Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Merge remote-tracking branch 'origin/main' into fix/flat-wall-bounce

Nguyen Xuan An4929a96b99a8
diff --cc bench/reference/README.md
index 833ba5c2,688482ff..c7df24a0
--- a/bench/reference/README.md
+++ b/bench/reference/README.md
@@@ -1056,26 -1056,18 +1056,43 @@@ Main reproduced `baseline.json` first o
- Change: for a mapped normal the ambient and reflected sky term is scaled by `0.5 + 0.5 * dot(mapped, geometric)`, the share of an even sky lobe that stays above the surface. `brick-graph` 0.1584 to 0.1518 (EEVEE 0.0875 to 0.0844, CPU the same); all 22 other scenes reproduce their rows to 4 digits (none uses a normal map). Excess over its flat wall: 67js 0.0320 to 0.0254, EEVEE 0.0122.
- Still open: the sun is not clipped against the surface plane (the wall faces the sun, so it changes nothing here), the colour gap on the brick faces (Cycles 0.524, EEVEE 0.476, 67js 0.466 in luminance), and a bump scale per world unit instead of per UV unit (Blender's Distance 0.15 is 0.025 per UV unit across and 0.0375 up on this 6 by 4 wall, the bake gives 0.031 both ways). Whether the condition of #50 can be met is still An's decision.
Bundle size: the two shader lines add 9 to 18 bytes gzip to eight bundles that carry the main fragment shader (ntry:core, ntry:agent-scene, ntry:agent-asset, ntry:cascaded-shadows, scene:lit-box, scene:gltf-box, scene:gltf-box+lazy, scene:agent-scene); their budgets rose by 20 to 30 bytes.
++
+## Ground bounce (2026-11-03, issue #244)
+
+Cause of the 10.7 percent gap on `brick-flat`, measured: light the ground bounces onto the wall. Main reproduced `baseline.json` first (GPU columns to 4 digits after a fresh render of every scene; `brick-flat` 0.1264, `brick-graph` 0.1518). Cycles of `brick-flat`, 256 samples, RTX 3060, mean display luminance over the wall (rows 110 to 430, columns 230 to 730; same tone map as 67js):
+
+| Cycles setting | wall luminance | linear |
+| --- | --- | --- |
+| normal (stored) | 0.6150 | 0.2389 |
+| floor painted black (`--floor-color 0`) | 0.5466 | 0.1854 |
+| light bounces limited to 0 (`--max-bounces 0`, sun and sky only) | 0.5370 | 0.1791 |
+| 67js before | 0.5558 | |
+
+The ground adds 0.0535 linear (22 percent of the wall's light) in Cycles. With bounces off, Cycles is 0.019 below 67js (display), so the sun units and colour, the sky irradiance on a vertical wall, Lambert against Principled diffuse and the tone map are not the cause: they leave 67js slightly bright, not dark. 67js showed the lower half of the sky HDRI to the wall, where Cycles has the floor.
+
+Fix: `withGroundBounce(map, { albedo, keyColor, lightDirection })` (`src/ground-bounce.js`, `67js/addons/ground-bounce`) replaces the lower half of the environment map with `albedo * (sun * max(l.y, 0) / pi + sky irradiance on a level surface)` once, when the scene is built. Nothing in the renderer or a shader changes, and a frame costs the same. The suite hands the brick scenes a map with the floor's colour `[0.4, 0.38, 0.32]`; Blender still gets the plain HDRI. Wall luminance 0.5558 to 0.6125 (Cycles 0.6149).
+
+| Scene (GPU, against Cycles) | before | after |
+| --- | --- | --- |
+| `brick-flat` | 0.1264 | 0.0636 |
+| `brick-graph` | 0.1518 | 0.1109 |
+
+Both are now closer to Cycles than EEVEE is (0.1098, 0.1221); against EEVEE they score 0.1117 and 0.1162 because EEVEE has no ground bounce on the wall. Every other scene is unchanged by construction: only `brickWallScene` calls the helper, and the full GPU run on main before the change gave the committed rows. Only these two scenes got the helper: the other scenes with a floor (`material-spheres`, `metal`, `character`, `outdoor-hdri` ...) were not tried, and their floors are not the infinite flat plane the term assumes. The floor's shadow under the wall is ignored, which is why a lower albedo is the way to correct a mostly shaded floor.
+
+`render-blender.py` gained `--max-bounces <n>` and `--floor-color <v>` (Cycles only, like `--world-strength`). Bundle size: `entry:ground-bounce` is new (2832 bytes gzip, budget 2850). `entry:core` measured 85952 on main with or without the new entry, so its budget rose by 5 bytes to 85955.
++
+ ## Bump scale per world unit and the brick-face colour (2026-11-03, part of issue #50)
+
+ Main reproduced `baseline.json` first on the stored arrays (`brick-flat` 0.1264, `brick-graph` 0.1518, EEVEE against Cycles 0.1099 and 0.1221, GPU). Nothing is kept and no engine file, baseline row or budget changed.
+
+ - Bump scale per world unit, tried and not kept. The baked map has a slope of `bump / 32` per UV unit; Blender's Bump node with Distance 0.15 has `0.15 * bump / L` per world length `L` of the UV axis, so the wall (6 across, 4 up) needs the existing `normalScale` uniform at `[4.8 / 6, 4.8 / 4]` = `[0.8, 1.2]` (a scale of the map's x and y leaves the slope ratio exact). `brick-graph` against Cycles goes 0.1518 to 0.1525 (worse), against EEVEE 0.0844 to 0.0840, CPU the same; `brick-flat` and `brick-room` are unchanged. The mean scale is still 1, and earlier measurements here show bump strength is not what separates the render from Cycles, so matching the anisotropy does not help. No shader or material field was added for it.
+ - Brick-face colour, measured: the gap is light, not the colour path. Mean luminance (display space, tone-mapped like 67js) over the wall, a uniform-colour wall (`brick-flat`) against the graph wall, by region found by projecting the wall back to UV:
+
+ | Renderer | flat wall | graph, brick faces (body over 0.95) | faces / flat | graph, mortar (under 0.05) | mortar / flat |
+ | --- | --- | --- | --- | --- | --- |
+ | Cycles | 0.6149 | 0.5236 | 0.852 | 0.7062 | 1.148 |
+ | EEVEE | 0.5600 | 0.4755 | 0.849 | 0.6610 | 1.180 |
+ | 67js | 0.5557 | 0.4657 | 0.838 | 0.6295 | 1.133 |
+
+ Cycles is 10.7% brighter than 67js and 9.8% brighter than EEVEE on the plain flat wall, with no texture at all, so most of the 0.524 against 0.466 on the brick faces (12.4%) is Cycles-only light, the same offset as in `brick-flat`'s score. Once the flat wall removes it, the face ratios are within 1.6% (0.852, 0.849, 0.838), which is the share the graph's colour path and noise statistics can own. Ramp stops and mix constants are linear on both sides (`element.color` in `render-blender.py` takes linear values and the bake writes `linearToSrgbByte`), the ramp is linear in both, and the Blender noise differs from the 67js one (stated in `render-blender.py`), so a 1.6% face offset cannot be traced further without a Blender run, which this pass did not have. Not changed.
+ - Excess of the graph wall over its flat wall, the number #50 asks for: 67js 0.1518 - 0.1264 = 0.0254, EEVEE 0.0122, unchanged.