Hey guys. I have been spending a good amount of time and effort trying to find/create a solution for mobile devices to use water with “depth alpha” or “depth opacity”, where objects that are placed under the water, are only visible nearest the surface of the water, and the deeper they get, the more and more “hidden under the water” the object becomes visually to the player.
This might not sound like its that complicated, but in practice, I’ve yet to find a solid tutorial, code snippet, or open source shader that shows how to achieve this effect. I’ve seen things like the free open source ocean system that has had a few different authors working on it, as well as plenty of water examples that don’t have any different rendering no matter how deep the object gets.
An example of a (bad) workaround might be to layer 5 or so planes/quads on top of one another, each with slight transparency, so that the deeper the objects were, the less transparency there would be visible, like you see here:
But that is obviously not the solution I’m looking for, it looks bad, and probably would even have rendering problems on some mobile devices… another less than perfect solution might be to manually change the alpha of objects the lower they get in the water… but this also is not an optimal solution and wouldn’t work for objects not specifically decided to be adjusted at lower depths.
So how in the world do you guys do this? I’m not asking for a asset store package to solve this problem (although I’d be interested to see/hear how they did it for those water assets available in the asset store) but I’m hoping somebody can actually shed some light on specifically what worked, whether you wrote a custom shader, or used shader forge, or did something else entirely!
How did you make your mobile water “darker” at lower depths? Thanks ahead of time for any info and tips that might help me figure this out!
EDIT: another thing I’ve heard of is “schlicks fresnel equation” - which I don’t know anything about, but perhaps would help me?
EDIT2: forgot to mention, the “pro water” is too performance heavy for my target devices, so even though it might have options to do this sort of stuff (not sure) I found it was just too slow even on default settings for mobile devices.




Editor
Android