gerstnerWave: Physically-Based Ocean Wave Generator
Mathematical Foundation of Water Surface Dynamics
The Gerstner wave represents the most physically accurate mathematical model for ocean surface simulation. Unlike simple sine wave approximations, Gerstner waves reproduce the characteristic sharp crests and rounded troughs observed in real ocean conditions.
The mathematical foundation centers on the wave equation where particle motion follows elliptical trajectories rather than simple vertical oscillations. The core formula relates wave steepness to wavelength through the wave number :
Where represents the phase velocity derived from deep water gravity wave theory, denotes the normalized wave direction vector, and represents the surface normal.
ライブエディター
const fragment = () => { const waves = gerstnerWave(uv.mul(4), vec2(1, 0.3), 0.8, 2, iTime.mul(0.5)) const height = waves.y.add(0.5) const foam = vec3(0.1, 0.4, 0.7).select(vec3(1), height.greaterThan(0.9)) return vec4(foam.mul(height), 1) }