Skip to content

water: fetch and lee, gusts, the sea lagging the wind, and currents, in both seas (O13) - #1311

Merged
transfix merged 1 commit into
masterfrom
feat/ocean-wind
Nov 16, 2026
Merged

transfix merged 1 commit into
masterfrom
feat/ocean-wind

Conversation

@transfix

Copy link
Copy Markdown
Owner

O13 of docs/roadmap/OCEAN-AND-WEATHER-ROADMAP.md: fetch and lee (E2), gusts (E3), the sea lagging the wind (E4) and currents (E6, §10.3–10.4), in the drawn sea and the physics sea alike. Exit: the lee goes calm, and a wind change doesn't pop.

What changed, and where

  • One wind, read in one place. inc/cvc/algo/wind_field.h: the scene's gusts as one deterministic function of (x, y, t). It's two scales of integer-hashed value noise carried downwind (120 m gusts at the wind's speed, 37 m cat's paws at 0.8 of it), times ABYSSAL's pulse over time. It lives in cvc::algo so the water, the clouds, the trees and physics can all sample it. inc/cvc/gl/WindGLSL.h is the same function in GLSL, with no texture. inc/cvc/ariadne/scene_wind.h is the one place a node reads its wind; today that's the water node's water.wind_speed, water.wind_dir and water.gustiness. O14 points it at wind.*.
  • Fetch and lee (E2). inc/cvc/ocean/fetch.h. The fetch map is one upwind sweep over the shore grid (O(N²) for any wind), at most 256² and capped by each body's open extent. It's rebuilt only when a keyframe's direction moved, never per frame. Each cascade is scaled by clamp(sqrt(F / F_full), 0, 1), where F_full is the fetch at which that cascade's band is fully grown (see the decisions below).
  • The sea lags the wind (E4). inc/cvc/ocean/sea_lag.h. The sea's wind follows the wind with water.sea_lag (20 s) and steps along it by keyframes. Each keyframe crossfades from the last over water.sea_fade (4 s), and there's at most one keyframe per crossfade. That's the debounce for the h0 and fetch rebuilds.
    • The old and new h0 share their noise, so the linear crossfade is continuous, with no change in phase.
    • The physics sea mixes per mode at its own time (sea_surface's new sea_forcing).
    • The drawn node mixes the same two h0 on the CPU and uploads them only while a crossfade runs. OceanFFT is unchanged.
  • Gusts (E3). The ripple cascade's weight follows the gust factor in both seas. The drawn water also gets cat's paws: a ruffled patch mirrors less sky (darker), and near the camera a fine ripple tilts the normal (faded out from 80 m to 300 m).
  • Currents (E6). inc/cvc/ocean/current.h is the curl of two scales of noise: divergence-free, with water.current m/s as its RMS.
    • The 83 m and 29 m cascades are carried through a two-phase flow map. The blend is variance-preserving, and each phase gets its own random offset per cycle, which breaks up the tiling.
    • sea_surface::velocity carries the current, so a floating body drifts with the drawn small waves.
  • Ariadne. SceneWaterSeaClock (scene_water.h) holds the keyframes that both WaterRuntime (physics, headless too) and the drawn node read. New water.* keys: gustiness, lee, sea_lag, sea_fade and current. They're on water_controls.ari, in docs/ARIADNE.md and in the roadmap's "As built (O13)" notes.
  • cvcGL. src/cvcGL/ocean/OceanWind.{h,cpp} holds the GLSL and per-frame uniforms, shared by water_node.cpp and lsystem_coast.cpp. The gusts and the current are evaluated per vertex (near grid 2 m, far grid coarse), and their fine detail fades with distance.
  • The ported pieces (the gust pulse, the current's shape) keep ABYSSAL's MIT notice in their headers and in THIRD_PARTY_NOTICES.md.

How it was checked (Windows 11, MSVC Release)

  • ocean_wind_test (new, 10 tests):

    • The lee: behind a round island the fetch at 10, 50, 100, 200, 400 and 800 m reads 15, 55, 105, 205, 405 and 805 m. The long cascade's scale is 0.011 there and 0.058 at 400 m (four times as far, twice the waves).
    • A lake is its own fetch. Each band's full-growth fetch at 9 m/s is 120, 22.2 and 4.6 km.
    • The lag: a 20 s lag reaches 15 − 6/e after one tau. Taking 9 to 15 m/s makes 8 keyframes, each at least 4 s apart. A slider jittered every frame for 10 s makes at most 3.
    • No pop: an instant rebuild jumps 0.571 m. Crossfaded, the sea at the change is the old one bit for bit, the first frame moves 0.021 m, and the worst frame in the fade moves 0.037 m, under the waves' own worst frame (0.048 m).
    • Gusts and current: golden hashes for the gusts, the current and the fetch map. The current's divergence is ≤ 2.5e-8 /s against gradients up to 6e-3 /s, and its RMS is the asked speed.
    • Physics sea: 30 m behind an island the RMS is 0.011 m, against 0.476 m without the lee. The velocity is the waves' plus the current, exactly.
  • ariadne_scene_world_test, AWaterNodesLeeIsCalmerThanItsOpenWater (new): a 9 m/s wind past an island.

    • The sea's RMS is 0.014 m 40 m behind the island, 0.715 m upwind, and 0.543 m with lee: 0.
    • A floating 2 m crate heaves 0.009 m RMS in the lee and 0.625 m in the open (Jolt, 17 s).
    • Two wind changes 1 s apart make 2 keyframes and 2 field rebuilds. 2 s into the fade, the new sea's share is 0.50.
  • Existing suites pass unchanged, and no golden hash moved: a sea_surface without a forcing has the same digest and values. That covers OceanSea.IsTheSameOnEveryPlatform, the lattice digest and PhysicsOceanSurface.CrossPlatformGoldenHash.

    • Run: Ocean*, PhysicsField / PhysicsOceanSurface, AriadneSceneWorld, AriadneLoader / AriadneComponents (water_controls.ari loads clean), WorldWaterBodies, cvcgl_ocean_fft, cvcgl_ocean_band, cvcgl_ariadne_realize (which now checks the new keys are seeded).
    • That's 161 + 32 tests.
  • Offscreen frames, looked at:

    • terrain_lab on an island world (preset: island, edge: shore), from the downwind side: the water behind the island is glassy while the open sea beside it keeps its waves. On master the same view is rough everywhere.
    • A close view of the lee: calm, with fine ripples breaking up the glint.
    • terrain_lab's big lake: fetch-limited, calmer, no whitecaps.
    • lsystem_coast: the island's downwind side is calmer, with fewer whitecaps.
  • Frame cost: measured, but the measurement doesn't resolve it. terrain_lab, arigl snapshot at 1280×720; each figure is the 720-frame run's time minus the 120-frame run's, over 600 frames. I ran seven rounds of master's arigl and this branch's, interleaved, with the order alternating. Three other agents were building and testing on the same machine (six compilers, ~66 % CPU), and the numbers swung widely:

    round master (ms/frame) this branch (ms/frame)
    1 57.8 49.0
    2 92.7 149.6
    3 247.0 100.0
    4 144.5 121.7
    5 166.9 179.8
    6 195.7 246.8
    7 142.0 73.4
    median 144.5 121.7

    The per-round difference (branch − master) has a median of −9 ms and a spread of ±100 ms. So the change costs less than this machine could resolve today. The quietest round, 57.8 vs 49.0 ms, matches the roadmap's 54.9 ms on a quiet machine. A clean measurement (with GPU timer queries) is still to do, and so is the browser.

    The design keeps the per-frame cost down:

    • The fetch map is a coarse texture, rebuilt only at a debounced keyframe.
    • The gusts and the current are evaluated per vertex with no texture; their fine detail fades with distance and is off on the far grid.
    • The far grid's height reads skip cascades with no weight.
    • The h0 crossfade runs on the CPU only during a fade.
  • Textures: one new sampler per water stage, uWindFetch (RG32F, at most 256²). The gusts and the current are hashed noise in the shader. Each water stage goes from 8 samplers to 9: uDisp0–uDisp2, the bed, uShoreGrid, uShoreWave, uShoreDir, uWake, and now uWindFetch, plus the cloud deck's shade where wired.

For O14 (one scene wind)

  • The keys O14 drives. scene_wind() in inc/cvc/ariadne/scene_wind.h is the only reader of the water's wind. It reads water.wind_speed, water.wind_dir (degrees, the way it blows, from +x toward +y) and water.gustiness through kWaterWindKeys. O14 points that function at wind.speed, wind.dir and wind.gustiness.
    • cloud_sky's wind_az is a compass azimuth; SceneWind::azimuth() converts.
    • water.fetch, lee, sea_lag, sea_fade and current stay the water's own.
  • The gust field. cvc::algo::wind_gust(wind_state, x, y, t) (or a gust_frame per frame) on the CPU, and cvc_wind_gust(p, fine) from cvc/gl/WindGLSL.h in a shader. cloud_sky's drift, the trees and physics can sample it at the same (x, y, t) the water does.

Not checked

  • The browser (WebGL2): not run. The GLSL uses uint hashing (GLSL ES 3.00 core) and one RG32F texture read with texelFetch.
  • Linux and macOS: the new golden hashes (fetch map, gusts, current) were measured on Windows only. They use det_math and no FMA contraction, like the existing pins.
  • Stream velocities from water_bodies: not built, because there's no flow grid until hydrology (W1). sea_forcing is where they'd join the current.
  • Distant lakes look glassy. The far grid doesn't draw the ripple band, so fetch-limited lakes beyond the near grid read glassy. A roughness term from the ripples' weight would fix it; that's not done here.
  • lsystem_coast's shading has the lee, gusts on the ripples, the current and the crossfade, but not the cat's-paw roughness.

…in both seas (O13)

- cvc::algo::wind_field: the scene's gusts as one deterministic function of (x, y, t): two scales
  of integer-hashed value noise carried downwind and ABYSSAL's pulse over time. cvc/gl/WindGLSL.h
  is the same in GLSL, no texture. Everything the wind moves (O14: the clouds, the trees, the air
  physics) can sample it at the same point and time.
- cvc::ocean: fetch.h (the fetch map in one upwind sweep, coarse, capped by each body's extent; each
  cascade scaled by sqrt(F / F_full), F_full where its band is fully grown), sea_lag.h (the sea's
  wind follows with a time constant and steps by keyframes, at most one per crossfade), current.h
  (a divergence-free curl-noise current and a two-phase flow map). sea_surface takes a
  sea_forcing: the h0 crossfade, the fetch scales, the ripples' gust weight, the current.
- Ariadne: scene_wind.h reads a node's wind in one place (O14 points it at wind.*).
  SceneWaterSeaClock steps the keyframes both seas use. New water keys: gustiness, lee, sea_lag,
  sea_fade, current (water_controls.ari, ARIADNE.md).
- cvcGL: OceanWind (one RG32F texture of the two keyframes' fetch maps; the gusts and the current
  hashed per vertex). The water node and lsystem_coast draw the lee, the gusts (the ripples'
  weight, cat's paws in the shading), the current carrying the two short cascades, and mix the two
  keyframes' h0 on the CPU only while a crossfade runs.
- Tests: ocean_wind_test (fetch behind an island and on a lake, the lag and its debounce, a
  continuous crossfade, golden hashes of the fetch map, the gusts and the current, a
  divergence-free current, the physics sea's lee and current), a floating crate in the lee against
  one in the open (ariadne_scene_world_test), the water node's new keys (cvcgl_ariadne_realize).

No golden hash moved: a sea_surface without a forcing has the same digest and values as before.
@transfix
transfix enabled auto-merge (squash) November 16, 2026 08:26
@transfix
transfix merged commit 3fdd9fd into master Nov 16, 2026
29 checks passed
@transfix
transfix deleted the feat/ocean-wind branch November 16, 2026 18:05
transfix added a commit that referenced this pull request Nov 16, 2026
The water node keeps both: #1311's lagged sea (keyframes, crossfade, fetch
maps), gusts, cat's paws and current, and the persistent foam, A4 shading
and level of detail. The far grid's cascade weights carry the lee, computed
once a fragment and shared by its normal and the shading's unresolved
slopes; the cat's paws darken the shaded colour as before. The foam's mean
cover, roughness wind and windrow direction follow the sea's wind (its
newest keyframe), as the whitecaps' thresholds already do.
transfix added a commit that referenced this pull request Nov 16, 2026
The one conflict, docs/ARIADNE.md, keeps both: #1310's 'Recording a video'
section, then the browser's texture units. cvcgl_ariadne_realize's 16-unit
block still passes with #1311's uWindFetch in the water: no draw runs out.
transfix added a commit that referenced this pull request Nov 16, 2026
This branch carried #1311's original commit (b6ab0c4), whose files are identical in the squash.
The add/add conflicts (wind_field.h/.cpp, scene_wind.h/.cpp) and water_controls.ari take this
branch's side, which is #1311 plus #1317's changes. docs/ARIADNE.md is a three-way merge on
b6ab0c4 as its base, so master's later edits and #1317's both stand. Against master, the result
is exactly #1317's own diff against b6ab0c4: the same 44 files and the same changed lines.
transfix added a commit that referenced this pull request Nov 16, 2026
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).
transfix added a commit that referenced this pull request Nov 16, 2026
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.
transfix added a commit that referenced this pull request Nov 16, 2026
…ning

Conflict:
- THIRD_PARTY_NOTICES.md, the ABYSSAL summary line: kept the wind gusts and
  currents, the rain streaks and this branch's lightning bolts.
water_node.cpp merged cleanly. The flash's swap into the water lighting
still finds its line.
transfix added a commit that referenced this pull request Nov 16, 2026
…#1305, #1310, #1311)

#1305 gives each Runtime program-lane providers of its own (add_program_intrinsics), so two
documents on one app no longer reach each other's verbs and host functions, and moves
AppRuntime's provider there from the app's list. This branch had split that provider in seven,
each registered on the app with its kind (S1-Q7). Conflicts in ariadne.h, app_runtime.cpp and
ariadne.cpp keep both:

- Runtime::add_program_intrinsics takes a kind too (the form without one is host_only, as
  register_action_intrinsics's), and the Runtime's own list keeps it. AppRuntime adds its seven
  providers there, each with the kind it had, in the same order.
- install_providers runs any list by kind; the Runtime's own run after the app's, by the same
  rules, wherever an env is built: an action, a resident, a spawned child (finish_context), the
  names probe, and init: and a module's init: (every kind as it is, on their own thread).
- host_only_bindings counts the Runtime's own host_only providers, so one that binds anything
  pumps the document's group on the host thread, as an app provider does.
- add_program_intrinsics marks the placement stale, as a late host verb does.
- The own list is read where an env is built, a spawned child's on its pumping worker, so it is
  under a mutex of its own (own_mutex), copied, and run unlocked; names_mutex no longer guards it.

STATE_EXEC_THREADED.md: the Runtime's own providers, AppRuntime's seven among them, and the
fourth late-registration path. Built locally (MSVC Release; AB.lock held the box, so the suites
were not run here); a test of the own providers by kind follows.
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