Always on top mask shader?

I’m pretty new to shaders but is it possible to make a mask shader that always is on top, making everything in it’s path and behind it invisible? I have been able to make a shader that makes a solid color shader always on top, but not a mask shader.

Just make sure that you turned off all color channels:

ColorMask 0

and that you still write to the z buffer:

ZWrite On

Your shader should be drawn before everything that should be “masked” of course :wink:

Have you tried the DepthMask shader?

http://wiki.unity3d.com/index.php?title=DepthMask

It masks everything that is behind it