- Home /
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:
http://www.youtube.com/watch?v=cz7xX8kV7vY
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.
Answer by AlucardJay · May 10, 2014 at 09:24 AM
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 =]
Thank you! It works perfectly. But I had to change the camera option - clear flag to solid color for my application.
Hi , I tried what you said but it didn't work. I need to Hide part of a mesh so that it appears like a window
This almost works. Is there a reason why the shaders on the objects underneath the plane don't show? The objects show, but not with their shaders.
*Edit, Never $$anonymous$$d, I forgot to increase the Queue size to allow for all of the shaders