Feature Library

FFT ocean

4.77 GPU · 0.11 CPU ms
A still of the FFT ocean demo
Still
The live demo starts when it’s in view.Drag to look around · arrow keys too (Shift for bigger steps) · try Open water upwind

An open sea from a wind-wave spectrum (Tessendorf), summed back to heights, choppy sideways push and folds by a Stockham FFT on the GPU every frame, into…

What it costs a frame

4.77 ms
0.11 ms
GPU
4.77 ms
CPU, median
0.11 ms
CPU, 95th pct
0.18 ms
Draw calls
0
Weight
Heavy

Measured 11 November 2026 on 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 157, 1920×1080 at 1×. 600 frames × 3 rounds, median kept. What ran: The default sea at golden hour: two 256² cascades transformed every frame (spectrum, row and column FFTs, assemble, mips), the sky and far-sea pass and the ~370k-triangle ring mesh at 4× MSAA, timed with its own timestamp queries. The waves move by themselves. Phones: tiers are being measured next.

On every machine it was measured on
MachineGPU msCPU msCPU p95
unknown GPU · 13th Gen Intel(R) Core(TM) i9-13900Hreference · measuring tool4.770.110.18
apple · Apple A19 Proin a browser tab · 16 November 20266.520.240.34
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 20264.260.270.41

Bars against one 16.7 ms frame. A browser-tab run is timed in a visible tab without the tool’s scripted input, so read it as close, not exact.

What it needs

Renders with
WebGPU or WebGLWebGPU where there is one, WebGL2 where there is not.
Your browser
Runs hereNo WebGPU needed
Depends on
NothingNo other packages

What it’s for

  1. Open-water scenes in games
  2. Sailing and flight sims
  3. Hero backgrounds and title screens
  4. Coastal and weather visualisations
  5. Height and normal maps for your own water shader
  6. Lakes, bays and sheltered water that should not look like the open ocean

Pitfalls, in brief

  1. The FFT size must be a power of two from 64 to 512: one row is one workgroup of n/2 threads holding 2n values in shared memory, and 512 fills the default 16 KB exactly.
  2. Changing the wind, height or swell remakes the spectrum on the CPU (a few ms at 256², tens at 512²): do it at most once a frame, never per pointer event.
  3. Sample the slope texture with mipmaps and anisotropic filtering: without them the far sea and its sun path sparkle and shimmer, whatever the FFT size.
  4. Keep the long cascade’s tile well over the longest wave (the peak is ~7.7 V² / g): at strong wind on a short tile the energy piles into the tile’s own length and the repeat shows.
  5. The sideways push is in the textures, so a point’s height is at its displaced place: read the surface at a world point by its undisplaced coordinate (the mesh does), not by its final x and z.
4 more in brief
  1. Pipelines compile in the background (createComputePipelineAsync, createRenderPipelineAsync): nothing is drawn until create() resolves, and a new FFT size swaps in when ready.
  2. Never queue more than one frame ahead: the demo skips a frame while the last is still on the GPU.
  3. Without WebGPU, use OceanViewGL (ocean-gl.ts) on a canvas of its own: the same look and API, drawn straight to the canvas.
  4. A fully developed sea needs a long fetch (about 175 km at 10 m/s, more in stronger wind): set fetch for a lake, a bay or the lee of a coast, or a 10 m/s wind raises 2 m ocean waves on a 5 km lake (it should be about a third of a metre).
9 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Where it comes from

From SpaciousPro. Fully custom code.

Jerry Tessendorf, Simulating Ocean Water (2001): The method: a Phillips spectrum of random waves, each turned to its phase by the deep-water dispersion sqrt(g k), summed by an inverse FFT, with the choppy sideways displacement and its Jacobian for foam.

Thomas Stockham, the autosort FFT: The radix-2 Stockham formulation that ping-pongs between two halves of shared memory, so no bit reversal is needed.

K. Hasselmann et al., the Joint North Sea Wave Project (JONSWAP, 1973): The growth of a wind sea with fetch: significant height 0.0016 √(gF/V²) V² / g and peak period 0.286 (gF/V²)^(1/3) V / g, until fully developed.

Pierson & Moskowitz (1964): A fully developed sea’s significant wave height for a wind speed, 0.21 V² / g: the default height.

Olano & Baker, LEAN Mapping (2010): The idea behind storing the squared slope beside the slope, so a mip’s lost slope variance widens the glint.

Walter et al. (2007), GGX; Schlick (1994): The sun glint’s microfacet lobe and the Fresnel approximation, written in the shader by their published formulas.

Krzysztof Narkowicz, ACES filmic tone curve fit (2015): The display curve.

Mark Jarzynski & Marc Olano, Hash Functions for GPU Rendering (2020): Their pcg2d drives the foam’s value noise and the dither.

Tommy Ettinger, mulberry32: The seeded random behind the waves’ phases (public domain).

Kasten & Young (1989), relative air mass: How much air the sun’s light crosses at an elevation: its colour by Beer–Lambert.

ffttessendorfoceanwatercomputewgslraw webgpucascadesmipmapsfetchjonswaplakeswind waveswebgl2 fallback

Near it in the frame