So finally I finished with Shoreline implementation. I know my work should be over by now but I'm happy with new things i'm learning each day. :D. Basically I took a foam texture (programmers art like) and blended it on ocean mesh where ever ocean touches terrain.
This is done by first getting all the points( These points are in world space) where ocean touches terrain and then scale them down to store it in an array. Till now all steps are pre-computed on CPU. That array is now passed to shader program. Now in a vertex program, nearest distance between vexter position and array of foam points is computed and then that distance is passed to fragment program. In fragment program foam Colour is clamped depending on the distance.
I got pretty much everything working with ease except for first step i.e. Getting the foam point.
To get foam points first I got terrain from engine into the water plugin. Then iterated over each terrain cell's height map. Now the thing took me so long was that The coordnate system usually start from bottom left corner so are iteration over cells. But when you are performing texture(heightmap) lookups the coordnates start from top left corner. It took me 7 days to understand this.
This is how it looks like:-
*Array size is limited to 1000 a better way would be to create a texture and store all those points in it and perform a texture lookup in shaders
*This shoreline only works for Terrains. In order for them to work for any mesh, a plan collider can be used to get foam points. Rest of the steps would remain the same.
|<< <||Current||> >>|
This is the long description for the blog named 'Blog All'.
This blog (blog #1) is actually a very special blog! It automatically aggregates all posts from all other blogs. This allows you to easily track everything that is posted on this system. You can hide this blog from the public by unchecking 'Include in public blog list' in the blogs admin.