How would you cull a water intersecting a ship when viewing inside?

I don't really know how to explain it, im going to post a pic for illustration. If im going to use a plane, the water then would go through the ship's inside. How would I hide it? alt text

Try using a DepthMask shader.

At first glance it looks like an easy problem, but it becomes harder once you start to appreciate it. I guess I have come up with three approaches that doesn't involve changing the mesh runtime.

  1. You could draw the water first and then clear Z buffer before rendering the ship. This won't look good if you're viewing the ship from outside. Maybe you could switch to clearing Z buffer only if you're looking from the interior of the ship to reduce this effect.

  2. You could perhaps draw the interior of the ship first using scissoring (if that is available in Unity, I don't know) to clip the sea rendering. Finally you could apply the boat. In fact I see now at my final touches to my answer that ina already posted a DepthMask shader that seems to achieve this.

  3. You could use render to texture to render the inside of the ship through a portal. This is probably somewhat more complex and I am not entirely sure how to go about it best. Basically you'd have the inside of the ship modeled somewhere else and have another camera mimic the main camera to render the insides and apply the resulting texture to the boats main surface plane. Think of it like a mirror, but not really a mirror. More of a portal.