Computing vertex normals for gerstner waves

I’m trying to implement normals calculations for waves displacement by JBaldwin (here)](JBaldwin - UE4 Content Preview Thread - Work in Progress - Unreal Engine Forums) I found nvidia paper he based on and read it. Equations that are of interest to me:

However I’m not sure about what Di.x and Di.y are suppoused to be, x and y values of direction vector, or maybe something else? Also since Di is 2d vector, and P is 3d, I can’t calculated dot product of Di*wi and P, does that mean there is an error in nvidia paper?

Di is 2d direction vector, thats correct. In case with P, I don’t really remember sadly. Most likely it is 2d position with offsets applied. Or Di is 3d vector with z being 0

I’ve used a different,cheaper approach to calculate normals. I will link the article later if i manage to find it, because GPU gems paper is indeed a bit confusing.

Yes, that is exactly right.

We ended up leaving Amplitude & Steepness out of the equation until the very end, this way we don’t need to worry about the Z component. It’s not exactly the same formula, but does have the same results.

Also, the definition of P is:
Dir.X, Dir.Y, Time

With time being used to calculate the height of the wave (sin wave) at that position.

Here’s what the material function looks like (based off GPU Gems using equations # 9 & 13, right click and open the image in a new tab/window for full size):


If you click the link in my signature you can find a complete implementation with adjustable parameters in 8 wave clusters. Feel free to use it (even if only as a reference) :slight_smile:

One thing to note with this paper is that there is a symbol missing near the beginning where pi is meant to be. This throws a lot of the math off. There is a pdf of the article somewhere online that has the right symbols. I’ll try and link to it when I get home.

Either you can consider P to be 2d or you can append D with a 0 to make D 3d. And D.x/D.y are the sepearate components of your 2d input vector. I got this working a couple of months ago. One of the implementation I saw on the forums was slightly wrong (even though it looked like waves). There was a youtube vid of it where there was averaging of the multiple frequencies. Instead they should just be added.

I’ll see if I can post my working solution.

Hello, thanks for all the replies, it turned out that I did it correct before, but due to en error in projected grid I made, whole plane was flipped upside down. insert ashamed emote here I decided to go along with DotCams implementation though, since it’s actually really amazing project and it makes no sense to reinvent the wheel when there is already whole car built.
Thanks again.