NatureGL Waterv1.1.0

Guides

Waves, wind and foam

Three numbers shape the sea. Wind speed sets how high and how steep the waves are, the peak wavelength sets how long the swell is, and the direction sets where it travels. Foam follows from how hard the crests fold.

storm: 19 m/s wind over a 72 m swell. Significant wave height is 6.08 m, and whitecaps linger in the persistent foam field after the crests pass.

#The wave dials

ParamDefaultEffect
wind6Wind speed in m/s. Sets the significant wave height and the chop
wavelength32JONSWAP peak wavelength in metres: the length of the swell
windDirection216.87Direction the waves travel toward, in degrees (0 = +X, 90 = +Z)
choppiness1Multiplier on the wind-derived steepness

The wave height comes straight from the wind and the wavelength:

Hs   = min(0.21 · wind² / g, wavelength / 12) + 0.08      (metres)
chop = min(0.92, (0.38 + wind / 32) · choppiness)

So a longer wavelength only raises the sea once the wind can build it, and short waves can't get taller than a twelfth of their length. Read the result at runtime from water.stats.significantWaveHeight and water.stats.chop.

js
water.setParams({ wind: 14, wavelength: 60 });     // a building sea, eased
water.setParams({ windDirection: 90 });            // waves travelling toward +Z
water.stats.significantWaveHeight;                 // ≈ 4.3 m once eased

The spectrum is rebuilt from the eased values every frame, so changing wind or wavelength morphs the sea rather than jumping. Every numeric param eases toward its target over about 1.5 s. time and windDirection take the short way round.

#Two wave sources

The quality tier picks where the waves come from. Both read the same wind, wavelength and windDirection, so presets look alike on every tier.

Gerstner (low, medium)FFT (high, ultra)
What it is24–56 Gerstner waves sampled from a JONSWAP spectrumTessendorf FFT of a JONSWAP directional spectrum
Resolutionwaves components128² × 2 cascades (high), 256² × 3 (ultra)
TilingNone, it's analyticThe 512 m swell cascade repeats, softened by rotated detail cascades (67.3 m, 10.7 m) and fog
CPU samplingEvaluates the same sumReads back the swell cascade, 1–3 frames late
js
water.setQualityLevel('high', { waveSource: 'gerstner' });   // Gerstner on the high tier
water.setQualityLevel('ultra', { fftCascades: 2 });            // cheaper FFT
water.fft;                                                     // FFTWaves on FFT tiers, else null

Either way the ocean is a polar grid centred on the camera. Long waves displace the vertices, the short band is added per pixel, and waves smaller than a pixel become surface roughness. That's why far water turns rougher and brighter instead of shimmering.

#Foam

Foam comes from five places:

SourceDial
Whitecaps and streaksfoam (1)Where crests fold (the displacement Jacobian drops), plus wind streaks above about 9 m/s
Linger timefoamPersistence (4 s)How long whitecap foam takes to fade, scaled by 0.5 + wind / 20
Breakers and swashshoreFoam (1)Where shore waves break, and the swash on beaches. See Shorelines
Contact lineshoreFoam (1)A thin line wherever your geometry pierces the surface, found from the depth buffer
HullsaddWakeWhite water round each tracked hull, a Kelvin V and a trail. See Buoyancy and wakes

On medium and above, whitecaps are stamped into a persistent foam field: a texture of 256² to 1024² texels covering 256–400 m round the camera. Foam stays where the crest broke, drifts with the wind, and breaks up into lace as it fades. On low the field is off and foam lives only on the crest that makes it.

js
water.setParams({ foam: 1.6, foamPersistence: 8 });   // long-lived, heavy whitecaps
water.setParams({ foam: 0 });                          // glassy, no whitecaps

#The look of the surface

These change how the water shades, not how it moves.

ParamDefaultEffect
glitter1GGX sun specular. The peak is clamped, so the sun path glitters without fireflies
sss1Subsurface light through thin crests
reflections1Screen-space reflections of your scene (high and ultra). The sky is always reflected
refraction1Refraction distortion and the depth blur of the seabed
sunset: a long glitter path under a low sun
arctic: 11 m/s over a 55 m swell, steel-blue water

The full list is on Water parameters.