Implementing Gerstner Waves with buoyancy problem : Need Please Help

I’ve been working on implementing Gerstner waves in Unreal Engine for a while now. I believe I’ve got everything working with the Material here’s an example


To implement this I used the formula from this[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_123322_1511309678167_663”}[/ATTACH];base64




First things first we have W*


Here we have Q*
WaveSteepness / (W* * A* * WaveAmount)

​ Here we have Phase which is P = WaveSpeed * W* or P = WaveSpeed * 2/L
We can also see on the side Phase * Time

​ So first I Do W* * Dotproduct of the World Position, and the Wave Direction
Then Phase * Time

​ Then they’re added together and I get the Cos and Sin of this


After this I take the X of the direction and multiply it by Q* * Amplitude. Then that is Multiplied by the Cos of the InnerFunction or in other words this Cos(w* * Dotproduct(Direction, Position) + Phase * Time)
And that will give you the offset of X. The same is done with Y simply using the Y of the Direction. However the Z offset is just the Amplitude * Sin(InnerFunction) ^

All of that was a Material Function to create a wave


In the Water Material 4 waves are created going in different directions, and all added together which results in the displacement for the material. The result being the first image.

Now, for buoyancy I wanted to get a super simple version to test, so I wrote this exact (that is it’s supposed to be) formula, using the same numbers, which i’ll show below, and using the z result I added that to 210. I added it to 210 because that’s the z of the waterplane before any displacements. Using a cube as a test which. As I said this was also just for testing, I plan on making the buoyancy much better than this however, until I’m getting the same results I can’t go any farther


All the numbers should be the same as used in the Material
Here is the blueprint for the cube


I made a video showing the results (sorry about the music it was just playing in the background)

As i’m writing this the video is uploading, so if it’s not available you may have to give it a minute. The text on the side is the results from the wave calculated, so how much everything is being offset(only Z on the cube is actually changed)
The results were that the box was going up and down very slowly and not even close to being inline with the waves height whatsoever. I do know that each vertex on the waterplane do move on the other axis as well, so even if the Z were working correctly it most like won’t be 100% correctly to the water height at that position, but the results were nothing at all like they should be. If I forgot anything that anyone would need to help me solve this problem please ask and I will provide you with the info you need. Thanks to anyone who can help me in anyway.

It seems after changing wavespeed in the C++ code to wavespeed * PI * 2 gets the speed correct with the wave, and matches with the wave, as long as it’s at 0,0. However if you move it anywhere from there nothing changes, it keeps going as if it was at 0,0.

I believe I’ve found a solution for anyone else who’d like to know. I changed Wi to Wi = 2 * PI / Wavelength, and set the period on the Sine/Cosine in the material as Pi * 2 or in this case 6.283185

There are 2 community projects both with buoyancy ocean x and ue4 ocean project. The later requires a plug in. There is also the marketplace, and nvidia waveworks. Most of whatever i needed was there.