# Ocean visible through the island's lake in Unity3D?

I'm working on a puzzle game featuring islands: there is a plane with a water shader, and objects colliding with that plane.

Now I'd like to make lakes on the islands, with different (higher) water levels than the ocean's.

The problem is that if I put a water plane in a "hole", I can see the ocean below at best, or even worse, the upper water surface just glitches out and disappear.

One option is that I move the lake's basin higher than the ocean's see level. This works, but I it doesn't look so good, because the lake becomes too shallow.

Another option is that I cut holes in the ocean's plane, but that seems a bit overengineered, isn't it?

Is there a better solution?

Also having a water plane for every "lake tile" causes some problems:

but I want to have dynamic lakes, so having a 2x2 water plane for a 2x2 group of lake tiles isn't a walkable path.

• Have you considered rendering a depth-only object below your lake water level to clip out the ocean before it's drawn, similar to the approach described here? – DMGregory Jun 12 '20 at 11:42
• Not yet, but sounds good. Could you help with the solution in the Answer? I'm a bit newbie with shaders. – Tudvari Jun 15 '20 at 16:47
• What specific help do you need? How far have you gotten, using the linked Q&A as a guide? – DMGregory Jun 15 '20 at 16:47
• I just don't get how does it work and thus how could I use that to solve my issue. Under "clip out" you just mean to draw an "opaque, only-depth" face above the ocean? If yes, how would that differ from my current "having a basin object above ocean? if no, how could I have the basin rendered, but the ocean not? I'm a bit confused here :\ – Tudvari Jun 15 '20 at 20:11
• Nice work! Thanks for sharing your answer! – DMGregory Jun 16 '20 at 20:05

Based on this answer: Fade in rendering mode doesn't work as intended

I've put a quad just above the ocean's gameobject in my lakes, with a material with this shader:

Shader "Custom/DepthReserve"
{
Properties
{
}
{
Tags { "RenderType" = "Opaque" "Queue"="AlphaTest+1" }
LOD 100

Blend Zero One

Pass
{

}
}
}


So this quad "reserves" the depth, not letting the ocean mesh to be shown.