Invisible Depth Mask

I’m working in unity, and trying to get a similar hole, “depth mask,” effect to the one posted here.

http://vimeo.com/25654703

The ground recedes into the surface of the table. I will basically need to embed an object’s surface, like in the video, while hiding any embedded geometry, other than that which is visible from the hole at the top. There is a the wiki depth-mask script

http://www.unifycommunity.com/wiki/i...itle=DepthMask

but I cant seem to get the same effect as receding ground. For instance, trying to hide the water in that tutorial, either by removing the mesh-renderer, or by applying an see-though texture, doesn’t seem to work.

How did you go about doing this? Or is there a tutorial I can reference? Any information you could give me would be very much appreciated.

Thanks,

Just use a ring of polygons around your geometry you want to hide (red mesh):

Then apply this simple material to this (red) mesh:

Shader "DepthMask"
{
	SubShader
	{
		Tags {"Queue" = "Geometry-1" }
		Lighting Off
		Pass
		{
			ZWrite On
			ZTest LEqual
			ColorMask 0		
		}
	}
}

That’s it :sunglasses:

I have been trying to find a shader that would mask another item, and I’d been looking for a while. This isn’t at all the intended use I had in mind, but it works great for having polygons mask out objects behind them. Thank you!

I’m trying to use this by creating a place, and masking the terrain (creating the appearance of a hole). Is this not usable for that?
All I get is an invisible plane.

[Edit]
But, it works great. Here’s a screenshot of a cave a manually put together with planes, under the terrain:

ok. This only appears to work with Forward rendering. Any idea how to make it happen with Deferred?

Modifiying the render queue in Deferred rendering doesn’t work like in Forward. I don’t know if this is a bug or just a technical limitation with deferred rendering.
You could try to use a 2nd camera, but I guess this is slower in deferred…

I actually am using a 2nd camera, I wasn’t sure how to get it working with just one :slight_smile: One renders just the cave layer containing the cave, the “Main” camera renders the invisible plane, everything else.

And it is -significantly- slower…going by the stats window, at least.