3D engine that AI agents drive
Merge origin/main into feat/probe-bounce
Nguyen Xuan Anbf80b641ab96
diff --cc bench/reference/README.mdindex fa044c2b,ded022f0..a3dce264--- a/bench/reference/README.md+++ b/bench/reference/README.md@@@ -1145,30 -1186,21 +1186,49 @@@ Which scenes the bounce skips (a temporNothing moved, so `baseline.json` is unchanged. `foliage` is still 0.0979 against EEVEE 0.0888, and the issue stays open.Bundle size: `entry:ground-bounce` is 9451 bytes gzip (9318 before the texture mean, which adds 133 bytes), so its budget rose from 9330 to 9460.+## One bounce and the sky in object probes (2026-11-03, part of issue #167)++`OBJECT_PROBE_BOUNCES` went from 0 to 1, and a probe hit on a non-metal surface now adds the sky that surface mirrors toward the probe. Measured on SwiftShader first, then the GPU (FLIP against Cycles, `baseline.json` rows of `metal`, `metal-room`, `brushed-film`, `car-paint` and `material-spheres` updated; mountain-valley moved 0.1769 to 0.1820 on this machine's run with no probe in the scene, so its baseline row and the other 17 rows were kept as they were).++The earlier bounce try (#209, 0.1246 at 64 samples) was measuring a bug: `directIrradiance` returns one shared array, the gatherer calls it again for every neighbour it hits, and `traceProbeMaps` read `direct` after that call, so each probe pixel got the direct light of the last neighbour the gatherer visited (usually in shadow). The floor's mean in the probe fell from 0.25 to 0.15 with one bounce. With a copy of the direct light first, one bounce adds a little light and no longer darkens.++| SwiftShader, `metal` | FLIP | probe trace |+| --- | --- | --- |+| Main | 0.0962 | 0.12 s |+| One bounce, bug as it was | 0.1098 | 0.24 s |+| One bounce, direct light copied | 0.0955 | 0.25 s |+| Plus dielectric sky reflection (Fresnel, F0 0.04, capped by gloss, sky blurred to a cosine lobe, one shadow ray) | 0.0942 | 0.25 s |+| Same, Fresnel not capped by gloss | 0.0938 (`brushed-film` 0.1019) | |+| Same, plus metal parts mirroring the sky too | 0.0939 | |+| Two bounces | 0.0941 | 0.28 s |++Kept: one bounce, the copy, the capped Fresnel sky reflection. The uncapped Fresnel, the metal reflection and the second bounce are worth 0.0003 or less and cost code or time. GPU result against Cycles:++| Scene | Main | Now | EEVEE |+| --- | --- | --- | --- |+| `metal` | 0.0964 | 0.0944 | 0.0916 |+| `metal-room` | 0.5071 | 0.5045 | 0.5262 |+| `material-spheres` | 0.0956 | 0.0954 | 0.1053 |+| `car-paint` | 0.0979 | 0.0978 | 0.0844 |+| `brushed-film` | 0.1017 | 0.1019 | 0.0984 |++`brushed-film` is 0.0002 worse (the sky reflection; it was 0.1015 with the bounce alone on SwiftShader). Probe trace time on this machine (SwiftShader run, JS, so the same on the GPU run): `metal` 0.12 to 0.25 s, `brushed-film` 0.09 to 0.20 s, `car-paint` 0.06 to 0.10 s, `material-spheres` 0.19 to 0.37 s, `metal-room` 0.06 to 0.41 s; the trace runs when parts, lights or materials change, and a scene without a reflective part never loads it. `metal` is still 0.0028 above EEVEE: the cylinder's floor reflection is the closest gap left (probe 0.567 against Cycles 0.578 in the region, mean display luminance), the rest is light between metal parts that a diffuse bounce does not carry. The room probe trace (`PROBE_BOUNCES` 2) had the same overwritten `direct` and now reads the right light; no baseline scene uses it.+++ ## Ground bounce occluded by the parts above it, measured and not kept (2026-11-03, part of issue #197)++ Idea, from the shadow depth remeasure (#252): the ground bounce counts the ground as lit, but under and beside a caster it is in shadow, and Cycles darkens the bounce there. Change tried: `groundOpenness(parts)` in `src/ground-bounce.js` traced 24 upward rays from an 8 by 8 grid over the ground around the non-floor parts (their footprint widened by the tallest part's height) with `skyVisibilityGrid`, took the mean share that escapes (1 is open ground), and multiplied the lower half of the diffuse copy by it. Derived from the scene, once per parts array, no cost per frame, and nothing in core. `closed-room.js` only gained an optional grid size.++ Measured on the same Cycles arrays as main (GPU, 960 x 540; `brick-flat` redrawn as well, the other scenes have no part above the floor, so the term is 1 and their rows are unchanged by construction):++ | Scene | floor before | floor after | FLIP before | FLIP after | change |+ | --- | --- | --- | --- | --- | --- |+ | `material-spheres` | 2.01 | 1.81 | 0.0956 | 0.1049 | +0.0093 |+ | `car-paint` | 2.61 | 2.57 | 0.0979 | 0.0995 | +0.0016 |+ | `long-street` | 1.68 | 1.66 | 0.1121 | 0.1134 | +0.0013 |+ | `outdoor-hdri` | 2.42 | 2.28 | 0.0333 | 0.0350 | +0.0017 |+ | `brick-flat` | | | 0.0547 | 0.0608 | +0.0061 |+ | `character` | 1.27 | 1.23 | 0.0567 | 0.0567 | 0.0000 |++ The shadow floors move toward Cycles (mostly by 0.02 to 0.2) but five scenes get worse and two pass the 0.002 limit (`material-spheres` +0.0093, `brick-flat` +0.0061; worst regression). Cause (inferred): the term cuts the bounce that reaches the sides of objects and walls, where Cycles still has all of it, more than it cuts the light in the shadowed floor tiles; `material-spheres` lit-level 1.09 after. The shadowed floor itself gets no bounce from the lower-half copy in the first place (a level surface sees none of a lower hemisphere), so the floor ratio gap is not mostly this term: removing the whole bounce took `material-spheres` only from 2.01 to 1.51. Not kept; `baseline.json` is unchanged.++ Next idea: occlude per surface, not per scene: a sky and sun visibility lookup for the ground next to each caster, which needs a texture in the core shader and is a size cost; or darken only the floor-facing lower part of casters, which the shader would need a height above the floor for.diff --cc bench/size/budgets.jsonindex 03e5b24e,b486c6f1..f8305fe0--- a/bench/size/budgets.json+++ b/bench/size/budgets.json@@@ -34,21 -34,21 +34,21 @@@"entry:ground-bounce": 9460,"entry:path-tracer": 14600,"entry:texture-set": 900,- "entry:agent-scene": 77810,- "entry:agent-scene+lazy": 260280,- "entry:agent-asset": 109170,- "entry:agent-asset+lazy": 271680,+ "entry:agent-scene": 78530,- "entry:agent-scene+lazy": 260700,++ "entry:agent-scene+lazy": 261000,+ "entry:agent-asset": 109880,- "entry:agent-asset+lazy": 272100,++ "entry:agent-asset+lazy": 272400,"entry:hdri": 3300,"entry:camera-effects": 8600,- "entry:water-reflection": 26000,+ "entry:water-reflection": 26540,"entry:render-passes": 1700,- "entry:material-layer-shaders": 20700,- "entry:light-linking": 19000,- "entry:cascaded-shadows": 27730,- "scene:lit-box": 63360,- "scene:gltf-box": 84380,- "scene:gltf-box+lazy": 87710,- "scene:agent-scene": 105160,- "scene:agent-scene+lazy": 287630+ "entry:material-layer-shaders": 21360,+ "entry:light-linking": 19680,+ "entry:cascaded-shadows": 28480,+ "scene:lit-box": 64170,+ "scene:gltf-box": 85190,+ "scene:gltf-box+lazy": 88520,+ "scene:agent-scene": 105980,- "scene:agent-scene+lazy": 288160++ "scene:agent-scene+lazy": 288460}}