Remove Mesh from WaterMaterial and MirrorTexture?

How can I remove a mesh from the WaterMaterial and MirrorTexture after it has been added?
I’m trying to optimize and remove some reflective meshes if targetFPS is not reached.
But I can’t make it work. Any help?

WaterMaterial: https://playground.babylonjs.com/#1SLLOJ#3568
MirrorTexture: https://playground.babylonjs.com/#1YAIO7#684

For the water case, you can do it by accessing the renderList property of the reflection / refraction textures:

However, having a method to do it would be better, so here’s a PR that adds a removeFromRenderList method:

Regarding the mirror texture case, it’s a closure problem: because mirrorMaterial is declared as a var, the 4 setTimeout calls will only operate on the last value of mirrorMaterial. Use a let instead:

1 Like

You’re a legend. Many thanks!