Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

Craft guides bevy/solari (ray-traced light: what it lights and traces, glowing lamps, rooms that do not leak, cuts, metering) and bevy/water (seas, lakes and pools: waves, reflection, refraction, absorption, caustics, foam), routed from bevy.md, their sources cited in NOTICE

shinyobjectz1be0cc4a5b5f
diff --git a/sdk/guides/craft/bevy.md b/sdk/guides/craft/bevy.md
index 63f42187..8cb0dbfc 100644
--- a/sdk/guides/craft/bevy.md
+++ b/sdk/guides/craft/bevy.md
@@ -31,6 +31,8 @@ pieces; then write the file. Each file's example is a complete composition you c
| an asset to fix in Blender first (scale, pivot, heavy mesh, FBX/OBJ, rig, bake); never a whole scene | `bevy/blender` |
| a real scene or object from footage as gaussian splats, and animating them (assemble, disperse, morph...) | `bevy/splats` |
| liquids and goo: coffee dumped from a mug, a tap's stream, honey, things melting | `bevy/liquids` |
+| water: seas, lakes and pools; waves, reflection, refraction, absorption, caustics, foam | `bevy/water` |
+| ray-traced light (Solari): what it lights and traces, glowing lamps, rooms that don't leak, cuts, metering | `bevy/solari` |
| bloom, fog, tone mapping, exposure, fisheye and lens distortion, motion blur | `bevy/post` |
| how much the scene can hold, what isn't there yet | `bevy/limits` |
diff --git a/sdk/guides/craft/bevy/NOTICE b/sdk/guides/craft/bevy/NOTICE
index 4146eada..84a6ac96 100644
--- a/sdk/guides/craft/bevy/NOTICE
+++ b/sdk/guides/craft/bevy/NOTICE
@@ -3,3 +3,9 @@ raea/3d. No text was copied from other packs. Its layout (a short router, one fi
checked example and a list of common mistakes) follows EnzeD/r3f-skills (no license stated; cited, not copied),
chrisgliddon/bevy-skills (MIT) and gamedev-skills' bevy-ecs (Apache-2.0). Bevy API facts come from Bevy's own v0.19.1
examples and migration guides (MIT OR Apache-2.0). The survey with links is in sdk/raea/docs/bevy-coverage.md.
+
+The Solari and water topics (bevy/solari.md, bevy/water.md) cite, and don't copy: Bevy's bevy_solari docs, its
+examples/3d/solari.rs and its implementation (v0.20, MIT OR Apache-2.0); JMS55's "Realtime Raytracing in Bevy 0.17
+(Solari)"; GPU Gems 1 ch. 1, "Effective Water Simulation from Physical Models"; Tessendorf's "Simulating Ocean
+Water"; an ocean simulation and rendering survey; Neopallium/bevy_water and mate-h/bevy_fft; and Bevy Elements'
+water research note.
diff --git a/sdk/guides/craft/bevy/solari.md b/sdk/guides/craft/bevy/solari.md
new file mode 100644
index 00000000..8c956d67
--- /dev/null
+++ b/sdk/guides/craft/bevy/solari.md
@@ -0,0 +1,157 @@
+# Ray-traced light: Solari
+
+## What to do
+
+- Put `<SolariLighting />` (`raea/light`) inside the `<Camera3d>` it lights. raea sets up what Bevy asks for around it
+ (HDR, no MSAA, the deferred and depth prepasses). It needs a GPU with ray queries: Apple silicon on Metal, an RTX
+ card on Vulkan. Elsewhere the scene draws raster-lit and raea says so. On the Mac, MetalFX's denoiser cleans the
+ result (`RAEA_SOLARI_DENOISE=0` shows the raw noise).
+- Its three props:
+ - `bounces`: how many times light bounces. Bevy's default is 3 when it's left out; 2 is enough for most rooms and
+ costs less.
+ - `restir`: reuse light samples between pixels and frames. It's off by default, as Bevy has it. Turn it on when
+ contact shadows look soft or hard light flickers; it costs a real share of the frame.
+ - `reset`: start the lighting's history again. Set it on the first frame of a cut made by moving one camera, or
+ the old shot's light smears into the new one for a few frames. A cut between cameras (`<Camera3d is_active>`,
+ the first active one draws) needs none: the engine resets Solari's and the path tracer's history on the frame
+ the shot changes.
+- For a still to judge the look against, use `<Pathtracer />` in its place: exact and slow, accumulating while the
+ view holds still. It isn't for motion.
+- Light the scene with what Solari sees:
+ - a `DirectionalLight` (the sun);
+ - emissive surfaces: a `StandardMaterial` with `emissive`. A fluorescent tube is a thin glowing box, a bulb a small
+ glowing sphere, and a screen its picture as `emissive_texture`;
+ - an `<Environment>` panorama, and `<Atmosphere light />`.
+
+ Bevy 0.20's Solari has no point, spot or rect lights, so a `PointLight` lights nothing it traces. For the same
+ light, a big dim emitter is cleaner than a small bright one.
+- Under Solari a glow is light, exposed by the camera like the rest. Raster lighting draws `emissive` 1-3 as a glow;
+ traced, a tube that lights a room is in the thousands (7,000 lights a pool hall) and a screen in the hundreds to
+ low thousands.
+- Know what it traces: each `Mesh3d` and `Model` part whose material is a plain `StandardMaterial`. These are drawn
+ raster-lit after the denoiser instead:
+ - an `ExtendedMaterial` (a `ShaderExtension`, a toon or paint extension);
+ - a `ToonMaterial`;
+ - a skinned or morphed mesh (a `<Character>`).
+
+ The sun's shadow map and the Environment light them, and they reflect only the panorama. The rays pass through
+ them, so they cast no traced shadow, stop no light, bounce none, and their glow lights nothing.
+- Where light must stop, back an untraced surface with a traced one: a traced floor under shader water, a box behind
+ a toon facade. Keep `shadow_maps_enabled` on the sun, so the untraced parts still get shadows and volumetric fog
+ still gets its shafts.
+- Build closed, thick rooms: walls as boxes, not planes, meeting at the corners. Light leaks through gaps and single
+ faces. The bounce cache's cells are 15 cm, so a wall thinner than that next to a bright light leaks too.
+- Keep an interior under about 50 m across. A bounce ray that goes 50 m without hitting anything counts as sky, so a
+ bigger hall gets sky light in its bounce.
+- Put every light in the tree from the first frame, and change brightness with the sky, the glows and the exposure
+ rather than the sun's `illuminance`. As of raea 0.1.1:
+ - a `DirectionalLight` that appears after the first frame lights nothing directly;
+ - the traced sun keeps its first frame's strength (its direction does follow);
+ - one `--at` render that jumps more than about 4.5 s between two frames loses the traced sun for every frame
+ after.
+
+ So render stills one per process (`--frame N`), and a film a shot a chunk.
+- In a surface hook (`fn surface`), write `emissive` with alpha 1.0. Bevy reads that alpha as how much the camera's
+ exposure applies, so 1.0 puts the hook's glow in the traced light's units. At 0.0 the glow skips the exposure and
+ comes out about 1,000 times brighter at the default.
+- Meter before you match. Render a still with no grade pass, read the traced surfaces' linear values (sRGB-decode
+ the PNG), and give anything you work out by hand those values: a reflection traced in a shader, a glow meant to
+ sit beside the room's light. A pool hall's walls metered 13-17 under its 7,000 tubes.
+
+## Why
+
+Solari is real-time path tracing in three parts. Direct light picks among the emissive triangles and the sun with
+ReSTIR, which resamples candidate lights and reuses good ones across neighbouring pixels and frames. Bounce light comes
+from a world-space cache that rays keep updating (the world cache), read wherever a path ends. All of it is traced
+against acceleration structures built from the meshes. That's why it needs its own mesh layout (raea makes a copy per
+mesh, once), why only the `StandardMaterial` fields it knows are traced (base colour, emissive, metallic and roughness,
+normal maps, alpha masks, `uv_transform`), and why it's noisy until a denoiser runs. Reflections went in with 0.18
+(specular) and 0.19 (a mirror BRDF). Their motion vectors aren't there yet, so a polished floor's reflections smear
+when the camera moves.
+
+Bevy changes Solari every release. It arrived in 0.17, gained specular in 0.18 and mirrors in 0.19, and 0.20 turned
+ReSTIR off by default, added the atmosphere and environment lighting, and ran on Metal (with no denoiser of its own:
+raea adds MetalFX). Read the docs and `examples/3d/solari.rs` for the version raea vendors (0.20, whose shaders are
+WESL), not a post written for an older one.
+
+## Common mistakes
+
+- Lamps as `PointLight`s under Solari: the room renders dark. Make them emissive meshes.
+- A shader surface expected to stop light. A pool's water drawn as a `ShaderExtension` plane, with no basin floor
+ under it, let a sun parked under the ground shine up through the pool and light the ceiling over it white. A
+ traced box under the water fixed it.
+- Walls of `Plane3d`: light leaks along their edges. Use boxes.
+- No `reset` at a cut made by moving the one camera: the new shot's first frames carry the old shot's light.
+- A tiny, very bright emitter (a 1 cm LED at 100,000): fireflies. Make it bigger and dimmer, or turn on `restir`.
+- Judging reflections from one still. Check a moving shot for smearing.
+- A glow pitched for raster (`emissive` 2) in a traced scene: it's black. Pitch it in the traced light's units.
+- Following a 0.17 or 0.18 example: the API and the defaults have changed since.
+
+## Example: a hall lit by its tubes and a low sun, with a cut
+
+```tsx
+import { AbsoluteFill, Composition, registerRoot, useCurrentFrame } from "raea";
+import { Atmosphere, ToneMapping } from "raea/3d";
+import { StandardMaterial } from "raea/pbr";
+import { Cuboid, Mesh3d } from "raea/mesh";
+import { DirectionalLight, SolariLighting } from "raea/light";
+import { LinearRgba } from "raea/color";
+import { Transform } from "raea/transform";
+import { Camera3d } from "raea/camera";
+
+type V3 = [number, number, number];
+// a closed hall 10 m wide, 4 high and 20 long, its walls 20 cm boxes, a window in the left wall from z -12 to -6
+const SLABS: { name: string; min: V3; max: V3 }[] = [
+ { name: "floor", min: [-5.2, -0.2, -20.2], max: [5.2, 0, 0.2] },
+ { name: "ceiling", min: [-5.2, 4, -20.2], max: [5.2, 4.2, 0.2] },
+ { name: "wall-r", min: [5, 0, -20.2], max: [5.2, 4, 0.2] },
+ { name: "wall-far", min: [-5.2, 0, -20.2], max: [5.2, 4, -20] },
+ { name: "wall-near", min: [-5.2, 0, 0], max: [5.2, 4, 0.2] },
+ { name: "wall-l-low", min: [-5.2, 0, -20.2], max: [-5, 1, 0.2] },
+ { name: "wall-l-high", min: [-5.2, 3, -20.2], max: [-5, 4, 0.2] },
+ { name: "wall-l-back", min: [-5.2, 1, -20.2], max: [-5, 3, -12] },
+ { name: "wall-l-front", min: [-5.2, 1, -6], max: [-5, 3, 0.2] },
+];
+const box = (min: V3, max: V3) => ({
+ transform: Transform.fromXyz((min[0] + max[0]) / 2, (min[1] + max[1]) / 2, (min[2] + max[2]) / 2),
+ half: [(max[0] - min[0]) / 2, (max[1] - min[1]) / 2, (max[2] - min[2]) / 2] as V3,
+});
+// the tubes: thin glowing boxes (Solari has no point lights), bright because Solari exposes a glow like any light
+const TUBES = [-2.5, 2.5].flatMap((x) => [-3, -9, -15].map((z) => ({ x, z })));
+
+function Hall() {
+ const f = useCurrentFrame();
+ const cut = f === 45;
+ const cam = f < 45 ? Transform.fromXyz(3.5, 1.6, -1).lookingAt([-2, 1.2, -14]) : Transform.fromXyz(-1, 1.2, -18.5).lookingAt([1, 1.6, -2]);
+ return (
+ <AbsoluteFill style={{ background: "#000000" }}>
+ <Camera3d transform={cam} projection={{ Perspective: { fov: (55 * Math.PI) / 180 } }}>
+ <SolariLighting bounces={2} reset={cut} />
+ </Camera3d>
+ <ToneMapping exposure={1} />
+ <Atmosphere light />
+ <DirectionalLight illuminance={60000} shadow_maps_enabled transform={Transform.fromXyz(-20, 9, -6).lookingAt([0, 0, -9])} />
+ {SLABS.map(({ name, min, max }) => {
+ const b = box(min, max);
+ return (
+ <Mesh3d key={name} name={name} transform={b.transform}>
+ <Cuboid half_size={b.half} />
+ <StandardMaterial base_color={name === "floor" ? "#8c8378" : "#d8d2c4"} perceptual_roughness={0.8} />
+ </Mesh3d>
+ );
+ })}
+ {TUBES.map(({ x, z }) => (
+ <Mesh3d key={`${x},${z}`} name={`tube-${x}-${z}`} castShadow={false} transform={Transform.fromXyz(x, 3.96, z)}>
+ <Cuboid half_size={[0.06, 0.02, 1.2]} />
+ <StandardMaterial base_color="#ffffff" emissive={new LinearRgba(5000, 5200, 4800, 1)} />
+ </Mesh3d>
+ ))}
+ </AbsoluteFill>
+ );
+}
+
+registerRoot(() => <Composition id="hall" component={Hall} width={960} height={540} fps={30} durationInFrames={90} />);
+```
+
+Render frames 20 and 60 (`--frame`, one per process) and look: the sun's patch through the window on the floor, its
+bounce warming the walls, the tubes lighting the ceiling round them.
diff --git a/sdk/guides/craft/bevy/water.md b/sdk/guides/craft/bevy/water.md
new file mode 100644
index 00000000..0de8b08b
--- /dev/null
+++ b/sdk/guides/craft/bevy/water.md
@@ -0,0 +1,170 @@
+# Water: seas, pools and what's under them
+
+## What to do
+
+- Decide what the shot needs from the three parts of a believable water:
+ - **motion**: the waves, and whether the swell has to rise in silhouette or only move the light;
+ - **appearance**: how light meets it (reflection, what shows through, colour by depth, glitter, foam, caustics);
+ - **interaction**: things in it (a wake, rings round a post, a splash, foam at the shore).
+
+ Most shots need the first two. Leave out what the camera can't see.
+- Pick the technique by the shot:
+ - **A sum of waves in a surface shader** (Gerstner, GPU Gems 1 ch. 1): cheap, loops, and fine for calm to choppy
+ seas, lakes and pools. This guide's way.
+ - **A spectrum by FFT** (Tessendorf; `mate-h/bevy_fft` is a building block): an open ocean of many thousands of
+ waves that tiles. Heavier, and not in raea's SDK yet.
+ - **A shallow-water simulation** (bevy_fft has one): water that flows and ripples where things move through it.
+ - **A baked liquid**: `<Goo solver="sph">` for pours, splashes and spills (`bevy/liquids`).
+ - `Neopallium/bevy_water` (vertex waves, a height query for floating things, tiles) is a crate for Bevy 0.18; raea
+ is on 0.20. Take its wave set and its height query, not the crate.
+- In raea a water surface is a flat `Plane3d` with `<ExtendedMaterial base={<StandardMaterial ...
+ opaque_render_method="Forward" />} extension={<ShaderExtension wesl={SRC} uniforms={...} />} />`. Its
+ `fn surface(in, pbr)` sets the normal (`(*pbr).N`), the colour, the roughness and the emissive per pixel; read
+ uniforms as `u_NAME()`, and the time as `globals.time`. The hook can't move vertices and a `Plane3d` has no
+ subdivisions, so the plane stays flat. Waves move the light, not the silhouette. For a swell that rises against the
+ sky, bake a displaced mesh per frame (`<MeshSequence>`) or use `<Goo>`.
+- Waves as normals:
+ - Sum trains of different wavelength `len`, direction `d` and amplitude `a`. For each, `k = 2π/len`, and the speed
+ is deep water's: `ω = √(9.8 k)`. Round ω to whole cycles in the shot (or the minute) and the water loops.
+ - Steepness `ka` sets the sea state: 0.02-0.03 is a light breeze or a sheltered cove, 0.05 is choppy. Sharpen the
+ crests with Gerstner's term (`n.y = 1 - Σ Q·ka·sin`, Q about 0.5).
+ - Give each train its own phase, space the wavelengths about 1.4 times apart, and scatter the directions within
+ about 50 degrees of the swell's. Trains in simple ratios, or in nearly square pairs, draw a lattice.
+- Filter by the pixel, not by distance. Fade each train as it nears six pixels (`keep = clamp(len / (6 *
+ length(fwidth(p.xz))) - 1, 0, 1)`). Then add the slope it no longer draws to the roughness: `α² = α0² + Σ (1 -
+ keep)·(ka)²/2`, and perceptual roughness is `√α`. Far water then widens the sun's glitter into a path instead of
+ shimmering.
+- Reflect at water's own strength: `reflectance={0.35}` (Bevy's F0 is 0.16·r², so 0.35 is water's 2%; 0.5 is 4%,
+ glass). Fresnel then takes the water from see-through underfoot to a mirror at the horizon.
+- What a forward plane reflects: Bevy's lighting gives it the Environment (the panorama or the atmosphere) and the
+ sun's highlight, but not the scene: no other objects and no screen-space reflections. Outdoors that's most of what
+ the sea shows. Indoors the panorama is some other place, so trace the room in the shader instead: its box, its
+ lights and its windows, at the values you metered (`bevy/solari`). Set `reflectance={0}` so Bevy adds no panorama,
+ and add the room `* fresnel` to the emissive.
+- What shows through, `* (1 - fresnel)`:
+ - Refract the view ray into the water (`refract(v, n, 1 / 1.33)`) and trace it to the floor or a wall. Lane lines
+ and tiles then bend with the ripples.
+ - Absorb along the way down and back up (Beer-Lambert, `exp(-σ·distance)`). Clear water is about σ = (0.45, 0.065,
+ 0.022) per metre, so red is gone in two metres and the deep end goes blue-green.
+ - Add a little scatter from the lamps for the glow round them.
+ - For a sea, the body colour is a deep teal or blue base colour, lit by Bevy.
+- Caustics are where the bent rays bunch up. Light crossing a surface with height Hessian `H` lands a throw `D`
+ further on, where `D = depth × (1 - 1/1.33)` going in (onto a floor) and `distance × 0.33` coming out (onto a
+ ceiling over a pool). The brightness is `1 / |det(I + D·H)|`: thin bright lines where the determinant nears
+ nought. Draw them on the floor inside the water's shader, and on a ceiling as an added plane (`alpha_mode="Add"`,
+ base black, the net as emissive).
+- Crests and foam:
+ - Where a low sun is ahead, light comes through the thin crests on faces turned to the camera, as a green-gold
+ glow. Write it as emissive, and only where the sun really reaches.
+ - Foam goes where the Gerstner fold sum gets steep: white, roughness 0.85, broken into streaks along the swell.
+ - Shore foam needs the water's depth, which the depth prepass can't give (the opaque water is in it), so give the
+ shader the shore's shape as a distance.
+- Write the emissive with alpha 1.0, so it's in the scene's light units (`bevy/solari`).
+- Under Solari the water isn't traced. Close the basin under it with a traced box, or light from below (a sun parked
+ under the ground) comes up through it. Water that must mirror the scene's own objects (a boat, a person on the
+ edge) can be a plain `StandardMaterial` instead (roughness 0.02-0.05, `reflectance={0.35}`, a normal map moved
+ with `uv_transform`). Solari then traces its reflections, but it can't refract or show the floor.
+
+## Why
+
+Water is almost all light transport. Its own colour is dark, so what you see is the sky or the room it reflects,
+weighted by Fresnel, plus what comes up from under it, coloured by how far that light travelled through the water.
+The waves matter because they move the reflection and the refraction around. A flat plane with good normals and
+honest Fresnel, absorption and caustics reads as water from any height where the swell doesn't break the horizon.
+GPU Gems' rule is low-frequency waves as displacement and high-frequency ones as normals. In raea the plane can't be
+displaced, so everything is normals, and the long waves are kept gentle.
+
+Sources: GPU Gems 1 ch. 1, "Effective Water Simulation from Physical Models" (Finch: Gerstner sums, mesh resolution
+limits); Tessendorf, "Simulating Ocean Water" (the spectrum, caustics, scattering, sunbeams); the ocean rendering
+survey (picking a technique); `Neopallium/bevy_water` and `mate-h/bevy_fft` (Bevy implementations);
+Bevy Elements' water research note.
+
+## Common mistakes
+
+- `reflectance={0.5}`: 4%, glass. The water looks grey and plastic. Use 0.35.
+- Every train with phase 0: they all crest together near the origin and draw a target of rings there.
+- Trains in simple ratios or square pairs: a lattice of diamonds. Space them about 1.4x and scatter the angles.
+- Too steep near a low camera: 15 cm over the sea, each wave is a glass blob. Keep `ka` near 0.03 for a calm sea.
+- Fading short waves by distance (`dist / 80`) instead of the pixel: far water aliases, or near water goes smooth.
+- An indoor pool reflecting the HDRI of some other place. Trace the room and set `reflectance={0}`.
+- Caustics as `1 / (1 + D·∇²h)`: soft blobs, not the net. Use the Hessian's determinant.
+- Expecting the water to stop light under Solari: put a traced floor under it.
+- A backtick inside a WGSL comment in a TS template string ends the string ("Expected a semicolon").
+
+## Example: a calm sea at sunset
+
+```tsx
+import { AbsoluteFill, Composition, registerRoot, useCurrentFrame } from "raea";
+import { Atmosphere, ToneMapping } from "raea/3d";
+import { ExtendedMaterial, ShaderExtension, StandardMaterial } from "raea/pbr";
+import { Mesh3d, Plane3d, Sphere } from "raea/mesh";
+import { DirectionalLight, SolariLighting } from "raea/light";
+import { Transform } from "raea/transform";
+import { Camera3d } from "raea/camera";
+
+// The sea's surface: sixteen Gerstner trains as normals (the plane stays flat), on deep-water speeds, each with its own
+// phase, wavelengths 1.39x apart at scattered angles round the swell's. A train under ~6 pixels fades and its slope
+// goes into the roughness, so the far sea widens the sun's glitter instead of shimmering.
+const SEA = /* wgsl */ `
+const TAU: f32 = 6.2831853;
+fn surface(in: VertexOutput, pbr: ptr<function, PbrInput>) {
+ let p = in.world_position.xz;
+ let t = globals.time;
+ let fw = max(length(fwidth(p)), 1e-4);
+ var slope = vec2<f32>(0.0);
+ var q = 0.0;
+ var lost = 0.0;
+ for (var i = 0; i < 16; i++) {
+ let fi = f32(i);
+ let len = 14.0 * pow(0.72, fi);
+ let a = (fract(sin(fi * 12.9898 + 4.1) * 43758.5453) - 0.5) * 1.75;
+ let d = vec2<f32>(sin(a), cos(a));
+ let k = TAU / len;
+ let om = round(sqrt(9.8 * k) * u_loop() / TAU) * TAU / u_loop();
+ let ph = k * dot(d, p) - om * t + fract(len * 7.31) * TAU;
+ let ka = u_steep();
+ let keep = clamp(len / (fw * 6.0) - 1.0, 0.0, 1.0);
+ slope += keep * ka * cos(ph) * d;
+ q += keep * 0.55 * ka * sin(ph);
+ lost += (1.0 - keep) * 0.5 * ka * ka;
+ }
+ (*pbr).N = normalize(vec3<f32>(-slope.x, 1.0 - q, -slope.y));
+ let a0 = 0.04 * 0.04;
+ (*pbr).material.perceptual_roughness = sqrt(sqrt(a0 * a0 + lost));
+ // the water's own colour (what comes up from under the surface); the sky and the sun come from Bevy's lighting
+ (*pbr).material.base_color = vec4<f32>(0.004, 0.03, 0.045, 1.0);
+}`;
+
+function Sea() {
+ const f = useCurrentFrame();
+ return (
+ <AbsoluteFill style={{ background: "#000000" }}>
+ <Camera3d transform={Transform.fromXyz(0, 1.2 + 0.002 * f, 6).lookingAt([0, 0.9, -40])} projection={{ Perspective: { fov: (40 * Math.PI) / 180, far: 4000 } }}>
+ <SolariLighting bounces={2} />
+ </Camera3d>
+ <ToneMapping exposure={-1} />
+ <Atmosphere light />
+ <DirectionalLight illuminance={40000} shadow_maps_enabled transform={Transform.fromXyz(8, 5, -100).lookingAt([0, 0, 0])} />
+ <Mesh3d name="sea">
+ <Plane3d half_size={[2000, 2000]} />
+ {/* reflectance 0.35 is water's 2% (Bevy's F0 = 0.16 r^2); Forward, as a surface hook runs in the main pass only */}
+ <ExtendedMaterial
+ base={<StandardMaterial base_color="#0a3040" perceptual_roughness={0.04} reflectance={0.35} opaque_render_method="Forward" />}
+ extension={<ShaderExtension wesl={SEA} uniforms={{ loop: 3, steep: 0.03 }} />}
+ />
+ </Mesh3d>
+ {/* a rock: a plain StandardMaterial, so Solari traces it (the sea is drawn forward and isn't) */}
+ <Mesh3d name="rock" transform={Transform.fromXyz(-6, -0.4, -18).withScale([3, 1.2, 2])}>
+ <Sphere radius={1} />
+ <StandardMaterial base_color="#3a332c" perceptual_roughness={0.9} />
+ </Mesh3d>
+ </AbsoluteFill>
+ );
+}
+
+registerRoot(() => <Composition id="sea" component={Sea} width={960} height={540} fps={30} durationInFrames={90} />);
+```
+
+A frame shows the sun's glitter path running to the horizon, widening with distance, and the sky's gradient
+reflected in the near ripples. A pool builds on the same waves: refract into the basin, absorb, light the floor and
+its caustics, and trace the hall into the reflection, as the list above says.