I was always wondering how hard it might be to simulate ocean waves and decided to take a look under the hood with a simplified demo that can run in real-time (Modern movies with ocean waves are rendered over a long period of time with much higher resolution and precision). Since I studied electromagnetics, i became obssessed with the idea of using one of the commonly used algorithms for that purpose – FFT. Luckily,there is the famous work on this topic – “Simulating ocean water” from Jeremy Tessendorf from 2002.
Since all the information about the wave spectrum and the equations used to compute the moving ocean surface are located directly within the paper, I will ommit the tematics here in the post. The script that I have created uses Timers to properly animate the waves. The most demanding part of the algorithm is the IFFT function. Curious readers and/or CUDA/GPGPU enthusianists are free to accelerate the computation via cuFFT library for even better performance, or give a try to the Matlab’s “GPU Array” functions. Althought non power-of-2 FFT grid sizes are allowed, they are not recommended for performance reasons.
The demo does not include the “choppy” waves. It may be added though at a later time 😇 As always, the demo is available ➡️ HERE ⬅️ and includes the original Tessendorf’s work papers.