---
id: "gerstner-waves"
title: "Gerstner (Trochoidal) Waves"
aliases: [trochoidal waves, sum of Gerstner waves]
domain: "volumes"
stage: "volume"
realtime: "realtime"
platforms: [webgl2, webgpu, desktop-gpu, mobile-gpu, unity, unreal, godot]
year_introduced: 2004
inputs: [material-params]
outputs: [heightfield, normals, mesh]
style: "both"
dynamic: "dynamic"
cost: "cheap"
authority: "Finch & Worlds"
url: "https://texelatlas.vercel.app/t/gerstner-waves/"
sources_verified_at: "2026-11-29"
---
# Gerstner (Trochoidal) Waves (Finch & Worlds)

> An analytic water surface made of a few sine-like waves in which each point also moves in a circle, yielding sharp crests and flat troughs with a closed-form displacement and normal.

## Reach for it when

- need cheap stylised water with sharp crests
- boats need a height query on the cpu for buoyancy
- mobile water that still looks like moving waves
- sine waves look too round and smooth
- a few controllable swell directions on a lake

## How it works

Each wave i has a direction D, wavenumber k, amplitude A and a speed from the deep-water dispersion relation, omega = sqrt(g k). For a point at rest position x0 and time t, the phase is theta = k D.x0 - omega t. The surface point is x0 minus D times Q A cos(theta) horizontally and A sin(theta) vertically, where Q is a steepness factor; the sum over waves gives the final surface. The horizontal term pulls vertices toward the crests, and keeping the sum of Q k A below one prevents loops. Normals come analytically from the partial derivatives, so shading needs no finite differences. The displacement is applied in a vertex shader on a dense grid, or the field can be ray-marched in a fragment shader by inverting the horizontal term with a few fixed-point iterations.

## When to use it

Choose it for stylised or mobile water, for a handful of directional swells on a lake or harbour, and wherever the height at a point must be cheaply and exactly queryable on the CPU for buoyancy.

Prefer [FFT Ocean (Tessendorf)](https://texelatlas.vercel.app/t/fft-ocean.md) when you need a realistic spectrum with hundreds of waves and tiling statistics. Prefer [Shallow Water Equations (Height-field Water)](https://texelatlas.vercel.app/t/shallow-water-equations.md) for ripples and wakes that react to objects. Use [JONSWAP Wave Spectrum](https://texelatlas.vercel.app/t/jonswap-spectrum.md) to choose wave amplitudes and wavelengths statistically.

## Cost

cheap — A few sine and cosine evaluations per wave per vertex or pixel.
Measured GPU Weight: 98.07× baseline (extreme) — 3.2266 ms median / 3.289 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 77.86× baseline (extreme) — 1.238 ms median (2.61× faster on L4).
Ampere A100 scaling: 65.59× baseline (extreme) — 1.889 ms median (1.71× faster on A100).

## Failure modes

- Self-intersecting loops at crests when the steepness sum exceeds one
- Visible regular repetition: with few waves the pattern looks periodic and synthetic
- Height at a world position requires inverting the horizontal displacement, otherwise buoyancy queries drift
- No foam, breaking or shoreline interaction on its own
- Aliasing and shimmering for short wavelengths when mesh density is low
- Mesh vertex density must be high or the displaced geometry shows faceting at the crests

## Engine support

- unity: official — `Package Manager > Shader Graph > Samples > Production Ready Shaders > Water (Gerstner)` (evidence: https://github.com/Unity-Technologies/Graphics/blob/557f6ac22b948284f57ffae6a789751fd1f63620/Packages/com.unity.shadergraph/Documentation~/Shader-Graph-Sample-Production-Ready-Water.md, checked 2026-12-01) — Shader Graph sample content (Gerstner subgraphs); not the HDRP Water System.
- unreal: official — `Enable the Water plugin; Water Body Ocean/Lake/River with a Water Waves asset (default uses Gerstner waves)` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/simulating-waves-using-the-water-waves-asset-in-unreal-engine, checked 2026-12-01)

## Dataflow

- Inputs: material-params
- Outputs: heightfield, normals, mesh
- Platforms: webgl2, webgpu, desktop-gpu, mobile-gpu, unity, unreal, godot

## Presets

### Four Gerstner waves, ray-marched ocean (glsl-fragment; rendered 2026-11-29)

```json
{
  "waves": 4,
  "steepness": 0.7,
  "gravity": 9.81
}
```

```glsl
// GLSL ES 3.0, Shadertoy-style. Sum of four Gerstner waves, heightfield ray-march, Fresnel sky reflection.
const float GRAV = 9.81;
const float STEEP = 0.7;
const vec3 SUN_DIR = vec3(-0.45, 0.28, -0.85);
// each wave: direction.xy, amplitude, wavelength
const vec4 WAVES[4] = vec4[4](
  vec4(0.96, 0.28, 0.55, 16.0),
  vec4(0.60, -0.80, 0.30, 9.0),
  vec4(-0.30, 0.95, 0.16, 5.0),
  vec4(0.85, 0.52, 0.07, 2.6));

vec3 sky(vec3 rd) {
  float t = clamp(rd.y, 0.0, 1.0);
  vec3 c = mix(vec3(0.75, 0.82, 0.90), vec3(0.18, 0.37, 0.70), pow(t, 0.5));
  float s = max(dot(rd, normalize(SUN_DIR)), 0.0);
  return c + vec3(1.0, 0.8, 0.5) * (pow(s, 600.0) * 6.0 + pow(s, 8.0) * 0.25);
}

// Gerstner displacement at rest position q. xy = horizontal offset, z = height.
vec3 gerstner(vec2 q) {
  vec3 r = vec3(0.0);
  for (int i = 0; i < 4; i++) {
    vec2 d = normalize(WAVES[i].xy);
    float A = WAVES[i].z;
    float k = 6.2831853 / WAVES[i].w;
    float th = k * dot(d, q) - sqrt(GRAV * k) * iTime;
    float Q = STEEP / (k * A * 4.0);
    r.xy += d * (Q * A * cos(th));
    r.z += A * sin(th);
  }
  return r;
}

// Height at world xz: undo the horizontal displacement with fixed-point iteration.
float height(vec2 xz) {
  vec2 q = xz;
  for (int i = 0; i < 3; i++) q = xz - gerstner(q).xy;
  return gerstner(q).z;
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
  vec3 ro = vec3(0.0, 3.2, 0.0);
  vec3 rd = normalize(vec3(uv.x, uv.y - 0.22, -1.0));
  vec3 col;
  float t = 0.0;
  bool hit = false;
  for (int i = 0; i < 90; i++) {
    vec3 p = ro + rd * t;
    float d = p.y - height(p.xz);
    if (d < 0.02 * (1.0 + t * 0.02)) { hit = true; break; }
    t += max(d * 0.6, 0.02);
    if (t > 250.0) break;
  }
  if (hit) {
    vec3 p = ro + rd * t;
    float e = 0.05 + t * 0.002;
    float h0 = height(p.xz);
    vec3 n = normalize(vec3(h0 - height(p.xz + vec2(e, 0.0)), e, h0 - height(p.xz + vec2(0.0, e))));
    float cosT = clamp(dot(n, -rd), 0.0, 1.0);
    float F = 0.02 + 0.98 * pow(1.0 - cosT, 5.0);
    vec3 refl = sky(reflect(rd, n));
    vec3 deep = vec3(0.01, 0.12, 0.17);
    vec3 shallow = vec3(0.06, 0.35, 0.38);
    vec3 body = mix(deep, shallow, clamp(0.5 + p.y * 0.8, 0.0, 1.0));
    col = mix(body, refl, F);
    col = mix(col, sky(vec3(rd.x, 0.02, rd.z)), 1.0 - exp(-t * 0.006));
  } else {
    col = sky(rd);
  }
  col = col / (1.0 + col);
  col = pow(col, vec3(1.0 / 2.2));
  fragColor = vec4(col, 1.0);
}

```

Attribution: written for this index; wave parameters are original sensible defaults

## Combines with

- [FFT Ocean (Tessendorf)](https://texelatlas.vercel.app/t/fft-ocean.md): Gerstner swells provide large-scale controllable motion while the FFT adds fine, statistically correct detail.
- [Real-time Water Caustics](https://texelatlas.vercel.app/t/water-caustics-realtime.md): Surface normals from the analytic derivative drive the refracted light that makes caustics.

## Sources

1. [primary] Mark Finch, Cyan Worlds Effective Water Simulation from Physical Models. GPU Gems, 2004. https://developer.nvidia.com/gpugems/gpugems/part-i-natural-effects/chapter-1-effective-water-simulation-physical-models (verified via http on 2026-11-29)

## Cite this entry

Texel. "Gerstner (Trochoidal) Waves." https://texelatlas.vercel.app/t/gerstner-waves/ (accessed 2026-12-01).
