I successfully implemented the equations from GPU Gems article for Gerstner waves.
Now I want to have the simple directional waves replaced by circular waves that concentrically emerge from a point.
From the GPU Gems article as well as a paper “Real-Time Rendering of Procedurally Generated Planets” by Florian Michelic, this should be possible by simply replacing the direction by the normalized vector between vertex position minus wave center position.
For testing, I do it in my material function by having a circular parameter to lerp between wave direction and wavecenter version, so I can be sure, that rest of the code is identical.
The result looks bad, as on the left image below: waves are strangely moving around, no concentic movement at all. The simple direction wave works fine.
Hi, buddy! I was having the exact same problem as you do and I’ve discovered the solution.
When you do the dot product between the direction and the position, you shouldn’t use the world position.
Instead, use the difference between the world position and the collision center.
Technically you’re considering the collision center the origin of the coordinate system you’re computing the waves in and by subtracting you’re translating every point in this system. Then, the formulas from GPU Gems work like a charm.
It should look something like this in code:
vec3 diff = world_position - collision_center;
vec3 dir = -normalize(diff);
float gernst_coeff = w * dot(dir, diff) + time * phi;
Hope it’s not too late!