Skip to content

lsystem_coast: the seabed and the shore damp the waves; coastH() retired (O3) - #1127

Merged
transfix merged 2 commits into
masterfrom
feat/ocean-shore
Nov 10, 2026
Merged

transfix merged 2 commits into
masterfrom
feat/ocean-shore

Conversation

@transfix

Copy link
Copy Markdown
Owner

O3 of docs/roadmap/OCEAN-AND-WEATHER-ROADMAP.md (A1, A2, and W0.2's textures): the waves stop at the shore instead of passing through it.

This branch includes #1125's commit (the cascade weights as state keys) underneath its own, because both edit lsystem_coast. Once #1125 merges, I'll merge master in here and the diff drops to O3's own commit, f8dd175. I didn't stack the PRs because in this repo deleting a merged branch closes the PRs based on it.

What it does (lsystem_coast)

  • The seabed is a cvc::gl::HeightFieldTexture of terrainH sampled at 1 m over the ocean (441²). Its bilinear grid gives the same heights on the CPU and the GPU.
  • The shore grid is cvc::world::water_bodies (from cvc::world: water_bodies, the sea, lakes and ponds and the shore grid (O1) #1109) built over that seabed, uploaded as an RGBA32F texture: distance to shore (+ offshore), the offshore normal, and the slope. The normal and slope are for O4. The scene reports "1 sea" on its 441² grid.
  • The vertex shader fades each cascade as the still water shoals. It is fully off on dry ground and the sea is still at the waterline. A faded cascade's fold (Jacobian) relaxes toward 1 with it, so foam fades too.
  • The fade depth is the cascade band's half wavelength, capped by a new knob, coast.water.shore_fade (default 3 m). The island stands on a shelf about 9 m deep that runs out to the horizon:
    • Uncapped, the ~60 m peak waves would fade over 30 m of depth and calm the whole visible sea.
    • Real shallows slow and steepen waves rather than flattening them; carrying that energy in is the shore layer's job (A3, O4).
    • Raising the knob gives the roadmap's uncapped rule.
  • No vertex moves sideways more than 0.8 of its distance to shore, so none can cross the waterline. This replaces the roadmap's "fade sideways motion within 2 m", which doesn't guarantee it.
  • The fragment shader's depth (the shallow tint and the shore foam band) reads the seabed texture. coastH(), the hand-copied GLSL of terrainH, is gone.

Checked

  • The waterline check. lsystem_coast --shore-check is a new flag; it exits 3 if any vertex lands on dry ground. After the run it reads back the three cascades and evaluates the vertex shader's displacement on the CPU for every offshore vertex (nearest texel, wrapped, as the GPU samples), counting those that land on dry ground:

    time offshore vertices old shader onto dry ground this one largest sideways move within 10 m of shore (old → now)
    0.45 s 44 722 60 0 3.28 → 3.18 m
    1.33 s 44 722 60 0 3.15 → 2.67 m
    5.00 s 44 722 76 0 3.60 → 3.11 m

    It checks the shader's arithmetic and the textures it reads; the GPU's own run of it shows in the frames.

  • Frames. In orbit and fly captures, the open sea keeps its chop. Near the island the water calms and turns shallow turquoise toward the beach, and the foam band sits on the waterline. No shader errors.

Built and run locally (Windows Release, GL build). git clang-format 18.1.8 is clean on the changed lines. The roadmap's A2 gets an "as built" note covering the fade cap and the sideways limit.

Next

O4, the shore layer: an eikonal phase map for refraction, Green's law shoaling, breaking, runup and the wetness texture, and reflection off the cliffs. It reads the shore grid's normal and slope uploaded here.

coast.water.weight_long, weight_mid and weight_short (the 251, 83 and 29 m cascades) set each
band's amplitude, baked into h0 so the physics band will see the same sea; a change rebuilds h0
like any spectrum knob. All default to 1, the one physical spectrum, so the default sea is
unchanged (an orbit capture's frame is byte-identical to before). The Ocean panel gains a slider
for each (0 to 2).
…red (O3)

O3 of docs/roadmap/OCEAN-AND-WEATHER-ROADMAP.md (A1, A2, W0.2's textures).

The seabed is a HeightFieldTexture of terrainH at 1 m over the ocean, and the shore grid is
cvc::world::water_bodies uploaded as an RGBA32F texture (distance to shore, offshore normal,
slope). The vertex shader fades each cascade as the still water shoals, over its band's half
wavelength capped by coast.water.shore_fade (3 m: the island's shelf is about 9 m deep to the
horizon, so the uncapped rule would calm the whole sea before the shore layer, O4, carries the
long waves in), and never moves a vertex sideways more than 0.8 of its distance to the shore.
The fragment shader's depth reads the seabed texture; coastH(), the GLSL copy of terrainH, is gone.

lsystem_coast --shore-check evaluates the vertex shader's displacement on the CPU over the
read-back cascades: at t = 1.3 s the old shader put 60 offshore vertices on dry ground, this one
none (76 and none at t = 5 s).
@transfix
transfix enabled auto-merge (squash) November 10, 2026 05:32
@transfix
transfix merged commit 81161ac into master Nov 10, 2026
15 of 30 checks passed
@transfix
transfix deleted the feat/ocean-shore branch November 10, 2026 07:24
transfix added a commit that referenced this pull request Nov 10, 2026
…rary (#1114), seabed damping (#1127)

One conflict, in ci.yml's sanitizer test list: this branch's stream_test,
net_ws_client_test and ariadne_host_test, and master's param_table_test, all
kept.
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