This is a little side project I got hung up lately, it’s another of my feeble attempts at making better water.
The goal is to create a water surface (height map and/or normal) that reacts to objects on it, but I also wanted an ability to draw a line on an image and say “this is my shoreline, you shader, draw me some wave here”.
I’m not sure how sane my idea is but the concept is such:
- Create a (buffer?) texture with points/lines that will be the origins of waves
- Feed the texture from #1 to a shader that will expand each point to a ring and fade it out over time (this works by using a ping-pong buffer running a kind of cellular automaton shader)
- Use the texture from #2 to make a normal map each frame
The code so far looks thus:
github.com/wezu/p3d_wave
The map it generates looks something like this:
At the moment it simulates a rain like effect, by moving some points around in the #1 buffer, but as you can see on the screen, it has a flaw - rings that intersect don’t get added like waves should, but cancel each other out
If anyone know how to improve my shader or has a better idea how to make an effect like that (possibly without going into the math of sombrero functions) then I’d much welcome the help.