Mirror texture with freezing active meshes

Hello!
I’m experiencing the reflection on the mirror texture to stop updating after I freeze active meshes for the scene. If you look at this PG Babylon.js Playground :

  • at first the red ball is animated along with its reflection
  • after 3 sec scene.freezeActiveMeshes() is called
  • after that the reflection stops updating

A similar issue was raised here:

but it was not solved, as far as i understand.

Thanks!

It’s kind of “by design”, @deltakosh or someone from the core will have to tell if it should stay as is or not, the question being: should the RTT textures used by mesh materials be updated when the active mesh list is frozen or not? For the time being, the answer is “no”. It’s debatable I think, as it’s not the meshes that are frozen (in which case freezing the RTT seems sensible) but the active mesh list (so the meshes themselves are still active)…

When the active mesh list is frozen, scene._evaluateActiveMeshes() is not run. However, it’s in the course of this function, namely in _evaluateSubMesh() that the RTTs used by materials are collected and put in the list of RTT to be rendered.

You can put those RTT to the list “by hand”, as in:

https://www.babylonjs-playground.com/#XYIK0Q#1

But it’s a kind of hack as I access the scene._renderTarget array, which is a private property.

A less hacky way is to put the RTT from the mirrors to the camera.customRenderTargets array:

https://www.babylonjs-playground.com/#XYIK0Q#2

1 Like

This is the recommended way :slight_smile: Maybe we can add it to the doc when talking about freezing active meshes?

1 Like

Adding this to docs would be great :slight_smile:

Thank you, will mark the customRenderTargets usage as the solution.

Fancy doing the PR for the doc change?

PR for the doc change?

Can you please check this one https://github.com/BabylonJS/Documentation/pull/1874 (and sorry for a late response)

2 Likes