Taos Explorer Technology Launch Taos ExplorerLaunch ↗

Technology / Rendering / 07

Rendering deep dive · 07

Rain, snow and wet weather

Wind-driven waves on San Francisco Bay in rain, thin rain streaks in the air and rings spreading on the water near the camera.
Rain on San Francisco Bay. The thin streaks are the GPU particle field around the camera; the rings are the water shader's own procedural drops. Two unrelated systems, driven by the same number: how much rain reaches the camera.
15,000 /sdrops spawned at the default rain amount (0.45); a downpour is about 33,000
24² over ±36 mcollision heightmap baked from the streamed terrain every frame
256² r8unormsatellite snow map, ±64 km about the camera, 500 m texels
22 sa change of weather, eased with a smoothstep
0.7 sone lightning flicker; the thunder follows d / 343 s later

Weather in Taos Explorer has to work for a camera that can sit on a runway, fly at 300 knots through a cloud deck, or climb to orbit in a single flight, over terrain that streams in from the network and has no GPU heightfield the effects could read. Rain has to stop when you climb above the cloud and come and go as you fly under storm cells. Snow has to lie where satellites saw it that week. And all of it has to cost nothing on the clear day most flights have. The answer is a small set of cooperating pieces: a pure-math weather conductor that sets targets; a few scalars (rain at the camera, ground wetness, snow cover, frost) eased with their own time constants; one particle field reused three times (rain, snow, drifting snow) and simulated in the camera's own frame; a screen-space pass that puts drops on the cockpit's actual panes; and a handful of shader terms in the G-buffer pass that wet, whiten and frost photographic ground the engine knows nothing about except its color.

Targets, not effects

The weather conductor

explorer/lib/weather/weather.ts · explorer/lib/weather/metar.ts · explorer/main.ts (updateWeather)

Nothing in the weather system draws anything. WeatherSystem is pure math with no engine dependency (it is unit-tested on its own): it holds a WeatherState of ten numbers and eases that state toward a target. The host reads weather.state every frame and pushes it into the systems that do draw: the volumetric clouds, the aerial-perspective height fog, the rain and snow particle fields, and the scalars described in the rest of this page.

TypeCoverBase–top (m AGL)Fog (1/m)RainSnowOther
clear0.041800–2600000
few0.251600–2700000
scattered0.51500–3200000the default
broken0.781300–3300000
showers0.451400–4200000shafts 0.8
high_clouds0.855200–6200000
overcast1.01000–3000000
light_rain1.01000–34000.00020.350
heavy_rain1.2800–40000.00060.80
snow1.1700–30000.001200.7ΔT −22 °C
thunderstorm1.35700–55000.000810lightning 1
light_fog0.61400–30000.00200
dense_fog0.81200–30000.01200

Each row of WEATHER_PRESETS is the whole definition of a weather type (density is left out of the table). Coverage above 1 is deliberate: the cloud shader reads it as "solid and heavy", which is how a storm deck gets its weight (see Volumetric clouds). The snow row's deltaT of −22 °C makes the air about −7 °C at sea level, cold enough for ice to build in cloud and for snow to stay on the ground.

Easing between rows

A change of weather does not jump. set(type) snapshots the current state into from and resets a blend parameter b to 0; each update advances it by dt · speed / transitionSeconds (22 s at speed 1) and mixes every field with a smoothstep of b:

Weather blend
s(t) = sfrom + (starget − sfrom) · b2(3 − 2b),   b = min(1, t · speed / 22 s)
  • sany of the ten fields: coverage, density, cloudBase, cloudTop, fogDensity, rain, snow, shafts, deltaT, lightning
  • speedthe Pace slider (effects.weatherPace, default 1); it also shortens the dynamic holds

Because sfrom is the live state, a change that arrives mid-transition starts from wherever the sky is, not from the previous preset. Dynamic weather (on by default, starting from scattered) holds a type for 90 to 240 s and then picks a neighbor from a weighted graph, WEATHER_NEXT: clear can only go to few, high clouds or light fog; a thunderstorm only grows out of showers or heavy rain; snow only comes from overcast, and an allow callback vetoes it unless the camera is above 2,000 m, beyond 62° latitude, or beyond 33° in that hemisphere's winter months by the sim's date. When every option is vetoed the system simply holds another while.

What the host does with it

In updateWeather the state overwrites the user-facing cloud settings (effects.cloudCoverage and friends, so the sliders show what the weather is doing) and the cloud renderer's settings; turns the rain on when max(rain, 0.7 · shafts) exceeds 0.02; and writes the fog into the lighting pass's height fog: density from the preset, its base at the eased ground elevation under the camera, a falloff of 0.008 /m (the layer thins over about 125 m) and a tint of (0.85, 0.97, 1.12) that pulls the warm horizon color the fog otherwise inherits back to the gray-white of water droplets (see Atmosphere for the fog itself).

Live weather (off by default) replaces the preset with a custom target via setCustom. metarWeather turns the nearest station's METAR into a WeatherState: coverage is the largest layer's cover (FEW 0.25, SCT 0.5, BKN 0.78, OVC 1.05, raised to 1.0–1.2 in precipitation and 1.35 in a thunderstorm); the base is the ceiling (lowest BKN/OVC layer) or else the lowest layer; fog extinction is min(0.015, 3 / visibility) below 9 km visibility, inverting the usual visual-range rule V ≈ 3/σ; rain is 1 for TS with precipitation, 0.8 heavy, 0.25 light, 0.45 otherwise; and snow, ice pellets or snow grains with no rain in the report become a snow rate of min(1, 1.4 · rain). The nearest named type is kept for the label and for whether lightning may strike. The sky's cloud layers do not come from this collapsed state: each reported layer keeps its own height and an inferred type (see Cloud types and the weather's sky).

Gating

How much rain reaches the camera

explorer/main.ts (the "Rain strength at the camera" block) · explorer/lib/weather/weather_radar.ts

The weather says how hard it rains somewhere. What the particle field, the windshield, the water rings and the wet aircraft need is how hard it rains at the camera, a number called rainAmount. It is a product of three factors: where the camera is relative to the cloud deck, whether the camera is under a rain cell, and the weather's rate.

Below, in, and above the deck

Rain falls out of the bottom of the cloud. The camera's height above the cloud layer's reference level (cloudLayerElev: the lay of the land over tens of kilometers, not the ground directly below, so the deck does not bob between ridge and valley) is compared with the deck's base and top:

Rain under the deck
below = 1 − smoothstep(hbase, hbase + 0.35 · max(1, htop − hbase), h)
  • hcamera altitude above cloudLayerElev (m)
  • belowweatherBelowCloud: forced to 0 off Earth and on the ISS ride
1 0 base base + 0.35·depth top full rain thinning in cloud cloud: no rain above: 0 camera height above cloudLayerElev →
The rain factor through a heavy-rain deck (base 800 m, top 4,000 m: the fade ends at 1,920 m). Inside the lower third of the cloud the drops thin out; from there up, including the whole of space, the particle field is switched off and costs nothing.

The same factor gates the snow, the lightning's light on the ground, the thunder and the faint flash overlay, which is how "rain, the flash and the thunder all stop once the camera climbs above the cloud layer" falls out of one number rather than four special cases.

Radar cells: rain that comes and goes

A uniform rain everywhere under the deck reads as a weather setting rather than weather. Instead each rainy type has a RadarClimate: the share of grid squares that hold a cell, the cell radius range, the peak level range (radar color levels: 1 green, 2 yellow, 3 red, 4 magenta) and a background level between cells.

TypeShareRadius (m)Peak levelBackground
light_rain0.353,000–7,0001–1.80.8
heavy_rain0.74,000–9,0001.8–31
thunderstorm0.452,500–6,0003–40.8
showers0.41,500–4,0001.2–2.40
snow0.65,000–10,0001.4–21

radarCells lays a grid of 15 km squares in latitude and longitude. Each square is hashed from its integer indices: one hash decides whether it holds a cell, two more place the cell in the middle 70% of the square, and two more pick its radius and level. The grid lives in a frame that drifts with the mean wind, so the pattern is identical for every player in a room and moves across the map during the day. The drift time is radarTime, seconds since that day's UTC midnight, not seconds since 1970: multiplied by a wind speed, the latter would be 105 km of drift, and the cells would jump by kilometers whenever a gust changed the wind. The level at a point is a parabolic core:

Reflectivity at a point
level = max(background, maxcells L · max(0, 1 − d2 / 1.96)),   d = distance / radius
  • Lthe cell's peak level; the core reaches zero at 1.4 radii

Every two seconds the host re-queries the cells within 25 km of the camera, and every frame converts the level at the camera into a share of the weather's rain: want = min(1.5, level / 2). Half the radar level means the background between a heavy-rain deck's cells is half the weather's rate, and a magenta core is one and a half times it. That share, cellRain, is eased with a four-second time constant, cellRain += (want − cellRain) · min(1, dt / 4), so flying into a cell feels like rain building rather than a switch.

1.5 1 0.5 0 level 2.4, r 4 km level 3, r 3 km background 1 (heavy rain) background 0 (showers) distance along a 24 km line →
cellRain (before easing) along a line through two cells. The solid curve has a heavy-rain background of level 1; the dashed one has none, which is how showers are dry between their cells. The same cells (the 16 nearest) feed the rain shafts drawn under the clouds and the cockpit weather radar, so the dark curtain you see, the return on the radar and the rain on the windshield coincide.

The rain at the camera is then simply:

explorer/main.tsTypeScript
// Rain rate, 0..1: the RAIN settings (which a weather type keeps rewriting), as much of
// it as falls here.
const rainRate = effects.rain ? Math.min(1, Math.max(0, effects.rainAmount * cellRain)) : 0;
rainAmount = weatherBelowCloud * rainRate;
const raining = weatherBelowCloud * rainRate > 0.01;
seaWaterFeature.rain = rainAmount;          // rings on the water
if (rainFeature.enabled !== raining) {
  rainFeature.enabled = raining;
}

One subtlety: a weather that has no cells of its own (overcast, say) may follow one that did. While the previous weather's rain eases out over 22 seconds, rainCellsType keeps using the previous type's cells; otherwise rain that had been confined to shower cells would briefly start everywhere as it faded.

Cells from the weather map

With the live weather the regional weather map (see the clouds deep dive) decides the cells: mapRadarCells keeps, of the light rain's, the heavy rain's and the storm's cells, in each square the one whose kind the map's rain at the cell calls for: a light rain's from 0.1, a heavy rain's from 0.45, a storm's from 0.9 when the map has thunder, none where it is dry. The cells keep the radar's hashed places and their drift, so every player gets the same ones. A painted map places its own: each peak of its rain (a texel at least its eight neighbors) is a cell as wide as the rain stays above half the peak (1.5 to 9 km), its level by the same thresholds (light 1 to 1.8, heavy 1.8 to 3, a storm 3 to 4). The rain shafts, the radar, the towers (cells of level 2.5 and up) and the rain at the camera all read these cells.

Simulation

A particle field that follows the camera

src/geo/geo_rain.ts · src/renderer/render_graph/passes/particle_pass.ts · src/particles/particle_builder.ts · explorer/main.ts

Rain, snow and drifting snow are all instances of the engine's general GPU particle system, ParticlePass: a compute chain (spawn → update → compact → write indirect args) followed by an indirect billboard draw. A particle effect is a declarative ParticleGraphConfig (emitter, modifier list, renderer, optional sub-emitters), and the builder compiles the modifiers into a WGSL update kernel. Rain is not special-cased anywhere in the engine; everything weather-specific lives in two config builders and one feature class, GeoRainFeature.

The rain config

src/geo/geo_rain.ts · makeGeoRainConfig (trimmed)TypeScript
emitter: {
  maxParticles: 200000, spawnRate: 15000, lifetime: [2.6, 3.6],
  shape: { kind: 'box', halfExtents: [34, 0.1, 34] },
  initialSpeed: [0, 0], initialColor: [0.75, 0.88, 1.0, 0.55],
  initialSize: [0.012, 0.020],
},
modifiers: [
  { type: 'gravity', strength: 20.0 },
  { type: 'drag', coefficient: 0.04 },
  { type: 'alpha_over_lifetime', start: 0.55, end: 0.0 },
  // Kill drops on terrain contact; the on_death split spawns the splash burst.
  { type: 'block_collision', bounce: 0, friction: 0, kill: true },
  { type: 'sphere_collision', center: [0, 0, 0], radius: 0, space: 'world',
    bounce: 0, friction: 0, kill: true, dynamic: true },
],
renderer: {
  type: 'sprites', blendMode: 'additive', billboard: 'velocity',
  shape: 'line', stretch: 1.0, thickness: 0.55, emit: 2.5, renderTarget: 'hdr',
},

The drops are born at rest in a thin 68 × 68 m slab and accelerate under a gravity of 20 m/s² against a linear drag of 0.04 /s (the modifiers compile to v.y −= 20·dt and v −= v·0.04·dt). Integrated, a drop falls the slab's 20 m to camera height in about 1.4 s and arrives at roughly 27 m/s. That is about three times the terminal speed of a real raindrop, and it is deliberate in effect if not in physics: at that speed the velocity-stretched streak (next section) is long enough to read as rain at a glance. The lifetime of 2.6 to 3.6 s lets a drop fall roughly 70 to 130 m before it dies of age, so near the ground every drop ends on the terrain, and from higher up the field simply reads as falling rain around you.

Why the field lives in the camera's frame

GeoRainFeature has two spatial modes. The default, used by the slow follow-camera samples, is world space: the emitter box is moved to 20 m above the camera each frame and the drops simulate in world coordinates. Explorer's camera defeats that in two ways. A fast camera outruns the drops it has already spawned (they do not inherit its velocity), and the floating origin's periodic re-anchoring strands the whole in-flight field at the old origin. The result would be rain that stops while moving, then dumps when you stop. At 60 m/s the camera is 85 m away before a drop born above it has fallen to its height; and when the aircraft stops, all the drops spawned in the last few seconds arrive at once.

Camera-relative mode avoids both by never letting the drops know where the camera is. The emitter sits at a fixed local position (0, 20, 0); the drops simulate in that local frame; and a render-time model matrix, a pure translation to the camera, is applied in the vertex shader:

src/geo/geo_rain.ts · GeoRainFeature.updateTypeScript
if (rel) {
  // Local sim centered on the camera; the box sits 20 m above the local origin
  // and the model matrix (below) translates the whole field to the camera each
  // frame, so it rigidly follows the viewer.
  this._emitter.data[12] = 0;
  this._emitter.data[13] = 20;
  this._emitter.data[14] = 0;
  this._model.data[12] = cam.x;
  this._model.data[13] = cam.y;
  this._model.data[14] = cam.z;
  this.pass!.setModelMatrix(this._model);
}

The trade-off is visible in the demo below: in the camera's frame a drop falls straight down no matter how fast the camera moves, so the streaks do not slant toward the viewer at speed. A world-space field gets that slant for free but cannot keep up with an aircraft. For a free-flying camera, rain that is always there is the better trade.

Interactive · world-space vs camera-relative rain
drops within 10 m of the camera: 0drops alive: 0
A side view, 160 m wide, of the ±34 m spawn slab (dashed) 20 m above the camera. In world space, set the speed to 50 m/s and the camera leaves its rain behind; drag it to 0 and the backlog arrives all at once. Camera-relative, the column of rain is always overhead, and the streaks, drawn along each drop's velocity as the camera sees it, stay vertical.

Colliding with terrain that is not on the GPU

The particle system's block_collision modifier is shared with the voxel game, where a heightmap of the world is already on the GPU. Streamed geo terrain has no such thing: the ground is whatever mix of quantized-mesh tiles, photogrammetry and buildings is currently loaded. So the feature bakes one on the CPU every frame: a 24 × 24 grid over ±36 m about the camera (cells of about 3.1 m), filled by calling a host-supplied groundY(x, z). In Explorer that closure converts the world point to ECEF, then to geodetic longitude and latitude, asks the streamed terrain for its height there, and converts back to a world Y. Cells with no ground get a sentinel of −109. In camera-relative mode the heights are stored relative to the camera's Y and the grid is centered on the local origin, matching the simulation's frame.

spawn slab: ±34 m × ±34 m × 0.1 m, local (0, 20, 0) collision grid: 24 samples over ±36 m (≈3.1 m cells), baked on the CPU each frame groundY(x, z): world → ECEF → lon/lat → terrain.heightAt → world Y (relative to camera Y) camera cabin sphere: drops die + splash splash ×8 20 m
The camera-relative rain field. Everything shown moves with the camera; only the heights in the grid change from frame to frame. The 24² resolution is the cost knob: 576 terrain queries per frame per active field, each with two geodetic conversions, which on dense city photogrammetry is the expensive part (the code comment calls out "heavier on dense city photo tiles than on smooth terrain").

The collision test in the compiled update kernel is a nearest-cell lookup, not a bilinear one; at a 3 m cell size, on a field of drops a centimeter wide, the error is invisible:

src/particles/particle_builder.ts · block_collision (generated WGSL)WGSL
let _bc_uv = (p.position.xz - vec2<f32>(hm.origin_x, hm.origin_z)) / (hm.extent * 2.0) + 0.5;
if (all(_bc_uv >= vec2<f32>(0.0)) && all(_bc_uv <= vec2<f32>(1.0))) {
  let _bc_xi = clamp(u32(_bc_uv.x * f32(hm.resolution)), 0u, hm.resolution - 1u);
  let _bc_zi = clamp(u32(_bc_uv.y * f32(hm.resolution)), 0u, hm.resolution - 1u);
  let _bc_h = hm_data[_bc_zi * hm.resolution + _bc_xi];
  if (p.position.y <= _bc_h) {
    // kill: run on_death events + splits, then life = -1
  }
}

The heightmap is a storage buffer of f32 plus a 16-byte uniform (origin, extent, resolution), bound as its own bind group only when the config contains block_collision. That matters because the update kernel is already close to WebGPU's four-bind-group limit: the builder refuses outright a config that combines a heightmap, an SDF and sub-emitter splits.

Splashes, and why they are small

A drop killed by a collider runs the same on_death path as one that ages out, which fires the config's split: eight child particles, inheriting −0.22 of the parent's velocity (so they kick up and back) and its color. The children are a second ParticlePass fed through a GPU queue of 8,192 entries: soft alpha-blended camera-facing sprites, launched at 1.4–3.2 m/s into a cone, pulled down at 14 m/s², gone in 0.35–0.55 s. Explorer builds the config with splashScale: 0.4, shrinking the children from 8–16 cm to 3.2–6.4 cm. The reason is the cockpit. Because the drops fall straight down in the camera's frame and know nothing of the aircraft, they would fall through the roof into the cabin. So a sphere collider is placed every frame at the aircraft's cabin center with its cabin radius (the config's dynamic sphere_collision, pushed through setSphereCollider): an umbrella that keeps a dry column under it. But a sphere around the cockpit means the splashes burst right on the windshield, where full-size ones read as big white blobs.

Snow and drifting snow

Snow is the same feature with a different config, makeGeoSnowConfig, registered as a second instance named GeoSnowFeature (feature names must be unique per engine). Gravity of 2.8 m/s² against a drag of 2.5 /s gives a terminal speed of 2.8 / 2.5 ≈ 1.1 m/s, close to real snowflakes. A turbulence modifier (two octaves of a 3D value-noise vector field, scale 0.35, strength 2.2) supplies the flutter. Lifetimes of 18–26 s let a flake fall the slab's 20 m and more; there is no splash. The host sets a sphere collider of radius 3 m at the camera: "flakes that would pass within a few meters of the eye are taken out: that close, a flake is a blurred disk across a tenth of the view."

Drifting snow (GroundDriftFeature) is a third configuration of the same pass: 26,000 flakes/s at full strength from a ±32 m slab only 0.9 m deep, set 0.6 m above the ground under the camera and 12 m upwind, blown along local +X by a wind modifier of strength 9 with 0.8 turbulence, with almost no gravity so they skim rather than fall. Its model matrix is a rotation that turns local +X into the wind's direction followed by the translation to the camera, so one config serves every wind direction. It runs only when lying snow exceeds 0.2, the wind exceeds 6 m/s, and the camera is within about 60 m of the ground:

Drift amount
drift = smoothstep(0.2, 0.6, lying) · smoothstep(6, 14, w) · (1 − smoothstep(25, 60, hAGL))

Paying only when it rains

All three features are created lazily. Until the first frame they are enabled, they hold no ParticlePass at all, because, in the code's words, "its buffers are tens of MB for a heavy rain" and most flights never see rain. Creation is asynchronous (pipelines are built with the async pipeline API) and the feature draws nothing until it resolves; if creation fails (out of GPU memory, a pipeline that would not build), it retries after 30 s rather than every frame. The spawn rates scale with the weather:

explorer/main.tsTypeScript
// (A phone: half the flakes and drops, the particles' cost halved; still a thick fall.)
const PHONE_PARTICLES = defaultTileMemoryMB().mobile ? 0.5 : 1;
const SNOW_SPAWN_RATE = 4000 * PHONE_PARTICLES;  // flakes / s at the snow config's own rate (snow 0.7)
const RAIN_SPAWN_RATE = 15000 * PHONE_PARTICLES; // drops / s at full strength
// …
// 0.45 is the default rain amount (15k drops/s); a downpour is ~33k.
rainFeature.setSpawnRate(RAIN_SPAWN_RATE * weatherBelowCloud * rainRate / 0.45);
snowFeature.setSpawnRate(SNOW_SPAWN_RATE * snowAmount / 0.7);

The rates are normalized to the amount each config was tuned at (rain 0.45, snow 0.7), so the default rain is exactly the config's 15,000 drops/s. At an average lifetime of 3.1 s a downpour keeps roughly 100,000 drops alive, half of the 200,000-particle pool. Below 0.01 the feature is disabled outright, and a disabled feature adds no passes to the render graph.

Rendering

Drawing drops and flakes

src/shaders/particles/particle_render_forward.wgsl · src/geo/geo_rain.ts · explorer/main.ts

A drop is drawn as a quad aligned with its velocity and turned to face the camera about that axis, the classic velocity-aligned billboard. Its length grows with speed; its width is a separate knob:

src/shaders/particles/particle_render_forward.wgsl · vs_mainWGSL
let center  = (params.model * vec4<f32>(p.position, 1.0)).xyz;
let vel     = (params.model * vec4<f32>(p.velocity, 0.0)).xyz;
let spd     = length(vel);
let vel_dir = select(vec3<f32>(0.0, 1.0, 0.0), vel / max(spd, 0.001), spd > 0.001);
let cam_dir = normalize(camera.position - center);
let right   = normalize(cross(vel_dir, cam_dir));
// Config-driven stretch: larger values turn dots into long streaks.
let stretch = 1.0 + spd * params.stretch;
let world_pos = center
  + right   * ofs.x * p.size * thickness
  + vel_dir * ofs.y * p.size * stretch;

The model matrix is the camera-relative translation from the previous section, applied to position as a point and to velocity as a direction. With stretch = 1 and a drop size of 1.2–2 cm, a drop at 27 m/s is a streak about 0.3–0.6 m long and, at thickness 0.55, under a centimeter wide: thinner than a pixel beyond ten meters or so at a typical field of view, which is why the field depends on the temporal antialiasing that runs after it to resolve into continuous, faint lines. The fragment shader for the line shape is minimal:

src/shaders/particles/particle_render_forward.wgsl · fs_lineWGSL
let dy = (in.uv.y - 0.5) * 2.0;     // -1..1 along the length
// Round caps: taper alpha to zero at uv.y endpoints.
let cap = 1.0 - dy * dy;
if (cap <= 0.0) { discard; }
// … the line is a solid bright HDR rectangle (round-capped along its length); the soft
// halo around it is produced entirely by the downstream BloomPass …
let rgb = in.color.rgb * params.emit * cap;
let alpha = in.color.a * cap;
return vec4<f32>(rgb, clamp(alpha, 0.0, 1.0));

The shader's own comment expects bloom to supply a glow, which suits sparks. Rain is the case where that is wrong: Explorer registers the rain after the bloom feature precisely "so the streaks aren't bloomed". Blending is additive into the HDR target, depth-tested (less, reversed when reversed-Z is on) against the G-buffer depth with depth writes off, so terrain, buildings and the aircraft hide the drops behind them and no sorting is needed. Alpha fades from 0.55 to 0 over each drop's life.

Lit how? Not at all, deliberately

The drops are unlit emitters: their brightness is the config's emit, set each frame from the time of day.

explorer/main.tsTypeScript
// Unlit drops: as bright as the day (bright streaks across a night sky read as
// snow); at night the landing lights catch the drops near the aircraft.
const dayR = Math.min(1, realSun.intensity / Math.max(1e-3, sunState.intensity));
rainFeature.setEmit(2.5 * (0.15 + 0.85 * dayR) + 1.8 * landingGlare * (1 - dayR));
// … and for the flakes:
snowFeature.setEmit(0.08 + 1.5 * day + 0.9 * landingGlare * (1 - day));

dayR is the real sun's current intensity over its full-day intensity, so it already folds in elevation and twilight. Rain keeps 15% of its daytime brightness at night, snow almost none (0.08 out of 1.58). landingGlare is the aircraft's landing lights, eased at 3 /s so it follows the lamps coming on with the flaps; it adds back up to 1.8 (rain) or 0.9 (snow) at night only. It is a uniform boost to the whole field rather than a per-drop light calculation, which works because the field only extends 34 m from the camera: in the cockpit or chase view, that is exactly the volume the lights would reach. The snowflakes use a soft camera-facing sprite with a radial falloff (alpha = a · (1 − r²)), alpha-blended.

A light aircraft on a wet runway at night in a storm, lit by a lightning flash, faint rain streaks against the dark sky.
A storm at night. The rain streaks are faint against the night sky (15% of their daytime emission), and the runway and the aircraft are lit by the lightning's point light.

Where the weather passes sit in the frame

The particle fields and the screen-space weather passes all draw into the lit HDR image, in feature registration order (see Anatomy of a frame for the whole graph):

#FeatureReads → writesWhy here
Before: shading that weather changes
—GeometryPasstiles → G-bufferwet ground, snow, season, frost, rime are G-buffer terms (later sections)
—HQ clouds→ HDRrain shafts under cells; lightning's glow inside the cloud
—LensBloomFeatureHDR → HDReverything above blooms; nothing below does
Weather in the lit image
1GeoRainFeaturedepth, HDR → HDRafter bloom so streaks are not haloed
2GeoSnowFeaturedepth, HDR → HDRsame field, snow config
3GroundDriftFeaturedepth, HDR → HDRblowing snow near the ground
4WindshieldRainFeaturepanes, depth, HDR → mask → new HDRlenses the scene including the drops outside
5SmokeVeilFeaturedepth, HDR → new HDRveils by distance, keeping the cockpit clear
6VehicleGlassFeature→ HDRreflections on the glass sit in front of the water on it
After
—Antialiasing (TAA)HDR → HDRresolves the sub-pixel streaks with the scene, then tonemaps with it
Screen space, glass space

Rain on the windshield

explorer/lib/cockpit/windshield_rain.ts · explorer/lib/vehicles/vehicle_glass.ts · explorer/main.ts

From the cockpit, rain is mostly what happens on the glass. WindshieldRainFeature is enabled only in the cockpit view, only while it rains at the camera or there is frost on the glass. It is screen-space in the sense that it is a full-screen pass over the lit image, but the drops are laid out in the coordinates of the glass itself, so they stay put on the pane as the pilot looks around, are smaller on a farther pane, and never land on the instrument panel or the window pillars. There is no wiper; the glass is cleared by the airflow instead.

Step 1: a mask in glass meters

The host hands the feature the same list of panes it gives the glass pass (windshieldPanes, up to 16 GlassItems: a mesh and its model matrix). The mask pass rasterizes them with the same jittered view-projection the scene used, into an rgba16float target the size of the screen, with no depth attachment; occlusion against the scene depth is tested by hand in the fragment shader. Each covered pixel stores where on the pane it is, in meters:

explorer/lib/cockpit/windshield_rain.ts · MASK_WGSL fs_mainWGSL
// Which way the pane faces (the aircraft: x right, y up, z aft) says which two of its
// coordinates run along it …
let n = abs(normalize(cross(dpdx(in.local), dpdy(in.local))));
// Glass standing upright and facing fore and aft is an instrument's cover on the panel
// (a windshield is raked back, a side window faces sideways): no rain or frost on it.
if (n.z > 0.97) {
  discard;
}
var onGlass = in.local.xy;
if (n.x > max(n.y, n.z)) {
  onGlass = vec2<f32>(in.local.z, in.local.y);     // side window: fore-aft and up
} else if (n.y > n.z) {
  onGlass = vec2<f32>(in.local.x, -in.local.z);    // roof pane: across and fore-aft
}
let sceneDepth = textureLoad(depthTex, vec2<i32>(pos.xy), 0);
// … discard if behind the scene (either depth convention) …
return vec4<f32>(onGlass, 0.0, 1.0);

The face normal comes from screen derivatives of the pane's local position, so the classification is per pixel. That matters because instrument cover glasses are often part of the same mesh as the windows; a pane facing straight fore-and-aft (|n.z| > 0.97) can only be one of them, since a windshield is raked back and a side window faces sideways.

pane meshes ≤16 GlassItems scene depth G-buffer WindshieldRainMask rgba16float rg = glass meters, a = 1 lit HDR (with rain) WindshieldRainFeature frost: 8-tap blur, whitened beads ×2 + runners: lens offset → new HDR target pass 1: render panes, test depth by hand pass 2: one full-screen triangle
Two graph passes, added only while the feature is enabled and there is at least one pane. The second writes a fresh HDR texture (every pixel, dry pixels copied through) because it samples the input at offset positions.

Step 2: procedural drops

No textures are involved. The glass coordinates are divided by GLASS_UNIT_M = 1.1 to get the drops' pattern space, and three layers are evaluated, each returning a lens offset and a coverage:

Which way the runners go depends on the airflow. Below 24 m/s airspeed they run down the glass at a fixed rate; above it the pattern's y axis is flipped and they are blown up the windshield, faster with speed (0.8 + min(3, v / 30)).

Step 3: each drop is a lens

A drop shows the scene from elsewhere, flipped across its center. The layers return the offset from the drop's center in glass units; that becomes a displacement on the glass in meters, and the question is how many pixels that is at this point of this pane, seen in perspective. The shader answers it with the mask's own neighbors: the glass coordinates one pixel right and one pixel down give the 2×2 Jacobian J of glass position with respect to screen position, and the screen shift is J−1 applied to the glass offset:

explorer/lib/cockpit/windshield_rain.ts · fs_mainWGSL
let gx = px.xy - pane.xy;                      // glass meters per pixel across
let gy = py.xy - pane.xy;                      // and down the screen
let det = gx.x * gy.y - gx.y * gy.x;
if (abs(det) > 1e-12) {
  let o = vec2<f32>(off.x, -off.y) * 3.0 * GLASS_UNIT_M;   // meters, y up the pane
  shift = vec2<f32>(gy.y * o.x - gy.x * o.y, gx.x * o.y - gx.y * o.x) / det;
  let far = length(shift);
  shift *= min(1.0, 60.0 / max(far, 1e-3));    // (a pane seen edge-on: not across the screen)
}
let lensed = textureSampleLevel(hdrTex, samp, clamp(in.uv - shift / vec2<f32>(dims), …), 0.0);
// Rim light toward the top-left, shade toward the bottom-right, so drops read as raised.
let rim = clamp(dot(normalize(off + vec2<f32>(1e-5)), vec2<f32>(-0.6, -0.8)), -1.0, 1.0);
let lit = lensed.rgb * (1.0 + 0.35 * rim) + vec3<f32>(0.04) * max(rim, 0.0) * (0.2 + lensed.rgb);

The shift is clamped to 60 px, which only matters for a pane seen nearly edge-on, where the Jacobian is close to singular. Running after the particle field means the drops on the glass refract the falling rain and splashes outside; running before VehicleGlassFeature means the glass's own reflections and sun glint are drawn over the water, which is the right order since the water is on the outside of the glass and the reflection is at its surface.

The same pass draws frost on the glass, which is described with the other ice in Seasons, frost, rime and ice.

Surfaces

Wet ground, wet paint, rings on water

explorer/main.ts · src/shaders/modules/ground_detail.wgsl · src/shaders/geometry.wgsl · explorer/lib/airports/runway_surfaces.ts · explorer/lib/aircraft/aircraft_finish.ts · src/geo/sea_level_water.wgsl

Wetness is a state with memory. The ground does not dry the moment the rain stops, and it should stay wet under the cloud while the aircraft is above it. So groundWet is driven by the rain that falls (the rate times cellRain, without the below-cloud factor) and by melting snow, and eased asymmetrically:

explorer/main.tsTypeScript
const rainFalling = activeBody === earthBody && effects.rain
  ? Math.min(1, Math.max(0, effects.rainAmount * cellRain)) : 0;
const melt = snowCover > 0.02 && groundC > 1 ? 0.6 : 0;
const wantWet = Math.max(Math.min(1, rainFalling * 2.5), melt);
const wetRate = wantWet > groundWet ? (1 + wantWet * 2) / 40 : 1 / 1200;
groundWet += (wantWet - groundWet) * Math.min(1, wetRate * dtc);

Wetting is an exponential approach with a time constant of 40 / (1 + 2·want) seconds: about 13 s in a steady rain, so the ground is soaked within a minute. Drying has a fixed 1,200 s (20 minute) time constant. The runways keep their own scalar with the same rates but driven by min(1, 3 · rainAmount) at the camera, and the aircraft's skin has a third:

rain 1 0 groundWet (= runway wetness here) aircraft skin (parked) 01020 30405060 min default rain (0.45) for 10 minutes, then dry; computed from the easing code snow air warms above freezing 1 0 snowCover groundWet from meltwater (0.6) 01020 30405060 min snow 0.7 for 3 minutes below freezing; warm from minute 20
The accumulation scalars over an hour, integrated from the easing code with a 1 s step. Snow cover is linear, not exponential: it rises at snowRate / 60 per second while it snows on ground below 2 °C (white in about 86 s at the Snow weather's 0.7) and falls at 1/900 per second (15 minutes) once the ground is above 1 °C, with the melt wetting the ground as it goes.

Wet photographic ground

Most of the ground in Explorer is photographs: satellite imagery draped on terrain, or photogrammetry tiles. The engine does not know which texel is a field and which is a road. The ground-detail module (shared with the close-range procedural detail; see Lighting) classifies each texel by color alone, with two helpers: gd_canopy (dark and green relative to its luminance) and gd_paving (low chroma, or slightly blue, neither the darkest canopy nor bright). ground_wet runs in the G-buffer pass for draws flagged as ground, and turns those weights into material changes:

src/shaders/modules/ground_detail.wgsl · ground_wet (trimmed)WGSL
let canopy = gd_canopy(albedo);
let paving = gd_paving(albedo);
// Darker: porous ground most, paving less, foliage least.
let darken = mix(mix(0.62, 0.8, paving), 0.85, canopy);
o.albedo = albedo * mix(1.0, darken, w);
let wet_rough = mix(mix(0.62, 0.2, paving), 0.7, canopy);
o.rough = mix(rough, min(rough, wet_rough), w);
// Standing water, past half wet.
let n = gd_octave(uv, 12.0, footprint).x * 0.6 + gd_octave(uv, 4.0, footprint).x * 0.4;
// (Fewer and smaller off the paving: grass and soil soak most of it up.)
let edge = 1.0 - mix(0.12, 0.32, paving) * smoothstep(0.5, 1.0, w);
let pool = smoothstep(edge, edge + 0.05, n) * smoothstep(0.97, 0.995, level) * (1.0 - canopy)
  * smoothstep(0.5, 0.9, w);
o.puddle = pool;
o.albedo = mix(o.albedo, o.albedo * 0.45, pool);
o.rough = mix(o.rough, 0.03, pool);

The physical idea is the usual one for wet porous materials: water fills the pores, less light scatters back out, so the albedo drops (to 62% for bare soil, 80% for paving, 85% for foliage) while the surface's specular film makes it smoother. Puddles appear only past half wet, only on level ground (the face normal, from position derivatives, within about 14° of the local up), and only where an Earth-fixed two-octave noise (12 m and 4 m cells) exceeds a threshold that drops as the ground gets wetter, so puddles grow from their deepest spots. The noise lives on a plane tied to the Earth through an anchor and repeats every 4,096 m, so it neither swims with the camera nor jumps when the floating origin re-anchors, and each octave fades to its mean before it would alias at the pixel's footprint. In the puddle, the geometry pass replaces the normal with the level ground's up and sets roughness to 0.03: a mirror-flat film that the screen-space reflections then pick up.

An airport after rain under a clearing sky: dark, glossy paving and darkened dormant fields.
After the rain. The sky has cleared to a few clouds but the ground is still wet (it dries with a 20-minute time constant): the paving is dark and glossy, the straw-colored winter fields darker than dry.

Runways, roads and the aircraft: a clearcoat film

Surfaces that Explorer draws itself rather than streams have real materials, and are wetted by changing those materials. The runways darken, halve their roughness and gain a clearcoat of up to 0.9 whose roughness falls from 0.3 (damp) to 0.14 (soaked): "a film of water over the asphalt's grain is not a mirror". Roads around a car get the same at clearcoat 0.6, because the runways' near-mirror film would make a whole street a sheet of sky glare. The sharpening coat combines with the lighting pass's stretched specular lobe, which samples the prefiltered environment along the reflection's elevation to produce the long vertical streaks of a wet runway at a grazing angle (see Lighting).

The aircraft's skin uses setAircraftWetness, which keeps each finished material's dry values and derives the wet ones from them:

explorer/lib/aircraft/aircraft_finish.ts · setAircraftWetnessTypeScript
const dark = 1 - 0.18 * w * (1 - d.metallic);
m.albedo = [d.albedo[0] * dark, d.albedo[1] * dark, d.albedo[2] * dark, m.albedo[3]];
m.roughness = d.roughness * (1 - 0.45 * w);
m.clearcoat = d.clearcoat + (1 - d.clearcoat) * w;
m.clearcoatRoughness = d.clearcoat > 0
  ? d.clearcoatRoughness + (0.02 - d.clearcoatRoughness) * w
  : 0.02 + 0.06 * (1 - w);

Matte paint turns glossy, gloss paint mirror-like, and metal does not darken. The host's planeWet targets min(1, 2 · rainAmount), wets at 0.25 /s (seconds), and dries at (1 + speed / 40) / 90 per second: about 90 s parked, a third of that at 80 m/s, because the airflow strips the water. Material updates are only pushed when the value moves by more than 0.01.

Rings on the water

Open water does not get particles' splashes; at thousands of drops per second, a procedural answer is cheaper and better. sea_level_water.wgsl perturbs the water normal with rings from a cell grid in a frame tied to the ripple origin:

src/geo/sea_level_water.wgsl · rain_rings (trimmed)WGSL
for (var oy = -1; oy <= 1; oy++) {
  for (var ox = -1; ox <= 1; ox++) {
    // h1, h2, h3: three hashes of the neighbor cell c
    if (h3 > rain) { continue; }               // more rain: more cells hold a drop
    let center = (c + vec2<f32>(h1, h2)) * cell;
    let life = fract(time * (0.9 + h3 * 0.6) + h1 * 7.0);
    let r = life * 0.8;                          // the ring grows to 0.8 m
    let d = q - center;
    let dl = length(d);
    let band = (dl - r) / 0.06;
    let ring = exp(-band * band) * (1.0 - life) * (1.0 - life);
    slope += d / max(dl, 1e-3) * ring * 0.35 * sin(band * 2.0);
  }
}

Each ring is a Gaussian band 6 cm wide moving outward, modulated by a sine across the band so the surface tilts up then down through it, decaying as (1 − life)². Two layers are summed, the second scaled by 1.7 in space and 1.13 in time so the grids do not line up. The rings are faded out between 25 and 80 m and wherever a pixel's footprint grows past a few centimeters (they would alias), and they add a little of the horizon color as a glint. The share of cells with a drop is rainAmount, the same number that drives the particle field, which is why the rings and the streaks in the hero image agree.

Accumulation

Snow that lies where it really lies

explorer/main.ts · src/shaders/modules/ground_detail.wgsl · explorer/lib/weather/snow_cover.ts · src/renderer/render_graph/passes/geometry_pass.ts · explorer/lib/ground/ground_trees.wgsl

Snow on the ground has two sources: the weather's own (snowCover, built while it snows and melted once the air warms, as charted above) and the satellites' (a map of where snow was actually lying on the sim's date). Both feed the same shader term, which takes whichever shows more at each point. Choosing Snow at the start of a flight sets snowCover = 1 so the snow is already there. The ground temperature that decides building versus melting is the standard atmosphere's at the ground elevation plus the weather's offset: 15 − 0.0065 · elevation + ΔT.

Laying it on photographs

ground_snow again works from the photo's color and the surface's slope:

src/shaders/modules/ground_detail.wgsl · ground_snow (trimmed)WGSL
// The weather's snow, or the snow map's where it shows more.
let s = max(gd.snow.x, gd_snow_map(world_pos));
let level = select(1.0, abs(dot(face / max(fl, 1e-20), up)), fl > 1e-20);
let flat_w = smoothstep(0.6, 0.85, level);
let canopy = gd_canopy(albedo);
let n = gd_octave(uv, 64.0, footprint).x * 0.6 + gd_octave(uv, 16.0, footprint).x * 0.4;
// Thin cover: in patches; full cover: everywhere it can lie.
let patchy = smoothstep(1.0 - s * 1.4, 1.25 - s * 1.4, n);
let amount = flat_w * (1.0 - 0.65 * canopy) * mix(patchy, 1.0, smoothstep(0.6, 1.0, s));
// (Paving, cleared, keeps its color and its markings.)
let lying = amount * (1.0 - 0.75 * gd_paving(albedo));
let snow = vec3<f32>(0.80, 0.82, 0.87) * (0.9 + 0.1 * n);
return vec4<f32>(mix(albedo, snow, lying), lying);

Snow slides off slopes steeper than about 53° (level < 0.6) and lies fully below about 32°; it settles last under dark green canopy, where the trees hold it off the floor; it stays off three quarters of the paving, so runways and roads keep their markings as if plowed. A thin cover appears first in Earth-fixed patches at 64 m and 16 m scales, which become a full cover as s passes 0.6. The snow albedo is (0.80, 0.82, 0.87), varied ±5% by the same noise. Roughness goes to 0.75 where snow lies. The term runs last among the ground terms (season, then wet, then airframe rime, then snow), so snow covers puddles rather than the reverse.

The satellite snow map

SnowCoverBuilder reads NASA's daily MODIS Terra snow-cover product (the gridded NDSI snow index at 500 m) through NASA GIBS, a keyless WMS with CORS, as a 256 × 256 PNG over a ±64 km box about the camera, which is exactly the data's own 500 m resolution. The PNG is a rendered legend, not data, so the builder decodes the color ramp back to the index (ndsiOfColor: the green channel steps by 30 per band of 20 NDSI, blue counts within a band, pure red is 100) and converts it with the standard MODIS fractional-snow-cover fit:

Fractional snow cover
FSC = clamp(1.45 · NDSI − 0.01, 0, 1)
  • NDSInormalized difference snow index, 0..1 (Salomonson & Appel 2004)

A single day's map has holes wherever there was cloud, and the snow algorithm sometimes mistakes thin cloud for snow. So four days are fetched (the sim's date or, if that is in the future or before the record starts on 23 December 2008, the latest day available, which is two days behind), and the most snow any of them shows is kept per pixel, with one filter: a pixel is kept only if two days saw snow there, or one day saw it plainly (NDSI ≥ 50). A single weak reading is more often cloud. Requests are snapped to a 4 km grid so a repeat request hits the cache, and the map is rebuilt in the background when the camera has moved a quarter of the half-span (16 km) or the day changes.

The result goes to the G-buffer pass as an r8unorm texture (setGroundSnowMap). The mapping from world XZ to the map's UV is not exact, since the map is a latitude-longitude rectangle and the world is a local frame on a curved Earth; the host linearizes it every frame about the camera with finite differences 2 km apart and passes an origin plus a 2×2 matrix. The affine approximation is exact at the camera and re-made every frame, and the shader fades the map out over the outer 8 km of the box so its edge is never seen.

The Lake Tahoe basin under snow, forested slopes with snow between the trees, the airport's runway clear and dark.
Lake Tahoe under the day's real snow, under a few-clouds sky: the snow comes from the MODIS map, not the weather. Snow lies in the clearings and on the crowns' upper sides; the runway, classified as paving, stays dark.

Trees and grass

The trees and grass are drawn by Explorer's own ground features, not the photographs, so they take the snow as uniforms: trees get max(snowCover, 0.7 · snowMapHere), where snowMapHere is the map's value at the camera. In the tree shader snow lies on the upper side of each crown, in clumps driven by the impostor atlas's own light-and-shade channel plus a little noise, with the crown's sides and underside left dark:

explorer/lib/ground/ground_trees.wgsl · fs_mainWGSL
let up_n = dot(normalize(in.frame_x * nw3.x + in.frame_y * nw3.y + frame_z * nw3.z), g.up.xyz);
let clump = col.r * 0.7 + n1 * 0.3;
let hold = smoothstep(0.05, 0.6, up_n + far * 0.12)
         * smoothstep(0.75 - 0.6 * snow, 1.05 - 0.6 * snow, clump + 0.3 * snow);
let on = 0.75 * hold * snow * (1.0 - 0.5 * smoothstep(0.4, 0.8, col.b));
albedo = mix(albedo, vec3<f32>(0.78, 0.8, 0.85) * mix(0.8, 1.0, col.r), on);

The far term leans distant woods toward a white top, since from far away a wood is lit and seen as a mass. Grass is simply buried: its density is multiplied by max(0, 1 − 2 · max(snowCover, snowMapHere)), so half a cover removes it entirely.

Cold

Seasons, frost, rime and ice

explorer/lib/weather/season.ts · src/shaders/modules/ground_detail.wgsl · src/shaders/geometry.wgsl · explorer/lib/cockpit/windshield_rain.ts · src/geo/sea_level_water.wgsl · explorer/main.ts

The season at a place and date

Aerial imagery is mostly flown in summer, so a January flight over Vermont would otherwise show green fields and full trees. seasonAt(lat, dayOfYear, height) returns four numbers in 0..1: broadleaf trees in leaf, fall color, grass dormancy and summer dryness. It is a temperate northern calendar, mirrored by half a year in the southern hemisphere and faded out toward the tropics (temperate = smoothstep(22°, 40°, |lat|)), shifted by latitude and height:

Calendar shift (days)
shift = 2.5 · (|lat| − 45°) + max(0, height) / 40 m
  • leaf outsmoothstep(105 + shift, 140 + shift, day)
  • color onsmoothstep(258 − shift, 285 − shift, day)
  • leaf dropsmoothstep(285 − shift, 315 − shift, day)
  • grassgreens up 80–115 + shift, browns off 290–325 − shift

Spring comes 2.5 days later per degree poleward of 45° and a day later per 40 m of height; fall comes earlier by the same amount. Dryness peaks in August in a 28–45° band, where the summer-dry climates lie. The ground's ground_season uses max(dormant, 0.3 · dry) to turn the photo's green fields toward straw (luminance · (1.38, 1.02, 0.6) · 1.1, weighted by how field-like and non-canopy a texel is), and grays photographed canopy a little toward bare. The trees drawn near the camera do the rest per tree: each broadleaf turns gold or red on its own schedule (a per-tree hash makes some turn early, some late), then goes leafless, its crown's alpha cutoff raised so it thins to the denser twigs. Conifers keep their needles.

An airport in Vermont in October, the woods in gold, orange and red among the green.October, Vermont: per-tree fall color
The same airport in January: bare gray woods, straw-colored fields, pale frost on the open ground.January: bare woods, dormant fields, frost

Frost on the ground

Hoar frost forms on clear, calm, cold nights. The host's target is a product of those conditions:

explorer/main.tsTypeScript
const sunSin = -realSun.worldDirection().y;
const clearSky = 1 - smoothstep(0.4, 0.85, cloudSettings.coverage);
const wantFrost = activeBody === earthBody && rainFalling < 0.02
  ? smoothstep(0.5, 0.9, season.dormant) * clearSky * (1 - smoothstep(0.05, 0.4, sunSin)) * (1 - groundWet) : 0;
groundFrost += (wantFrost - groundFrost) * Math.min(1, dtc / 120);

The dormant season stands in for "cold enough"; cloud cover over 0.4 starts to prevent it (cloud keeps the night warm); it burns off as the sun climbs from about 3° to 24°; wet ground does not frost. The time constant is two minutes. In ground_season the frost is a rime, not a cover: on level, open, non-paved ground, in Earth-fixed patches at 32 m and 8 m, the color is pulled 60% toward a pale blue-gray while the photo still reads through it. Where snow lies, the frost is scaled by 1 − snowCover.

Ice on the aircraft

Airframe ice is a simulation quantity (it builds in cloud or rain below freezing, and it changes the flight dynamics); its rendering is a few lines in the G-buffer pass, gated by a per-draw ice amount in model.gain.w and an airflow direction in gd.flow:

src/shaders/geometry.wgsl · fs_mainWGSL
// Rime ice on an airframe: it builds where the air strikes, on the surfaces facing the
// way the aircraft flies (leading edges, the nose, the spinner, struts), white and rough,
// in a crust that is broken up at its edge.
if (model.gain.w > 0.0) {
  let ng = normalize(in.world_norm);
  let face = dot(ng, gd.flow.xyz);
  let grain = fract(sin(dot(floor(in.world_pos * 40.0), vec3<f32>(12.9898, 78.233, 37.719))) * 43758.5453);
  let reach = 0.75 - 0.45 * model.gain.w;
  let rime = smoothstep(reach, reach + 0.25, face + (grain - 0.5) * 0.12) * min(1.0, model.gain.w * 1.6);
  out_albedo = mix(out_albedo, vec3<f32>(0.78, 0.82, 0.86) * (0.92 + 0.12 * grain), rime);
  out_rough = mix(out_rough, 0.85, rime);
}

The rime grows backward from the stagnation line as the ice amount rises: with little ice only normals within about 40° of the flow are covered (face > 0.75); heavy ice reaches surfaces at 70°. The 2.5 cm voxel hash breaks the edge into a crust. The same code draws frost on a parked aircraft by pointing flow straight up: planeFrost eases toward groundFrost · (1 − 0.5 · snowCover) with a 60 s time constant while the aircraft stands still on the ground, and decays with a 20 s constant once it moves (blown off, or wiped before the flight); 70% of it is shown as ice on the upper surfaces whenever it exceeds the in-flight ice.

A light aircraft with white rime on its nose, spinner, wing leading edges and struts.Rime on the surfaces facing the airflow
The cockpit view through a windshield almost entirely frosted over; the instrument panel is clear.Frost on the windshield, not the panel

Frost on the glass

The windshield pass draws frost when min(1, max(1.5 · ice, planeFrost)) is above zero, before the water (frost is under any water on the glass). Coverage grows in from the glass's "cold spots", broad value noise at 2.2 and 5.3 cycles per glass unit, with a ridged-noise feathery edge at 38 and anisotropic needles at 90 × 30 cycles. Inside the frost the view is scattered, so the scene is replaced by an 8-tap ring blur 14 px out, desaturated toward its luminance and tinted slightly blue, at up to 92% opacity:

explorer/lib/cockpit/windshield_rain.ts · frost_coverWGSL
let broad = vnoise(uv * 2.2) * 0.6 + vnoise(uv * 5.3 + 11.0) * 0.4;
let ridge = 1.0 - abs(vnoise(uv * 38.0) * 2.0 - 1.0);
let needles = 1.0 - abs(vnoise(uv * vec2<f32>(90.0, 30.0) + ridge * 3.0) * 2.0 - 1.0);
let grow = broad + 0.25 * ridge - (1.15 - f * 1.3);
return clamp(smoothstep(0.0, 0.18, grow) * (0.75 + 0.25 * needles), 0.0, 1.0);

Lake ice

Lakes and rivers freeze in a deep winter away from the tropics or in a hard frost: max(smoothstep(0.9, 1, dormant) · smoothstep(42°, 52°, |lat|), smoothstep(−2, −8, groundC) · dormant), eased over four minutes. The water shader only freezes water it judges to be a lake (away from sea level, or on a measured lake level well above it) and draws a dark, glossy sheet with a mottled albedo, or white where max(snowCover, snowMapHere) lies on it, lit by the sky and sun like the ground. Where a hull has churned the water recently (the wake map), the ice is open, with broken floes along the lead's edges. The sea never freezes.

Storms

Lightning

explorer/lib/weather/weather.ts · explorer/main.ts · src/shaders/clouds_hq.wgsl · explorer/lib/audio/thunder_audio.ts

There is no bolt geometry. A strike is a 0.7-second brightness curve applied to three lights: a point light on the ground, a glow inside the cloud, and a faint overlay on the view. The weather system fires strikes every 5 to 22 s while both the current and target state are stormy (so lightning stops as soon as a storm starts to clear, not halfway through the transition), at a strength of 0.45–1. The flicker is a piecewise-linear curve: a strike, a dip, a re-strike and fading after-flashes.

1 0 0 .05 .09 .16 .22 .45 0.7 s re-strike after-flash thunder at d / 343 s d ≥ 300 m brightness × strength (0.45–1) → point light, cloud glow, overlay
lightningFlicker(t). The thunder is queued at the moment of the strike for clock + distance / 343, and the queue is cleared when the weather leaves the storm, so a rumble trailing its flash by up to twenty seconds cannot arrive under a sky that has already cleared.

Where the strike is

The distance is not random when it can be helped. A strikeDistance callback asks the radar cells about the camera for the nearest core within 20 km and remembers that cell; the strike's distance is the distance to it (at least 300 m). The ground light is then placed at that cell's latitude and longitude, at the cloud base, so the flash on the ground, the glow in the cloud and the delay of the thunder all come from the same storm. With no cell nearby it is placed 1,500 m up and 800–2,600 m to a random side.

The light is an ordinary engine PointLight: no shadows, radius 9,000 m, a cold color of (0.82, 0.88, 1.0), intensity LIGHTNING_CD · flash with LIGHTNING_CD = 2.5e7; a value as large as 6e8 whites out the scene. It lights only while the camera is under the deck (the flash is multiplied by weatherBelowCloud).

The cloud's flash is separate and is seen from above the deck as well. The host passes a world position 900 m above the ground light and a strength of CLOUD_FLASH_GAIN · flash (gain 40) to the cloud renderer, which adds it to the ambient term of every cloud sample:

src/shaders/clouds_hq.wgsl · flash_glowWGSL
const FLASH_COLOR = vec3<f32>(0.82, 0.88, 1.0);
fn flash_glow(p: vec3<f32>) -> vec3<f32> {
  if (cloud.flash.w <= 0.0) {
    return vec3<f32>(0.0);
  }
  let d = length(p - cloud.flash.xyz);
  let near = 1.0 / (1.0 + (d / 450.0) * (d / 450.0));
  let reach = 1.0 - smoothstep(2500.0, 5000.0, d);
  return FLASH_COLOR * (cloud.flash.w * near * reach / max(cloud.ambientDimmer, 1e-3));
}

An inverse-square-like core with a 450 m knee, cut off between 2.5 and 5 km. Adding it to the ambient rather than computing a light-march toward the channel means the cloud glows "from within" at no extra cost per sample: the cloud's own extinction along the view ray already does the work of hiding glow that is deep inside. Finally, a DOM element with a top-to-bottom gradient is faded to flash · 0.07 opacity over the canvas, since a flat white sheet against a night scene reads as the renderer strobing rather than as lightning. The synthesized thunder is filtered noise whose brightness and length depend on the distance (the crack's highs are gone beyond about 7 km), muffled by a 450 Hz low-pass in the cockpit.

Visibility

Fog, smoke and the grade

explorer/lib/fire/smoke_veil.ts · explorer/main.ts (updateSmokeFog, sceneGrade)

Weather fog is the lighting pass's analytic height fog (see Atmosphere); the weather only sets its density, base, falloff and tint. Wildfire smoke needs one more thing, because in the cockpit a fog applied to every pixel would also fog the instrument panel. SmokeVeilFeature reconstructs each pixel's view distance from the depth buffer and the inverse projection, and veils by distance beyond a clear radius:

Smoke veil
k = opacity · (1 − exp(−max(d − dclear, 0) / reach)),   c = mix(cscene, csmoke, k)
  • d_clear3 m: the cockpit stays clear
  • reach30 m / smoke thickness: about 30 m in the thickest smoke
  • opacitymin(0.98, 2.2 · thickness); sky pixels get the full veil

The smoke color is lit as the fire's smoke puffs are: a small ambient term plus the sun's color and intensity scaled by daylight, so it goes nearly black at night. It sits after the windshield rain and before the glass, in the HDR image, so it is resolved and tonemapped with everything else.

Last, weather changes the color grade. sceneGrade(low, overcast, rain, night) builds the tonemap pass's grade from the light of the moment: overcast lowers contrast by up to 0.16, saturation by 0.22 and temperature by 9; rain at the camera takes another 0.1 of saturation. And under thick cover the sun's direct light is dimmed by up to 75% (eased), with the auto exposure compensated by up to −0.9 EV so the eye does not simply open up and undo it: "an overcast day is darker to look at, not only flatter." The grade itself is covered in Motion, antialiasing and the lens.

Design note

A recurring pattern on this page is that nothing is spatially simulated that does not need to be. Wetness, snow cover, frost and ice are each a single scalar for the whole scene, eased with a physically motivated time constant; the spatial variation comes from shaders that read the photo's color, the surface's slope and Earth-fixed noise. Only the satellite snow map is spatial data, and only the rain cells make rain vary across the map. That is what lets the whole weather system run on a phone with the particle counts halved.

Further reading

References

  1. K. Garg and S. K. Nayar, “Photorealistic Rendering of Rain Streaks”, ACM SIGGRAPH 2006. Why rain is seen as streaks at all: a drop's motion during the exposure. Explorer's streaks are the cheap version: a velocity-stretched quad with no per-streak oscillation model.
  2. N. Tatarchuk, “Artist-Directable Real-Time Rain Rendering in City Environments”, SIGGRAPH 2006 course notes (Advanced Real-Time Rendering in 3D Graphics and Games). The classic catalog of rain's sub-effects: falling rain, splashes, wet surfaces, puddles, droplets on glass.
  3. P. Rousseau, V. Jolivet and D. Ghazanfarpour, “Realistic Real-Time Rain Rendering”, Computers & Graphics 30(4), 2006. Drops as refracting lenses of the scene, the idea the windshield pass applies to drops on the glass.
  4. S. Lagarde, “Water drop” series (dynamic rain and its effects; wet surfaces), 2012–2013. Wet porous materials: darker albedo, smoother specular, puddles on level ground; the model ground_wet follows.
  5. V. V. Salomonson and I. Appel, “Estimating fractional snow cover from MODIS using the normalized difference snow index”, Remote Sensing of Environment 89(3), 2004. The FSC = 1.45 · NDSI − 0.01 fit used to turn the daily map into a snow fraction.
  6. D. K. Hall and G. A. Riggs, MODIS/Terra Snow Cover Daily L3 Global 500 m Grid (MOD10A1), NASA NSIDC DAAC; served as imagery through NASA GIBS. The snow data source.
  7. WMO Manual on Codes, FM 15 METAR. The report format live weather decodes: cover groups, ceiling, visibility, present-weather codes.