gerstner waves

What I dislike about the Gerstner wave algorithm is that it displaces the point you want to calculate the height of the wave at. It is possible to find such a point that it will be displaced exactly into the point you want the height to be calculated in, but this is cumbersome. Otherwise, the heightmap grid needs to be irregular. What approach do you use to calc the Gerstner wave heightmap?

Well, I managed to do it… A nonlinear equation needs to be solved for every vertex in the heightmap. Is there anything obviously wrong with the image below?


Hi, that’s exactly what i need!
Could you share this equation??

you have:

f : R^2 -> R^3
(x, y) |-> (x’, y’, z’)

But you want to find the value of the function at a specific (x’, y’), so you need to find the value (x, y) that gets displaced into (x’, y’). The displacement of (x, y) is governed by:

x’ = x - sum(k_i * A_i * sin(k_i * dot(x, d_i) - omega_i * t))

I set x = x’ + c_0 * i + c_1 * j, where i and j are the vectors (1, 0) and (0, 1)

Then I solve the nonlinear equation

0 = c_0 * i + c_1 * j - sum(k_i * A_i * sin(k_i * dot(x, d_i) - omega_i * t))

After I get c_0 and c_1, I can calculate x and verify if it gets displaced into x’. Accuracy usually doesn’t matter much.

Hi, thanks for reply.
I based my code on equation

from this article
Please tell me, what exactly is k_i in your formula?
And dot(x, d_i) - how can you calculate dot product of scalar x and vector d_i? Did you mean dot((x,y), d_i)?

I was writing the reply quickly, as my wireless is unreliable. Variable x is both a scalar and a vector in my reply, as a scalar, it is a coordinate, as a vector, it equals x = (x, y). I can’t denote vectors and scalars differently in these forums.

The equation above is from the NVidia gpugems article, yeah. The only difference is the Q_i constant and a phase shift. I used the tessendorf article for my equation.

k_i is the wave constant, 2 * pi / lambda_i, probably w_i, in the NVidia article.

Actually, I now see an error in my reply:

x’ = x - sum(k_i * A_i * sin(k_i * dot(x, d_i) - omega_i * t))

should be

x’ = x - sum(d_i * A_i * sin(k_i * dot(x, d_i) - omega_i * t))

so you need to solve:

0 = c_0 * i + c_1 * j - sum(d_i * A_i * sin(k_i * dot(x, d_i) - omega_i * t))

Don’t forget to substitute x = x’ + c_0 * i + c_1 * j in the above equation. Also the equation is a vector equation, the 0 on the left side is the zero vector. You can make a system of 2 nonlinear equations out of this equation. I’m sorry for the inconvenience.

Even though I’ve managed to solve the problem, I suggest you consider either IFFT or statistical waves. There’s no nonlinear equation solving necessary for those methods.

thank you very much ;]
i hope this will help me a lot ;]

Just use some minimization algorithm (I use the taxi-cab method) or Newton-Rhapson for the root finding.