Skip to content

weather: rain, with streaks, shafts, wet ground, rings and fog (O19) - #1315

Merged
transfix merged 22 commits into
masterfrom
feat/weather-rain
Nov 17, 2026
Merged

transfix merged 22 commits into
masterfrom
feat/weather-rain

Conversation

@transfix

Copy link
Copy Markdown
Owner

O19 of docs/roadmap/OCEAN-AND-WEATHER-ROADMAP.md: rain (F3, §10.6). In terrain_lab a storm walks across raining: shafts in the distance, streaks up close, rings on the lakes, wet roads and ground, and fog; then it clears and the ground dries. Stacked on #1312 (O18); this PR's own commits are the ones after its merge commit.

What changed

Model, cvc::world::weather (inc/cvc/world/weather.h, src/cvc/world/weather.cpp)

  • recent(t, window): the cells whose life reached into the window, alive or gone, so the ground dries along the tracks of storms that have passed.
  • rain_radius(r, I): the radius within which a cell's field passes the rain onset.
  • wetness(t, x, y, soak, dry): how wet a point is. Per recent storm, the time its rain lay over the point (along its track) over soak, capped at 1, times exp(-(time since its rain left) / dry). It is the CPU twin of the shader's wet ground, and the friction hook for O20.

Weather node (src/cvcGL/ariadne/weather_node.cpp)

  • It hands cloud_sky two keys:
    • sky.rain: the tracks of up to four recent storms;
    • sky.rain_k: the rain's constants (onset, rain_max, soak 300 s, dry 900 s, and the ring, fog and wet strengths).
  • It publishes weather.rain_here, the rain at the camera.
  • New keys: weather.streaks, .rings, .fog, .wet and .rain_quality, all on the Weather panel. New props: rain_count, rain_quality, soak, dry.
  • Streaks: a port of ABYSSAL's Rain (Precipitation.js:6-265 at 849ff7f4, MIT; notices kept).
    • ABYSSAL's rain is not a ping-pong state texture. It is "entirely in the vertex shader": each quad of a fixed mesh is a drop, placed and moved as a closed form of time in a box that follows the camera. So is this port. There is no state, no texture and no CPU work, and it runs the same in WebGL2 and single-threaded wasm.
    • The slant comes from steeringWind(), the one scene-wind accessor that O14 repoints.
    • Density is ∝ R at the camera, capped at rain_count (12000) × rain_quality. There are no drops above the cloud base.
    • Streaks are lit by the deck's transmittance (cloudShade()) and fogged.
    • The mesh draws in the volume layer after the clouds: cloud_sky keeps receivers that draw with the volumes after its near volumes.

cloud_sky (src/cvcGL/ariadne/lsystem_nodes.cpp): everything here is uniforms; no sampler is added to any receiver.

  • Rain shafts are drawn in the existing far shells, with no new volume. While a storm rains, the shells' box reaches down to the lowest ground, and each slab's stretch below the cloud base holds a grey veil as thick as the rain, thinning near the ground.
  • Wet ground in the receivers (ground, buildings, roads, props, foliage). cloudWet() is weather::wetness per fragment. Wet surfaces go darker, with a grazing-angle sheen and the sun's glint. The normal comes from the fragment's derivatives, so it does not depend on the mapper.
  • Fog: sky.fog (a haze of the scene's own, default 0) plus the rain at the camera (0.001/m at 25 mm/h). Its colour moves from a fair grey toward a storm grey with the deck's darkness. It reaches the receivers, the water, the streaks and the far clouds. The scene's gradient background goes toward it and comes back when the rain stops.
  • Rings (cloudRainNormal()): hashed 1 m cells, procedural.

Water (src/cvcGL/ariadne/water_node.cpp, kept small): water_light(shaded) gets three string swaps. They add the rings in the normal, the storm's ambient drop (O18's leftover) and the fog. Each swap is skipped if the line it follows has moved.

Also in this branch

How it was checked (Windows 11, MSVC Release)

  • WorldWeather (11):
    • RecentCellsOutliveTheirRain;
    • TheGroundWetsAndDries: under a storm crossing at 4 m/s, wetness climbs while the rain lies on the point, is 0.5 at half the soak, and is soaked when the rain leaves. After that it falls by 1/e every dry, and it is 0 beside the track.
  • cvcgl_ariadne_realize, all checks:
    • the rain's keys are seeded;
    • the sky has sky.rain and sky.rain_k;
    • the receivers carry the track as uniforms and still have only the shade's two samplers;
    • a gone storm's track stays while the ground dries.
  • The 16-unit section (low-memory mapper forced, VTK's table capped at 16) now runs an overhead storm with the camera in the rain. The streaks draw, with the low-memory mapper. The water carries the rain's fog as a uniform and keeps its 2 sky samplers. No draw runs out of units (0 warnings).
  • Also passing: the existing WorldCloudLayer, World*, AriadneLoader and AriadneComponents suites.
  • Offscreen frames looked at (terrain_lab, 1280×720, camera set with --set viewers.main.camera.orbit.*):
    • a storm overhead from a low camera: fog, streaks, a dark wet ground, a grey sky;
    • the city lake close up: raindrop rings and streaks;
    • a storm upwind: a rain shaft under its deck;
    • the city just after a storm (ground and roads darker) and 1800 s later (back to almost the clear frame).
  • The browser texture budget, natively on the full terrain_lab: with CVCGL_LOWMEM_MAPPER=force CVCGL_TEXTURE_UNITS=16, a 120-frame arigl snapshot of terrain_lab with a storm overhead and the camera in the rain. It logged 0 "no texture unit left" warnings, and the frame shows the fog, the streaks and the wet ground.

Frame cost. arigl snapshots of terrain_lab at 1280×720 from a low camera over the city, so the streaks draw. The per-frame time is (720-frame run − 120-frame run) / 600. Three interleaved runs, medians. Three other agents' builds were running, so the numbers are noisy.

run 1 run 2 run 3 median
clear sky 79 92 74 79 ms
storm overhead, the rain's effects off (weather.streaks/rings/fog/wet = 0) 83 83 67 83 ms
storm overhead, raining (streaks, shafts, wet ground, rings, fog) 74 70 116 74 ms

The spread is larger than the differences, so within the noise the rain costs nothing measurable: medians 79 / 83 / 74 ms. By construction the per-frame CPU work is O(cells) (the tracks, ≤ 4). The streaks are one draw of a fixed mesh whose vertex shader drops what it doesn't need. The shafts ride the far shells' existing march. The wet ground, rings and fog are ALU work on uniforms. Not measured: a quiet machine, GPU timer queries, the browser.

Not checked / not done

…ts (O18)

cvc::world::weather is a pure function of its parameters, the world time and
authored events (storm, steer, rate, calm): storms on hashed slots run clear,
building, storm, clearing and clear, born upwind and timed to cross the area in
their prime, riding the steering wind. It publishes the cells, the storm field
and a rain rate for O19 and O20. A weather stream is appended to lsys::stream.
…aps built off the frame

set_storms gives each cell a storm share that feeds it, holds it besides the
fair-weather coverage and deepens its shade and far opacity. set_deck makes the
maps again for new heights; a deck deeper than its cumulus grows cumulonimbus
(ABYSSAL's height profile) whose self-shade marches the sun through the tower.
prepare_deck / run / adopt_deck build it on another thread, and the cumulus the
maps grow from is kept, so a storm deck comes in in about 150 ms. cell_up_tau is
the optical depth straight up, for dark bases.
…rrain_lab

cloud_sky reads sky.base, sky.top, sky.darkness and sky.storms live: a storm deck
is built off the frame and swapped into the same near volumes and far shells, the
ramp darkens toward a storm's, a darkened cloud's light dims as the cloud above
hides the sky, and the storms reach the far shells and the receivers as uniforms
(no new sampler). The weather node owns the model over its ground, drives the sky
and publishes weather.*; its steering wind is the sky's until O14's scene wind.
weather_controls.ari, terrain_lab's weather node, docs and the roadmap's as built.
… there are no threads

std::async cannot start a thread in single-threaded wasm (the Pages gallery,
arigl-web), so a storm coming into reach would have aborted the page. The deck's
build is now a cvc::sliced_job on the app's scheduler, as generated_world's
rebuilds are (#984): on the background pool natively, a few milliseconds a frame
on the scheduler thread where there are no threads. cloud_layer::step builds a
deck a unit at a time (a variant's map, one layer of its self-shade, one row of
its shade), bit-identical to building it at once. deck_threading: cooperative
forces the sliced path natively; cvcgl_ariadne_realize runs the storm both ways.
…er's arrays

The redeployed terrain_lab still ran out in every water draw: headless
Chrome logged 2,318 out-of-units warnings in 75 s once the water came
up. VTK sizes its texture-unit table from GL_MAX_TEXTURE_IMAGE_UNITS,
which is 32 on a desktop GL but 16 in WebGL2. bindShaderTextures first
reserved a fixed 8 units for the low-memory mapper's emulated vertex
arrays, which left a draw 8 for its own textures, and the water binds
10 (three cascades, three coast grids, the wake, the bed, two
cloud-shade textures).

- LowMemoryPolyDataMapper::arrayTextureUnits(): the arrays the draw
  under way takes, vtkDrawTexturedElements::Arrays (bound in
  RenderPieceStart, before UpdateShaderEvent fires). bindShaderTextures
  reserves that many when the drawing mapper (the event's caller, or
  the node's own) is one of ours, else 8 as before.
- A texture that still finds no unit is left unbound, so it no longer
  sets a -1 sampler, which was a second GL error every draw. cvcGL
  names the node and texture once.
- ViewportManager::limitTextureUnits(n) and $CVCGL_TEXTURE_UNITS cap
  VTK's table, put back at the start of each render after a GL state
  reset. With CVCGL_LOWMEM_MAPPER=force, a native run draws within the
  browser's budget. Native terrain_lab that way logged 1,440 warnings
  with the fixed reserve ("far" and "near" out of units for uWake: 16
  in all, 8 kept, 10 shader textures), and 0 with this change.
- cvcgl_ariadne_realize: the water (with a swell, so the swash and coast
  grids are on), cloud_sky's shade and a shadow-casting sun, drawn with
  the low-memory mapper at 16 units, log no out-of-units warning. The
  count is checked to hear VTK's warning.
- ARIADNE.md: the browser's texture units, natively.
- The comment #1304 added said WebGL2 gives VTK 32 units; it gives 16.
…s wetness (O19)

weather::recent gives the cells whose life reached into a window, alive or gone;
rain_radius is where a cell's field passes the rain onset; wetness is how long a
recent storm's rain lay over a point over a soak time, times its drying since,
the CPU twin of the wet ground the sky draws and the friction O20 will read.
… and fog (O19)

The weather node hands cloud_sky the recent storms' tracks and the rain's
constants (sky.rain, sky.rain_k) and draws the streaks near the camera: a port of
ABYSSAL's Rain, drops placed and moved in the vertex shader as a closed form of
time, slanted by the scene wind's one accessor. cloud_sky draws rain shafts below
the cloud base in its far shells, wets and darkens its receivers along the tracks
and dries them after, puts procedural raindrop rings into the water's normal, and
thickens a distance fog with the rain at the camera, all as uniforms: no sampler
joins the ground, the buildings, the roads, the trees or the water. terrain_lab's
sky lists the streaks; the Weather panel has the rain's keys.
… off the terrain

cloud_sky looked its receivers up among the scene's top-level names, so the
weather's streak mesh (weather_rain, a child of the weather's node) was never
wired: it drew without the deck's shade and fog, and in the volume layer
before the clouds instead of after them. A receiver is now found anywhere in
the scene. The streaks' ground under a camera off the terrain is the height at
the terrain's edge, not NaN. cvcgl_ariadne_realize checks that the sky wired
the streaks.
Conflicts:
- THIRD_PARTY_NOTICES.md: both sides extended the ABYSSAL paragraph after
  OceanFFT.js. Kept master's gusts and currents sentence, then the storm
  deck's and the weather model's. The summary line now names the wind's
  gusts and currents (wind_field.h, current.h) beside the storm maps.
- src/cvc/tests/CMakeLists.txt: both test loops list world_weather_test
  (this branch) and ocean_wind_test (master).
Conflict:
- THIRD_PARTY_NOTICES.md, the ABYSSAL summary line: kept the storms merge's
  wind gusts and currents, and this branch's rain streaks.
water_node.cpp merged cleanly. The water lighting's three O19 swaps still
find their lines in #1311's shader, and vWaterRest is still there.
master fails to build arisrvx's python_engine.cpp: #1302 (bridged users)
added room(), bridge_presence(), bridge_absent(), bridge_post() and
listen_chat() calling server_link() with no argument, written against the
process-wide server link that the P0a cleanup replaced with the module's
own state, server_link(PyObject *self). Each of the five now names its
module argument self and passes it, as the other server ops (lent(),
publish(), ...) already do.

Found in #1324's pycvc-linux / cp312 job (run 43956686020),
which builds the PR merged with master.
…ther-storms

# Conflicts:
#	src/cvcGL/test/cvcgl_ariadne_realize.cpp
 into feat/weather-rain

# Conflicts:
#	docs/ARIADNE.md
#	src/cvcGL/test/cvcgl_ariadne_realize.cpp
The realize suite runs every node type's checks in one process. In a
Linux Debug job (Xvfb, llvmpipe) it took 250.6 s, 50 s under the 300 s a
test without a TIMEOUT gets; on a slower runner (#1309's Debug job, where
PhConvoy and Ewave also ran about 1.3x longer) it timed out on all three
attempts. As cvcgl_ewave, cvcgl_wake and cvcgl_volren_node have, it gets
a budget of its own with headroom, so only a real hang fails it.
Base automatically changed from feat/weather-storms to master November 17, 2026 09:40
Merged on #1312's final head (a6c28ab) as the base, so the squash's copy of #1312 meets this
branch's and only the rain's own changes are applied over master.
@transfix
transfix enabled auto-merge (squash) November 17, 2026 09:55
@transfix
transfix merged commit 8b6e756 into master Nov 17, 2026
29 checks passed
@transfix
transfix deleted the feat/weather-rain branch November 17, 2026 14:20
transfix added a commit that referenced this pull request Nov 17, 2026
…ightning

Merged on #1315's final head (0c16793) as the base, so the squash's copy of #1315 meets this
branch's and only the lightning's own changes are applied over master.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant