Does anyone know how to implement these depth-mask shaders?

I’m trying to create a plane that I can place over-top of the terrain which will hide the terrain but render all other things. For placing a cave under the terrain.

Here is a video of somebody using this technique:

And here are the shader scripts:
http://wiki.unity3d.com/index.php?title=DepthMask

I’m not sure I understand how to apply this for terrain though. Or where to attach the scripts.

The wiki link you gave has an example project to download.

Disclaimer : Never done this before, but for a quick test just now.

  • Import the SetRenderQueue.cs script
  • Import the DepthMask shader (I changed Tags {“Queue” = “Geometry+200” } as in the video)
  • Create a material, name it MaskMaterial, set the shader to Masked/Mask

now set up the scene :

  • put in terrain and a directional light
  • create a plane, position it just above the terrain
  • drop the MaskMaterial onto the plane
  • drop the SetRenderQueue.cs script onto the plane, set the Queues elements to 1800
  • create a cube, position it just under the terrain (behind the plane!)
  • drop the SetRenderQueue.cs script onto the cube, set the Queues elements to 1500

Done! Hit play and move the camera around.

In both the video and the example project, there was no script on the mask plane, but I couldn’t get it to work without adding it and setting the Queues Elements to 1800

So anything you want to render under the terrain behind the mask, add the SetRenderQueue.cs script and set the Queues elements to 1500

As in my disclaimer, I only just tried this for the first time now. Let me know how it goes =]