Physical Simulation of Ocean Waves in Unity-Engine including Shader Development

For a pirate-themed game it was necessary to create ocean waves that not only look realistic but also physically interact with floating objects like boats. Just as the ocean is infinitely vast, so should it be in the game: A distance based tile rendering mechanism had to be implemented.

Challenge

Solution

Floating objects

The first attempt to simulate ocean waves involved using a plane as an object and applying a shader to it. This allowed the waves to be visually represented, but physical objects could not interact with them.

In the second attempt, the nodes of the plane were moved in the code rather than visually manipulated by a shader. This enabled physical objects to interact with the plane, but performance dropped rapidly even with a small number of nodes.

A combination of both solutions was required: The positions of the nodes were calculated and moved within a shader. The key idea was to replicate these calculations in the code, allowing physical objects to query the water height at a specific point without needing to compute every individual node.

Mathematical approximation

The Addition of multiple sine waves defines the height of the ocean at any given point. If you look at the surface of ocean-waves you will notice that particles on the waves not only move in height but also move back and forth. This behaviour can be simulated by using so called Gerstner waves.

Visual Appearance

Unitys shader graph is used to create the visual appearance of the waves. The height of a specific point defines its color and transparency. Looking through water a distorted

Discover more Projects

Neue Website für den Sonderforschungsbereich der Ruhr-Universität Bochum

Neue Website für den Sonderforschungsbereich der Ruhr-Universität Bochum

Single-Page-Application for a Multiplayer-Network to aggregate and display data

Single-Page-Application for a Multiplayer-Network to aggregate and display data

Show Product Manufacturing Information using Augmented Reality

Show Product Manufacturing Information using Augmented Reality

Jonas Albohm

Together we find asolutionto your problem.

solution