NatureGL Weatherv1.1.0

Reference

Quality levels

Four tiers, from integrated laptop GPUs to 4K desktops. A tier sets the particle counts, the fog and reflection step counts, the shelter taps and the shadow map size.

js
const weather = await WeatherSystem.create({ renderer, scene, camera, quality: 'medium' });
weather.setQualityLevel('ultra');    // at runtime
weather.quality;                     // 'ultra'
QUALITY_LEVELS.high;                 // the settings object

#At a glance

LevelRain streaksFlakesSplashesFog steps / scaleSSR stepsShadow mapShelter tapsPixel ratio*
low18k9k50020 / 0.3512102441.0
medium32k16k90028 / 0.4516204861.25
high55k26k150036 / 0.520204881.5
ultra90k42k240056 / 0.75284096122.0

* The pixel ratio is only applied with managePixelRatio: true. The demo applies it itself.

Particle counts are drawn at intensity 1. A drizzle at rain: 0.22 draws 22 % of them.

#Every field

FieldUsed by
rainRainSystemStreaks at full rain (capped by maxDrops, 90000)
snowSnowSystemFlakes at full snow (capped by maxFlakes, 42000)
splashRainSystemSplashes at full rain (capped by maxSplashes, 2400)
fogStepsWeatherPipelineVolumetric fog raymarch steps
fogScaleWeatherPipelineFog buffer resolution relative to the drawing buffer
ssrStepsWeatherPipelinePuddle reflection ray steps
shadowMapSizeyour shadowLightApplied to the light passed to setLighting({ shadowLight })
shelterTapsSurfaceWeatherOcclusion taps per pixel for dry-under-roof surfaces. 0 turns shelter off
pixelRatiorendererRecommended maximum pixel ratio

fogSteps, fogScale and ssrSteps only matter with weather.render(). Changing shelterTaps recompiles every patched material, so avoid switching tiers every frame.

#What it costs

Measured on an Apple M5 in headless Chromium at 1280 × 720, high, pixel ratio 1.5: 5.5–10 ms of GPU and CPU time per frame, depending on the preset. That's 100 fps or more; the demo itself runs at the 120 Hz cap. To measure your own machine, the dev helper node scripts/perf.mjs --quality high reports the frame cost per preset.

#Choosing a tier

  • Start at high. It's the default, and what the numbers above were measured on.
  • Test with full rain. downpour sets rain: 1, which draws every streak and splash the tier allows. Check your frame rate on it, not on clear.
  • Watch the pixel ratio. The scene pass, SSR and bloom run at the drawing-buffer size, and the fog at a fraction of it. On high-DPI screens, cap renderer.setPixelRatio() at the tier's pixelRatio, or pass managePixelRatio: true.
  • Adapt once, early. The demo measures its 2nd to 6th second and drops a tier below 30 fps. It's a simple pattern worth copying: see demo/main.js.
js
// the demo's tier switch
function setQuality(level) {
  weather.setQualityLevel(level);
  renderer.setPixelRatio(Math.min(devicePixelRatio, QUALITY_LEVELS[level].pixelRatio));
  renderer.setSize(innerWidth, innerHeight);
}