# Mirror Texture Vs scene.freezeActiveMeshes

**URL:** <https://forum.babylonjs.com/t/mirror-texture-vs-scene-freezeactivemeshes/41381>\
**Category:** Questions\
**Created:** [June 5, 2023, 9:01am UTC](https://forum.babylonjs.com/t/mirror-texture-vs-scene-freezeactivemeshes/41381 "2023-06-05T09:01:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sravani](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@sravani](https://forum.babylonjs.com/u/sravani)\
**Post date:** [June 5, 2023, 9:01am UTC](https://forum.babylonjs.com/t/mirror-texture-vs-scene-freezeactivemeshes/41381/1 "2023-06-05T09:01:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [June 5, 2023, 12:01pm UTC](https://forum.babylonjs.com/t/mirror-texture-vs-scene-freezeactivemeshes/41381/2 "2023-06-05T12:01:00Z")

</div>

Unfortunately you can’t have both 🙂 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 🙂 What exactly are you trying to achieve? If you’re using freeze for optimizations, there are other optimizations you could try instead.

---

<div class="post-metadata">

**Author:** ![sravani](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@sravani](https://forum.babylonjs.com/u/sravani)\
**Post date:** [June 6, 2023, 7:08am UTC](https://forum.babylonjs.com/t/mirror-texture-vs-scene-freezeactivemeshes/41381/3 "2023-06-06T07:08:34Z")

</div>

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);

```

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [June 6, 2023, 1:37pm UTC](https://forum.babylonjs.com/t/mirror-texture-vs-scene-freezeactivemeshes/41381/4 "2023-06-06T13:37:31Z")

</div>

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