Real-time rendering and plausible simulation of oceans
Master Thesis - Limbic Entertainment GmbH
About
I saw my Master Thesis as an opportunity to gain a foothold in professional life. The game developer Limbic Entertainment near Frankfurt am Main was interested in a collaboration and I am really grateful that it worked out, even though it fell right in the time when Corona hit. With Real-time rendering and plausible simulation of ocean we found a challenging topic that can be well studied scientifically and that was of interest for an unannounced project by Limbic Entertainment. Now, over 1 year later, I am still employed by Limbic Entertainment as Graphics Programmer and I am really proud of the thesis’ results.
Abstract
An ocean that reflects wind conditions, reacts to the terrain and interacts with rigid bodies has great potential to improve believability of virtual worlds. Its simulation and rendering need to be fast enough to meet the real-time requirement in conjunction with many other features. This work employs a multi-band Fast Fourier Transform approach to synthesize a mixed sea ocean surface valid in deep water. A sampling strategy for wave spectra suitable for seamless transitions of sea states is introduced, and recommendations for a complete GPU implementation are made. Deep water is coupled with a shallow water simulation to supplement terrain awareness and rigid body interactions. For this, a recent improvement of the Lattice Boltzmann Method with reduced memory usage is adopted and implemented on the GPU. It is found how its properties can be used to cover a large-scale area with varying level of detail which may be of interest beyond the computer graphics research. A performance analysis and discussion of the results demonstrate the suitability for real-time applications, point out deficiencies and suggest exciting future work.
Personal highlights
My personal highlights of this work are the quadratic LOD scheme for the shallow water simulation and the Wave Spectra sampling strategy required for the FFT that runs completely on the GPU.
Quadratic LOD scheme
Researching the Macroscopic Lattice Boltzmann method to solve shallow water equations showed some interesting properties. Simply by defining the minimum lattice size $\Delta_{min} $ and grid resolution $n$ (must be power of two) we can derive all parameters required for the LOD scheme with simulation layers of quadratically growing spatial side lengths. Since the simulation time step $\Delta t $ is linearly dependent on the the lattice size $\Delta x$, each layer can be simulated in $M$ sub-steps which also grows quadratically. Intuitively this can be seen as a way to slow down the simulation while keeping the workload constant.
Applying this scheme results in rather astonishing numbers. A grid resolution $n = 1024$ and $\Delta_{min}~=~0.125m$ allows for a very detailed simulation of $12.5~\text{cm}$ at the highest detail level $0$ while covering an area of $1310.73~\text{km}$ for the lowest detail level $10$. Additionally, the number of simulated layers can be limited with currently active layers depending on the altitude of the camera.
Many more details to this scheme are considered in the thesis, like special boundary conditions that allow wave propagation between LOD layers and realignment of the focal point parallel to the sea surface.
Sampling Wave Spectra
An important improvement to the FFT for a real-time application is band division. Due to the $\mathcal{O}(n\log{}n)$ nature of the FFT, having multiple smaller grids is preferable to a single large grid. However, this makes the sampling of wave spectra more complicated.
Below there is an interactive example of the sampling strategy for the JONSWAP spectrum that is well suited for high frequency wind waves. Additionally, the thesis presents the JONSWAP-GLENN spectrum which allows for more intuitive control of low frequency swell waves.
Global and Sampling Parameters
Static Spectrum Parameters
Dynamic Spectrum Parameters
With the static parameters, the band subdivision can be setup for an average sea condition which is then animated at runtime using the dynamic parameters. At runtime, only dynamic parameters can be a updated without changing the spatial length of bands. This is important, because the spatial length of bands cannot be changed without unpleasant scaling of the surface texture.
The band sampling range is controlled with the help of 3 parameters:
- $\gamma_s$ shifts bands towards or away from the peak.
- $p_L$ controls the first band’s upper bound relative to the spectrum’s peak.
- $p_U$ controls the frequency range of the whole spectrum
With $\gamma_s = 0$ the first band spans from zero to the static spectrum’s peak frequency times $p_L$. Therefore it is aligned with the peak for $p_L = 1$. This allows for a rather intuitive control of the spectrum.
In practice, the band sampling intervals will be tuned once to achieve satisfying results for a desired range of dynamic spectrum parameters.
Additional material
ShaderToy Shallow Water
The simulation code for the Shallow Water simulation is available with an interactive demo on ShaderToy.
- Space: Toggle View Mode
- Q: Toggle Force Input Mode (Height / Velocity Injection)
- W: Toggle Water
- R: Reset Simulation
Procedural object interaction
Influencing the shallow water simulation is possible through a set of procedural equations manipulating the water depth or velocity within implicit spheres and capsules.