Reference
Presets
Nine looks, one file each, in src/config/presets/. Every preset sets both the water and the light. Hover a card to see the water move, click to enlarge it, or run one live.
clearClear mountain stream at noon: turquoise over pebbles, strong caustics.morningLow warm sun from the east over the same clear water.goldenLong light and warm glints on the ripples.overcastFlat, soft light under a greyer sky.glacialMilky turquoise rock-flour water, faster and foamier.muddyBrown, opaque and fast, with heavy foam and almost no caustics.swampTannin-dark, slow, glassy water under a greenish haze.duskSun under the ridge, a purple sky and the first stars.nightMoonlit: stars, dim moon glints and dark water.#Loading presets
water.loadPreset('glacial'); // lighting eases over ~1.5 s, water over ~0.3 s
water.loadPreset('glacial', { instant: true }); // snap
water.loadPreset(myPresetObject); // any object in the preset formatcreate({ preset }) takes a name or an object too. Unlike some other packs in the series, a preset object must be complete: it replaces params rather than being merged into it. Start from getPresetParams() when you only want to change a few values.
import { PRESETS, getPresetParams } from 'naturegl-river';
Object.keys(PRESETS); // ['clear', 'morning', 'golden', …]
const p = getPresetParams('clear'); // deep clone, safe to edit
p.water.clarity = 1.8;
p.light.elevation = 30;
water.loadPreset(p);#Presets are plain data
/** Glacial melt — milky turquoise rock flour */
export default {
name: 'glacial',
label: 'Glacial melt — milky turquoise rock flour',
water: {
absorption: [0.55, 0.12, 0.09], scatterColor: [0.05, 0.3, 0.32], scatterDensity: 0.95,
clarity: 0.9, flow: 1.35, caustics: 0.45, foam: 1.25, turbulence: 1.3,
normalStrength: 1.1, refraction: 0.8, reflectivity: 1.0, wetness: 1.0,
horizonHeight: 0.24,
},
light: {
elevation: 34, azimuth: 24, sunColor: '#f2f6ff', sunIntensity: 2.7,
skyTop: '#6f98c8', skyHorizon: '#d4e2ea', fogColor: '#c6d6df', fogDensity: 0.0072,
hemiSky: '#d2e2ff', hemiGround: '#46514a', hemiIntensity: 1.2,
horizonColor: '#1f2c26', lightAmount: 1.0, exposure: 1.0, clouds: 0.6, stars: 0,
},
};Every field is described on Preset parameters.
#Try one live
glacial. Click the preset pills in the demo to switch.#Reference
The first four and the last two share the clear water of clear and change only the light.
| Name | Label | Clarity | Flow | Caustics | Foam | Sun |
|---|---|---|---|---|---|---|
clear | Clear Stream — noon | 1.1 | 1.0 | 1.0 | 1.0 | 55°, 3.2 |
morning | Clear Stream — morning | 1.1 | 1.0 | 1.0 | 1.0 | 17°, 2.6 |
golden | Clear Stream — golden hour | 1.1 | 1.0 | 1.0 | 1.0 | 7°, 2.3 |
overcast | Clear Stream — overcast | 1.1 | 1.0 | 1.0 | 1.0 | 42°, 0.8 |
glacial | Glacial melt — milky turquoise rock flour | 0.9 | 1.35 | 0.45 | 1.25 | 34°, 2.7 |
muddy | Muddy spate — brown, fast and opaque | 0.8 | 1.6 | 0.12 | 1.5 | 38°, 2.5 |
swamp | Swamp / still lake — tannin-dark, slow | 0.9 | 0.25 | 0.35 | 0.3 | 28°, 2.0 |
dusk | Dusk — sun just under the ridge | 1.1 | 1.0 | 1.0 | 1.0 | 2.5°, 1.5 |
night | Night — moonlit stream | 1.1 | 1.0 | 1.0 | 1.0 | 38°, 0.45 |
The sun column is elevation and sunIntensity. At night the "sun" is the moon: a blue-white light at 0.45 with stars: 1 and lightAmount: 0.16.