How to clip out meshes in front of other meshes when using RenderTargetTexture?

I found an awesome tutorial covering using RenderTargetTextures and Image Post processing passes with a really cool playground showcasing a “water” effect here:

https://doc.babylonjs.com/how_to/how_to_use_rendertargettexture_and_multiple_passes

https://www.babylonjs-playground.com/#064AUB
Problem is, if you so much as add a sphere mesh over the “water” mesh the illusion breaks as the RenderTargetTexture is applied over the base image, even though the sphere should be on top it will look like the water is on top.

Is there a clear way around this? I imagine you must add the mesh to the renderlist of the RenderTargetTexture , but I don’t want the water effect to apply to the sphere.

You should apply a specific caustic material to the ground instead of doing a RTT / post process over the entire scene:

https://www.babylonjs-playground.com/#064AUB#1

2 Likes