I’ve been researching this for a long time and consider several solutions. Let’s say we have an ocean that’s basically an animated mesh with waves and all. When the water meets terrain, one would want some effects such as foam texture, change of color, increased transparency etc.
The challenge is to find out in the water shader, for each vertex, how far it is from the terrain that’s below it. If the terrain is close enough to the water, then it means we’re near the shore line, and we can modify the vertex color accordingly. An easy way would be a premade map that tells the shader where the water is shallow, however we can’t do this if the ocean is supposed to be dynamic - for example, in a large scale scene, the water surface mesh can’t be infinitely large so one would have to move it along with the player as the player move across the terrains, so the premade map would be useless once the ocean moves against the terrain.
I’m a beginner with shaders, but I have read in several places that a depth map can be rendered in real time for the water shader to know how far it is from the terrain below. I don’t quite understand how this works, but does anyone know if this is possible to do in Unity Pro?