Mirror Texture Vs scene.freezeActiveMeshes

I am using mirror texture for live reflection, and scene.freezeActiveMeshes for optimization. While enabling the scene.freezeActiveMeshes the live reflection is improper. If I remove “scene.freezeActiveMeshes” live reflection works fine. But I need these two. Please help me on this.

Unfortunately you can’t have both :slight_smile: A live mirror texture needs to have access to the updated list of active meshes to know what it should or should not render, while freezing the meshes will, well, freeze that list :slight_smile: What exactly are you trying to achieve? If you’re using freeze for optimizations, there are other optimizations you could try instead.

While enabling the scene.freezeActiveMeshes the filter is applied. if I remove the “scene.freezeActiveMeshes” the filter is not applied. Please help me on this.

I did something like this

let renderInterval = setInterval(() => {
let all_meshes = scene.meshes;
let ready_to_render = true;
all_meshes.forEach((cur_mesh) => {
let readyState = cur_mesh.isReady(true);
if (!readyState) {
ready_to_render = false;
}
});
if (ready_to_render) {
scene.stopAllAnimations();
clearInterval(renderInterval);
scene.freezeActiveMeshes();
let meshes = scene.meshes;
meshes.every(function (mesh) {
mesh.freezeWorldMatrix();
});
setTimeout(() => {
$(‘#loading-block’).css(‘display’, ‘none’);
$(‘.fadeInOut’).fadeOut(2500);
}, 1000);
BABYLON.Effect.ShadersStore[‘praaCombineFragmentShader’] = `
precision highp float;

          varying vec2 vUV;
          uniform float amount;
          uniform sampler2D textureSampler;
          uniform sampler2D lastFrameSampler;
          
          void main(void)
          {
              vec4 current = texture2D(textureSampler, vUV);
              vec4 last = texture2D(lastFrameSampler, vUV);
          
              gl_FragColor = last * (1.0 - amount) + current * amount;
          }`;
        //setup progressive anti aliasing post process

        //reset anti aliaising if camera changed

        self.resetRSAA = function () {
          praaSamplingStep = 0;
          praaEnabled = false;
          //enable praa after 200ms
          if (delayTimer != null) clearTimeout(delayTimer);
          delayTimer = setTimeout(() => (praaEnabled = true), 200);
        };
        let praaCombinePass = new BABYLON.PostProcess(
          'praaCombinePass',
          'praaCombine',
          ['amount'],
          ['lastFrameSampler'],
          1,
          primary_camera,
          BABYLON.Constants.TEXTURE_NEAREST_NEAREST
        );
        praaCombinePass.onApplyObservable.add((pEffect) => {
          if (praaEnabled && praaSamplingStep > 0) {
            pEffect.setTextureFromPostProcess(
              'lastFrameSampler',
              lastFramePass
            );
            let tAmount = 1.0 / (praaSamplingStep + 1);
            pEffect.setFloat('amount', tAmount);
          } else {
            pEffect.setTextureFromPostProcess(
              'lastFrameSampler',
              praaCombinePass
            );
            pEffect.setFloat('amount', 1.0);
          }
        });
        let lastFramePass = new BABYLON.PassPostProcess(
          'lastFramePass',
          1,
          primary_camera,
          BABYLON.Constants.TEXTURE_NEAREST_NEAREST,
          undefined,
          true
        );
        let delayTimer;
        if (self.eventsEnabled == false) {
          self.startEvents();
          self.eventsEnabled = true;
        }
        engine.stopRenderLoop();
        engine.runRenderLoop(function () {
          primary_camera.update();
          scene.render();
        });
      }
      self.SetupCamera(cameraObject['defaultView']);
    }, 200);

As per our question template please share your code in a Playground to facilitate reproduction :slight_smile: