Skip to content

water: the cascades' slopes per fragment, filtered at the pixel's footprint (after #1349) - #1351

Merged
transfix merged 5 commits into
masterfrom
feat/water-near-normal
Nov 18, 2026
Merged

transfix merged 5 commits into
masterfrom
feat/water-near-normal

Conversation

@transfix

@transfix transfix commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

The water node's normal now reads the FFT cascades' slopes per fragment, filtered at the pixel's footprint. Before, the near grid took its normal from its 2 m vertices and the far grid from central differences of nearest texels. Drawing only.

Builds on #1349, now on master as cdba913. Master is merged into this branch at cbcce82, so the diff against master is this PR's own change: commit 90bbd04, five files.

Also, a CI fix: commit a0f65db changes two test files.

  • TilerIntrinsicsAriadne.AnActionStartsItUnderTheDefaultLimits (from P3b part 2: cvc tile, pycvc and tiler.tile (the ContourTiler port's surfaces) #1334) now gets the same ctest TIMEOUT 900 and 900 s loop that its segmentation twin already has.
  • It takes 109–111 s in a Debug job. On this PR's run 44274032889 the runner was 3–5× slower (the segmentation twin took 548 s), and the tiler test hit the default 300 s timeout three times.

Why

What

  • OceanCascades::slopes() is a 2D texture array: layer c holds cascade c's height slopes (∂h/∂x, ∂h/∂y).
    • These are the spectrum's own derivatives. The time pass already computes them for the Jacobian's buffers, and the assemble pass discarded them.
    • One more pass, with a draw buffer per layer, writes them after the assemble.
    • The texture is RG16F, repeating and mipmapped with glGenerateMipmap, with anisotropic filtering up to 16× where available.
  • Both grids read the slopes with textureGrad at the fragment's own footprint. Waves a pixel can't resolve average away instead of aliasing.
    • Near grid: the vertex normal now carries only the swell, and the vertices no longer read the cascades for a normal.
    • Far grid: two filtered reads replace eight nearest-texel fetches.
  • oWaterFull's nstep is 0, so nothing coarser than the pixel bounds the normal any more. The ripples and the GGX lobe take what oUnresolvedMss still counts as unresolved.
  • The unused wHt helper is removed.
  • One more fragment sampler. RG16F is filterable in WebGL2 and renderable with the EXT_color_buffer_float the passes already need.
  • vtkOpenGLFramebufferObject::AddColorAttachment attaches a texture array's layer as if it were a 2D texture, which leaves the attachment empty (the framebuffer reported INCOMPLETE_MISSING_ATTACHMENT). The layers are attached with glFramebufferTextureLayer instead, and init fails if the framebuffer isn't complete.

What it shows (terrain_lab.ari, arigl snapshot 1280×720, --frames 240)

  • terrain_lab's sheltered lake barely changes at 9 or 16 m/s. The lee scales the cascades there to about 0.06–0.3. The ripples take the share the lee removes, so they still carry most of the near texture.
  • With the lee off (water.lee=0) at 16 m/s, the cascades' slopes draw a short-crested sea, where water: the rings on terrain_lab's lake (aliased glitter ripples), and twelve ripples in place of six #1349 showed mostly ripple ridges. A diagnostic build with the ripples forced off shows the cascades alone carrying that texture.
  • No rings in any view, master's ring views included. Band-passed images checked: 140 m at 9 and 16 m/s, the moved orbit centre, and lee off.

Frame cost (scratch harness, not committed: a full 1280×720 quad, glFinish over 100 quads, old and new alternated 12 times; Intel Arc iGPU, where cvcGL's contexts run; two runs agreed)

piece change per frame
near grid, every slope resolved (0.02 m a pixel) +0.018 ms
near grid, grazing (0.1 m × 0.6 m) +0.051 ms
far grid (1 m) −0.085 ms
far grid, grazing (0.3 m × 3 m) −0.07 ms
slope pass and mipmaps (three 256² layers) +0.08 ms

Not measured: the vertex shader's savings (12 texel fetches less per near-grid vertex).

Tests run locally (Windows, MSVC Release; pass)

  • cvcgl_ocean_fft:
    • The new check reads the slope layers back against central differences of the height tiles: correlation 0.93–0.96, ratio 1.11–1.19. A central difference reads a band reaching k dx = 1.2 at N = 64 as 0.78 of its slope, so the spectral slope comes out a little steeper.
    • The pass count is now 3 + 2 log2 N.
  • cvcgl_ariadne_realize (307 checks): the 16-texture-unit scene still draws with no draw short of units.
  • cvcgl_ariadne_physics.

Not verified: the browser (WebGL2: sampler2DArray and textureGrad, RG16F rendering and generateMipmap, framebufferTextureLayer), Linux and macOS (CI).

Not done: a LEAN-style variance from filtered slope moments in place of oUnresolvedMss's footprint heuristic; lsystem_coast's sea (OceanFFT, its own vertex normal).

Docs: the roadmap's A4 notes (OCEAN-AND-WEATHER-ROADMAP.md, "The cascades' slopes per fragment"); the water node's and OceanCascades' header comments.

… them

The rings on terrain_lab's lake were the A4 shading's glitter ripples (oMicroSlope)
aliasing. They faded together as the isotropic footprint (the geometric mean of the
pixel's axes) grew from 0.12 m to 0.5 m. At a grazing angle the mean hides the long
axis: from 140 m at 10 degrees a pixel is 0.1 m across the view and 0.58 m along it,
the mean read 0.24 m and kept 80 % of the waves, and the pixel sampled them along the
view at under two pixels a crest. A fixed wave sampled past that aliases into a zone
plate: evenly spaced rings round the screen point where it is one crest a pixel. They
kept their place on the screen when the orbit centre moved; with the ripples off they
were gone.

Each ripple now fades by how far its own phase turns across the pixel (the rest
position's screen derivatives, along the wave's direction): whole within an eighth of a
turn, gone at a quarter. The variance it drops goes to the GGX lobe, as the shared fade's
did. oWaterFull takes the derivatives (dpx, dpy), which both callers (the water node,
lsystem_coast) already take before any branch.

Twelve ripples in place of six (1.7 m down to 0.43 m in equal ratios, golden-ratio
directions within 0.95 rad of the wind, scattered phases): six fixed waves of equal
steepness sum to a pattern that repeats, read as regular parallel ridges near the camera
at 16 m/s and, once the rings were gone, a diagonal lattice further off. With the
ripples off the near grid's own waves leave the lake almost flat, so they carry its
texture.
…bles

A pixel too coarse for the longest ripple whichever way it runs (k times its shortest
axis, bounded below by its area over the root of its axes' squares, at least a quarter
turn) skips the loop, as the shared fade skipped it past 0.5 m: far water costs what it
did. The wavenumbers, frequencies and direction cosines are constants, not worked out
per fragment.

Measured with a scratch harness (oWaterFull on a full 1280 x 720 quad, glFinish over 100
quads, old and new alternated 12 times, Intel Arc iGPU): 0.081 ms a frame more than the
six ripples' 0.087 where every ripple is resolved, 0.054 on terrain_lab's grazing view,
0.001 where none is.
…tprint

The near grid took its normal from its vertices (central differences 1-4 m wide over 2-8 m
triangles), which drops every wave under about 4 m, a lake's short-cascade peak; the far grid
took central differences of nearest texels per fragment.

OceanCascades now writes each cascade's height slopes (the spectrum's own dh/dx and dh/dy,
which the time pass works out for the Jacobian's buffers) into a layer of an RG16F 2D texture
array, one pass with a draw buffer a layer, and mipmaps it. Both grids read it per fragment with
textureGrad at their own footprint (anisotropic where the context can), so the waves a pixel
cannot resolve average away instead of aliasing. The near grid's vertex normal carries only the
swell; oWaterFull's nstep is 0 (nothing coarser than the pixel bounds the normal). One more
fragment sampler: cvcgl_ariadne_realize's 16-unit scene draws with none short.

vtkOpenGLFramebufferObject::AddColorAttachment attaches a texture array's layer as a 2D texture
and leaves the attachment empty, so the layers are attached with glFramebufferTextureLayer.
cvcgl_ocean_fft checks the layers against the height tiles' central differences (correlation
0.93-0.96, ratio 1.11-1.19 at N = 64) and counts the pass (3 + 2 log2 N).

On terrain_lab's sheltered lake little changes: the lee scales the cascades to about 0.06-0.3,
and the ripples, which take the share the lee removes, still carry most of the near texture.
With the lee off at 16 m/s the cascades' slopes draw a short-crested sea. No rings in any view.

Cost (scratch harness, full 1280 x 720 quad, Intel Arc iGPU): near grid +0.018 ms close,
+0.051 ms grazing; far grid -0.085 ms, -0.07 ms grazing (two filtered reads in place of eight
nearest fetches); slope pass and mipmaps +0.08 ms a frame.
…/water-near-normal

# Conflicts:
#	docs/roadmap/OCEAN-AND-WEATHER-ROADMAP.md
#	src/cvcGL/ariadne/water_node.cpp
@transfix
transfix enabled auto-merge (squash) November 18, 2026 09:18
…twin

TilerIntrinsicsAriadne.AnActionStartsItUnderTheDefaultLimits (#1334) tiles a 30-slice tube
through an action's frame loop under ctest's default 300 s and a 300 s loop of its own. It takes
109-111 s in a Debug job (two other branches' package-linux / libcvc-debug runs today); on
#1351's run 44274032889 the runner was 3-5x slower (the segmentation twin took
548 s, the skeleton's 31 s against 10 s) and it timed out three times. Its segmentation twin got
ctest TIMEOUT 900 and a 900 s loop for the same reason; this gives it the same.
@transfix
transfix merged commit 4940c6c into master Nov 18, 2026
30 of 35 checks passed
@transfix
transfix deleted the feat/water-near-normal branch November 18, 2026 15:03
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