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
[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_123320_1511309382607_498”}[/ATTACH]
https://forums.unrealengine.com/core/image/gif;base64
To implement this I used the formula from this https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch01.html[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_123322_1511309678167_663”}[/ATTACH]
https://forums.unrealengine.com/core/image/gif;base64
[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_123323_1511309799762_470”}[/ATTACH]
https://forums.unrealengine.com/core/image/gif;base64
[ATTACH=JSON]{“data-align”:“none”,“data-size”:“medium”,“data-tempid”:“temp_123324_1511309898456_144”}[/ATTACH]
https://forums.unrealengine.com/core/image/gif;base64
[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_123321_1511309577588_843”}[/ATTACH]
https://forums.unrealengine.com/core/image/gif;base64
First things first we have W*
[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_123325_1511310001614_108”}[/ATTACH]
https://forums.unrealengine.com/core/image/gif;base64
Here we have Q*
WaveSteepness / (W* * A* * WaveAmount)
[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_123327_1511310343846_551”}[/ATTACH]
https://forums.unrealengine.com/core/image/gif;base64
Here we have Phase which is P = WaveSpeed * W* or P = WaveSpeed * 2/L
We can also see on the side Phase * Time
[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_123329_1511310650125_706”}[/ATTACH]
https://forums.unrealengine.com/core/image/gif;base64
So first I Do W* * Dotproduct of the World Position, and the Wave Direction
Then Phase * Time
[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_123330_1511310792547_685”}[/ATTACH]
https://forums.unrealengine.com/core/image/gif;base64
Then they’re added together and I get the Cos and Sin of this
[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_123331_1511311394001_611”}[/ATTACH]
https://forums.unrealengine.com/core/image/gif;base64
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
[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_123333_1511312562234_361”}[/ATTACH]
https://forums.unrealengine.com/core/image/gif;base64
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
[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_123341_1511315036923_662”}[/ATTACH]
https://forums.unrealengine.com/core/image/gif;base64
All the numbers should be the same as used in the Material
Here is the blueprint for the cube
[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_123342_1511315445638_283”}[/ATTACH]
https://forums.unrealengine.com/core/image/gif;base64
I made a video showing the results (sorry about the music it was just playing in the background) https://youtu.be/kUxe1DiAWFA
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.