# Remove Mesh from WaterMaterial and MirrorTexture?

**URL:** <https://forum.babylonjs.com/t/remove-mesh-from-watermaterial-and-mirrortexture/42146>\
**Category:** Questions\
**Created:** [July 4, 2023, 3:14pm UTC](https://forum.babylonjs.com/t/remove-mesh-from-watermaterial-and-mirrortexture/42146 "2023-07-04T15:14:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![a\_bolog](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/a_bolog/32/6292_2.png) [@a\_bolog](https://forum.babylonjs.com/u/a_bolog)\
**Post date:** [July 4, 2023, 3:14pm UTC](https://forum.babylonjs.com/t/remove-mesh-from-watermaterial-and-mirrortexture/42146/1 "2023-07-04T15:14:19Z")

</div>

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](https://playground.babylonjs.com/#1SLLOJ#3568)  
MirrorTexture: [https://playground.babylonjs.com/#1YAIO7#684](https://playground.babylonjs.com/#1YAIO7#684)

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [July 4, 2023, 4:39pm UTC](https://forum.babylonjs.com/t/remove-mesh-from-watermaterial-and-mirrortexture/42146/2 "2023-07-04T16:39:10Z")

</div>

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

> **[Babylon.js Playground](https://playground.babylonjs.com/#1SLLOJ%233570)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

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

> <https://github.com/BabylonJS/Babylon.js/pull/14023>
>
> See https://forum.babylonjs.com/t/remove-mesh-from-watermaterial-and-mirrortextu…re/42146

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:

> **[Babylon.js Playground](https://playground.babylonjs.com/#1YAIO7%23686)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![a\_bolog](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/a_bolog/32/6292_2.png) [@a\_bolog](https://forum.babylonjs.com/u/a_bolog)\
**Post date:** [July 4, 2023, 4:56pm UTC](https://forum.babylonjs.com/t/remove-mesh-from-watermaterial-and-mirrortexture/42146/3 "2023-07-04T16:56:37Z")

</div>

You’re a legend. Many thanks!
