- Home /
Hide water
My main goal is to hide the proportion of the water that is inside a ship like the one below. How should I go about it? (sorry for the sail-less ship)

The desired effect could be something like this:

I am aware that there are some shader's trickery that solves problems of the sort. I am no expert with shaders but I am happy to go deeper if that's what it needs to.
Also regarding shaders, I have thought to "underlap" the water material when a player gets inside the ship. There might be a solution down this hill as well.
I have considered to disable all water tiles when a player enters the inner of a ship, but that would force a limitation on the designing of ships, and it would only partially solve the problem as there are situations where the player can both look at the water level from inside and outside the ship.
Answer by tanoshimi · Feb 15, 2016 at 12:00 PM
There's an example explaining a solution to this exact situation on the Unity wiki. You need to write a value to the depth buffer before drawing the water: http://wiki.unity3d.com/index.php?title=DepthMask
Wouldn't that make the underwater part of the ship (it's keel for example) to look over water? Also, wouldn't that mess up the ship's relation to other objects?
No. You draw the ship as normal but write an (invisible) mesh to the depth buffer only immediately before rendering the sea. Shouldn't have any effect on any other elements in the scene
Your answer