NatureGL Waterv1.1.0

Reference

Presets

Seven seas, one file each, in src/config/presets/. Hover a card to see the water move, click to enlarge it, or run one live.

TropicaltropicalClear afternoon over a turquoise reef shelf.
SunsetsunsetLow sun, a long glitter path and warm haze.
DuskduskBlue hour just after the sun has set.
StormstormGale-force wind, long swell and breaking whitecaps under a dark deck.
FoggyfoggyCalm grey morning, visibility a few hundred metres.
MoonlitmoonlitNight sea lit by the moon and stars.
ArcticarcticCold, steel-blue water and a fresh breeze.

#Loading presets

js
water.loadPreset('storm');                     // ease there over about 1.5 s
water.loadPreset('storm', { instant: true });  // snap
water.loadPreset({ wind: 9, time: 7.5 });      // any partial params object

Anything a preset leaves out comes from DEFAULT_PARAMS, not from the previous sea. To change a few values on top of the current sea, use setParams.

#Presets are plain data

src/config/presets/storm.js
/** Storm — Gale-force wind, long swell, breaking whitecaps under a dark deck. (from index.html) */
export default {
  name: "storm",
  label: "Storm",
  time: 13,
  wind: 19,
  wavelength: 72,
  clouds: 0.96,
  cloudDarkness: 0.72,
  fogDensity: 0.0011,
  overcast: 0.75,
  absorption: [0.5, 0.13, 0.11],
  scattering: [0.012, 0.045, 0.05],
  exposure: 1.15,
};

Besides name and label, every preset sets the same ten params: the sky (time, clouds, cloudDarkness, overcast, fogDensity), the sea (wind, wavelength), the water optics (absorption, scattering) and exposure. The foam, shore, shading and bloom dials stay at their defaults.

js
import { PRESETS, DEFAULT_PARAMS, getPresetParams } from 'naturegl-water';

Object.keys(PRESETS);            // ['tropical', 'sunset', 'dusk', 'storm', 'foggy', 'moonlit', 'arctic']
getPresetParams('arctic');       // complete, deep-cloned WaterParams
getPresetParams({ wind: 12 });   // defaults + your overrides

#Try one live

Runs WebGL2 in this page · starts on storm
Starts on storm. Use the Sea buttons to switch presets and the sliders to change wind, wavelength, time and clouds.

#Reference

Hs is the significant wave height the wind and wavelength produce.

PresetTimeWind (m/s)Wavelength (m)Hs (m)CloudsFogExposure
tropical14:306320.850.320.000321.00
sunset17:337401.130.380.000451.05
dusk18:274300.420.220.00051.25
storm13:0019726.080.960.00111.15
foggy08:303240.270.600.00451.05
moonlit23:245360.620.180.00041.60
arctic11:0011552.670.550.00081.05

All seven came from the original single-file page's presets.