Skip to content

water: the wake drawn at every adaptive-quality tier - #1550

Merged
transfix merged 1 commit into
masterfrom
fix/wake-every-tier
Nov 26, 2026
Merged

transfix merged 1 commit into
masterfrom
fix/wake-every-tier

Conversation

@transfix

Copy link
Copy Markdown
Owner

Floating bodies leave their rings at every adaptive-quality tier. Until now the last two tiers turned the wake off, and the gallery's browser build sits on the last of them.

Why

  • terrain_lab runs at about 14 fps in the gallery's browser build, against the scene's 30 fps target.
  • So adaptive quality drops one tier every few seconds until it reaches tier 4 ("least"), and it only climbs back when frames take under 15 ms.
  • Tiers 3 and 4 had wake = false, so a crate or the launch on the lake never left a ring in the browser.
  • Native builds stay at tiers 0–1, which is why the wake showed there.

What changes

  • Tiers 3 and 4 keep the wake on its smallest window, 128 cells of 0.5 m (64 m round the camera's target), as tiers 1 and 2 already do (src/cvc/ariadne/scene_quality.cpp).
  • And step it in 1/30 s substeps in place of 1/60:
    • a new WaterQuality::wake_substep is passed to ewave_params::substep by start_wake (src/cvcGL/ariadne/water_node.cpp);
    • the window restarts when the tier changes its substep, as it already does for its size;
    • a frame runs half the substeps;
    • the window's shortest waves (0.7 m) keep ω dt under 0.35, where ewave.h puts a substep's φ within 1 % of the exact, and open water keeps its exact dispersion.
  • The other savings at those tiers are unchanged: the simple shading, no persistent foam, two cascades, and the far normal at half or a quarter.

Measured

terrain_lab at 1280×720 with the camera 14 m behind crate_b on the lake. The figures are the water node's own section times (water.profile 2, which waits for the GPU at each section's end), averaged over frames 60–240, two runs each (Windows, MSVC Release, Intel Arc iGPU):

the wake, a frame sources step upload all
tier 2: 128², 1/60 s 1.89–1.93 ms 2.40–2.48 ms 0.86–0.87 ms 5.3 ms
tier 4: 128², 1/30 s 1.95–2.00 ms 1.56–1.64 ms 0.83–0.84 ms 4.4–4.6 ms
  • The step falls by a third, not a half, because each step also has fixed passes besides its substeps. The wake as a whole falls by about 0.8 ms of a frame of about 47 ms.
  • cvcgl_ewave's own timing agrees: a walled 256² window steps a 1/30 s frame in 0.57–0.88 ms of GPU at 1/60 s (71 passes) and 0.29–0.44 ms at 1/30 s (36 passes).
  • A snapshot at tier 4 shows crate_b ringed by its waves with the wake on, the same at 1/60 s and 1/30 s, and flat water with it off.

Not measured:

  • The browser. Its frames are about 70 ms, so 1/60 s runs about four substeps a frame against two at 1/30 s, and the saving should grow with it. That will be visible in the gallery once this deploys.
  • Wall-clock frame times with the wake on and off were tried first. With other builds sharing the machine they spread too widely to use.

The largest part left is the sources: the CPU's immersion of each body in the sea at the frame's time. No tier changes them.

Tests

  • New: WaterQuality.TheWakeIsDrawnAtEveryTier, which checks the wake, its window size and its substep at each tier. It fails on the old table.
  • Changed: EachTierDrawsNoMoreThanTheOneAbove no longer expects tier 4 without a wake, and checks each tier's substep is no shorter than the tier above's.
  • Run locally (Windows, MSVC Release with cvcGL):
    • ariadne_scene_quality_test: 12 pass;
    • cvcgl_wake and cvcgl_ariadne_realize: pass;
    • cvcgl_ewave: ran for its timings.
  • Not run: Linux, macOS, wasm (CI).

Docs

  • scene_quality.h's tier table.
  • ARIADNE.md's adaptive-quality paragraph.
  • OCEAN-AND-WEATHER-ROADMAP.md §10.10: the table, the reason, and the measurement.

Adaptive quality's last two tiers (3 low, 4 least) turned the bodies'
waves off. The gallery's browser build runs terrain_lab at about 14 fps
against its 30 fps target, so it sits at tier 4 and a floating crate or
the launch never left a ring there. Native builds stay at tiers 0-1 and
always drew them.

Tiers 3 and 4 now keep the wake on its smallest window, 128 cells of
0.5 m (64 m round the camera's target), as tiers 1 and 2 have it, and
step it in 1/30 s substeps in place of 1/60 (WaterQuality::wake_substep,
passed to ewave_params::substep; the window restarts when the tier
changes it, as it does for its size). A frame then runs half the
substeps. The window's shortest waves (0.7 m) keep omega dt under 0.35,
where ewave.h puts a substep's phi within 1 % of the exact, and open
water keeps its exact dispersion; the rings a crate makes look the same.
The other savings at those tiers are unchanged.

Measured with the water node's own section times (water.profile 2,
which waits for the GPU at each section's end), terrain_lab at 1280x720
with the camera 14 m behind crate_b on the lake, frames 60-240, two runs
each (Windows, MSVC Release, Intel Arc iGPU):
- tier 2 (128 cells, 1/60 s): sources 1.89-1.93 ms, step 2.40-2.48 ms,
  upload 0.86-0.87 ms, in all 5.3 ms a frame;
- tier 4 (128 cells, 1/30 s): sources 1.95-2.00 ms, step 1.56-1.64 ms,
  upload 0.83-0.84 ms, in all 4.4-4.6 ms.
The step falls by a third (each step has fixed passes besides its
substeps), the wake by about 0.8 ms of a frame of about 47 ms.
cvcgl_ewave's timing agrees: a walled 256^2 window steps a 1/30 s frame
in 0.57-0.88 ms of GPU at 1/60 s (71 passes), 0.29-0.44 ms at 1/30 s (36).
The browser was not measured; its frames of about 70 ms run about four
substeps at 1/60 s against two at 1/30 s. The sources, the CPU's
immersion of each body, are the largest part left, and no tier changes
them.

Test: WaterQuality.TheWakeIsDrawnAtEveryTier (fails on the old table);
EachTierDrawsNoMoreThanTheOneAbove no longer expects tier 4 without a
wake, and checks each tier's substep is no shorter than the one above.
cvcgl_wake and cvcgl_ariadne_realize pass.
Docs: scene_quality.h's tier table, ARIADNE.md's adaptive quality,
OCEAN-AND-WEATHER-ROADMAP.md 10.10's table and the measurement.
@transfix
transfix merged commit 03544fd into master Nov 26, 2026
54 of 55 checks passed
@transfix
transfix deleted the fix/wake-every-tier branch November 26, 2026 19:11
transfix added a commit that referenced this pull request Nov 27, 2026
…cally, same bits) (#1562)

PhysicsFieldWake.PackedBodiesStayBoundedAndSleep took 581-747 s of its 1200 s ctest budget on
package-linux / libcvc-debug and timed out three times on a slow runner (#1550's). It took 269 s
there on #1344; #1532 made every wake test 2.5-2.8x slower in Debug (the ring 3.0 to 8.2 s, the
golden 2.4 to 5.8 s, this one 269 to 702 s). The test itself is as #1344 wrote it.

Profiled locally (Debug, MSVC /Od): the calm run with a wake is 62% of the test, and 87% of that
is the wake's wave step: deepen, the motion below the top that #1532 added (2 forward and ~3
inverse 64 x 64 FFTs a state a wave step), 51%; the ewave step 21%; sum, which now adds the
depths, 9%. In an unoptimized build std::vector's operator[] is a call per element, and these
passes made ~400k of them a state a wave step. And once every crate sleeps (~90 s into the calm
run) the wake made depths for ~30 s more, while its waves died away, with nothing reading them.

- fluid_wake::ready_depths: the depths are made at the first read after a wave step (in
  field_set::apply before the field workers' reads, when an awake body is in the wake's field,
  and in field_set::water_at), not at every wave step. The same inputs in the same order: the
  same bits. motion() reads only the layers that were made.
- The wake's per-cell passes (deepen, derive, sum, the wave step's dh/dt) and fft_plan::run_2d's
  gather and scatter index through raw pointers: the same operations in the same order. On their
  own, 28% off a 20 s calm run with a wake in Debug (37.5 s to 27.1 s, three interleaved runs,
  the same peaks to 17 digits).
- The test is two: the calm half keeps its name (and #1557's 3600 s), the swell's half is
  PackedBodiesStayBoundedInASwell, so each has its own ctest budget and ctest runs them side by
  side. What the comments claimed is now asserted too: every crate sleeps on calm water (9 of 9)
  and none in the swell (0 and 0). "Without one they sleep within 40" is 3 (2.55 s).

Measured locally, Debug, the old and new builds run side by side on one loaded box: 283.6 s
before; after, the calm half 72.5 s and the swell's 87.8 s (160.3 s). Every value the test prints
is the same to the digit. No pinned hash moves: the wake golden 0xc72e26b4ef0f764a, the shore
golden 0x89789ba92fbd1853, the swell and ocean scenes.
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