How to hide what is rendered behind a gameObject ?

Hi,

I’m generating meshes at runtime in my app.
I have 2 meshes in my scene :
2062559--134411--Capture d’écran 2015-04-10 à 14.14.17.png
I’d like to know if it’s possible to hide anything that is renderer behind the red mesh (so it would look like there’s a whole in the blue on) ?

Here’s what I’d like to render :
2062559--134414--Capture d’écran 2015-04-10 à 14.16.09.png

Could that be achieved using a custom shader that could hide stuff behind the gameObject to which its applied ?

Thanks :slight_smile:

This shader should work for you.
http://wiki.unity3d.com/index.php?title=DepthMask

1 Like

Thanks a lot, I just tried that and it works great. :wink: