3D engine that AI agents drive
Let a key shadow block the sun fully
Nguyen Xuan And59603289caf
diff --git a/bench/reference/README.md b/bench/reference/README.mdindex ecdcc56d..b6bf772d 100644--- a/bench/reference/README.md+++ b/bench/reference/README.md@@ -14,22 +14,29 @@ CI does not run this suite. `tests/reference-baseline.test.js` checks only thatThe HDRI holds its own sun: 6 of its 524,288 pixels carry 48.1 percent of the sky light, at 48 degrees of elevation. Most scenes also add a sun light. Cycles and EEVEE therefore drew two shadows of each object, and 67js drew one because its environment casts no shadow. `scenes.js` and `render-blender.py` now cap the image at radiance 16 on both sides, which removes the sun and its halo and keeps the clouds. The sky keeps 49.2 percent of its light. A scene with a sky now has only its own sun light.-`baseline.json` and `images/` use the cap. Scores measured before this date, including the tables and notes below, `khronos.json` and `path-tracer.json`, use the sky with two suns. Scenes with a constant world did not move. The current scores against Cycles:--| Scene | 67js before | 67js now | EEVEE now |-| --- | --- | --- | --- |-| `outdoor-hdri` | 0.0676 | 0.0466 | 0.0403 |-| `character` | 0.0995 | 0.0823 | 0.0622 |-| `glass` | 0.1326 | 0.1033 | 0.1009 |-| `car-paint` | 0.1521 | 0.1084 | 0.0844 |-| `brushed-film` | 0.1613 | 0.1172 | 0.0984 |-| `metal` | 0.1868 | 0.1309 | 0.0916 |-| `material-spheres` | 0.1598 | 0.1337 | 0.1053 |-| `foliage` | 0.1594 | 0.1346 | 0.0864 |-| `brick-flat` | 0.1999 | 0.1273 | 0.1098 |-| `brick-graph` | 0.2269 | 0.1604 | 0.1221 |--The mean over the 16 older scenes went from 0.2001 to 0.1751 for 67js. EEVEE is at 0.1645.+`baseline.json` and `images/` use the cap. Scores measured before this date, including the tables and notes below, `khronos.json` and `path-tracer.json`, use the sky with two suns. Scenes with a constant world did not move when the cap went in.++## No shadow floor (2026-11-01)++A key shadow in 67js kept 18 percent of the sun (`src/shaders.js`, `src/cascaded-shadows.js`). A sealed hall was evenly lit, and every shadow was too light. A key shadow now blocks the sun fully. `fog` (+0.0031) and `megacity-dusk` (+0.0044) got worse, and all other scenes stayed level or improved.++Scores against Cycles, with each change in turn:++| Scene | Two suns, floor | One sun, floor | One sun, no floor (now) | EEVEE now |+| --- | --- | --- | --- | --- |+| `outdoor-hdri` | 0.0676 | 0.0466 | 0.0462 | 0.0403 |+| `character` | 0.0995 | 0.0823 | 0.0799 | 0.0622 |+| `glass` | 0.1326 | 0.1033 | 0.1034 | 0.1009 |+| `car-paint` | 0.1521 | 0.1084 | 0.1059 | 0.0844 |+| `brushed-film` | 0.1613 | 0.1172 | 0.1149 | 0.0984 |+| `metal` | 0.1868 | 0.1309 | 0.1294 | 0.0916 |+| `material-spheres` | 0.1598 | 0.1337 | 0.1312 | 0.1053 |+| `foliage` | 0.1594 | 0.1346 | 0.1290 | 0.0864 |+| `brick-flat` | 0.1999 | 0.1273 | 0.1272 | 0.1098 |+| `brick-graph` | 0.2269 | 0.1604 | 0.1602 | 0.1221 |+| `long-street` | 0.1555 | 0.1555 | 0.1407 | 0.0976 |++The mean over the 16 older scenes went from 0.2001 to 0.1751 to 0.1732. EEVEE is at 0.1645.## Grand scenes (2026-11-01)@@ -37,13 +44,13 @@ Three scenes test what people want to make, not one feature. Each one is built w| Scene | Parts | Triangles drawn | 67js against Cycles | EEVEE against Cycles | Largest visible gap || --- | --- | --- | --- | --- | --- |-| `megacity-dusk` | 4,300 | 51.6 thousand | 0.1583 | 0.1524 | Window bands are sharper, and facades get no light from the windows |-| `mountain-valley` | 7,698 | 9.72 million | 0.3658 | 0.1828 | Trees are lighter from leaf translucency, and shadowed rock is brighter |-| `temple-hall` | 155 | 11 thousand | 0.5841 | 0.2341 | The sealed hall is evenly lit, while Cycles is nearly black |+| `megacity-dusk` | 4,300 | 51.6 thousand | 0.1627 | 0.1524 | Window bands are sharper, and facades get no light from the windows |+| `mountain-valley` | 7,698 | 9.72 million | 0.3473 | 0.1828 | Trees are lighter from leaf translucency, and shadowed rock is brighter |+| `temple-hall` | 155 | 11 thousand | 0.2126 | 0.2341 | The fog shafts are stronger in 67js, and the floor gets no bounce light |-A key shadow in 67js keeps 18 percent of the sun (`src/shaders.js`, `src/cascaded-shadows.js`), and that causes the `temple-hall` gap. A trial with no such floor scored 0.2126 on `temple-hall` and 0.3473 on `mountain-valley`. The mean over the 19 scenes moved from 0.2058 to 0.1839. `fog` (+0.0031) and `megacity-dusk` (+0.0044) got worse. The floor stays in the engine for now, because removing it changes the look of existing scenes.+With the shadow floor `temple-hall` scored 0.5841, `mountain-valley` 0.3658 and `megacity-dusk` 0.1583.-`temple-hall` sets its own `bakeOptions`. The defaults need 1.4 million texels, and the bake allows 1 million. With the options the bake scored 0.5913, worse than 0.5841 without it, because the shadow floor already over-lights the hall.+`temple-hall` sets its own `bakeOptions`. The defaults need 1.4 million texels, and the bake allows 1 million. With the options the bake scores 0.2239, against 0.2126 without it.## Baselinediff --git a/bench/reference/baseline.json b/bench/reference/baseline.jsonindex acaa7fb2..b562f4fd 100644--- a/bench/reference/baseline.json+++ b/bench/reference/baseline.json@@ -85,18 +85,18 @@},"scores": {"brick-flat": {- "gpu-vs-cycles": 0.1273,- "gpu-vs-eevee": 0.0463,+ "gpu-vs-cycles": 0.1272,+ "gpu-vs-eevee": 0.0462,"cpu-vs-cycles": 0.1269,- "cpu-vs-eevee": 0.0459,+ "cpu-vs-eevee": 0.0458,"eevee-vs-cycles": 0.1098,"gpu-vs-cpu": 0.0066},"brick-graph": {- "gpu-vs-cycles": 0.1604,- "gpu-vs-eevee": 0.0901,- "cpu-vs-cycles": 0.1605,- "cpu-vs-eevee": 0.0902,+ "gpu-vs-cycles": 0.1602,+ "gpu-vs-eevee": 0.0896,+ "cpu-vs-cycles": 0.1602,+ "cpu-vs-eevee": 0.0897,"eevee-vs-cycles": 0.1221,"gpu-vs-cpu": 0.0078},@@ -109,52 +109,52 @@"gpu-vs-cpu": 0.0071},"brushed-film": {- "gpu-vs-cycles": 0.1172,- "gpu-vs-eevee": 0.1033,- "cpu-vs-cycles": 0.1169,- "cpu-vs-eevee": 0.1033,+ "gpu-vs-cycles": 0.1149,+ "gpu-vs-eevee": 0.1004,+ "cpu-vs-cycles": 0.1146,+ "cpu-vs-eevee": 0.1004,"eevee-vs-cycles": 0.0984,- "gpu-vs-cpu": 0.0062+ "gpu-vs-cpu": 0.0061},"car-paint": {- "gpu-vs-cycles": 0.1084,- "gpu-vs-eevee": 0.0709,- "cpu-vs-cycles": 0.1081,- "cpu-vs-eevee": 0.0709,+ "gpu-vs-cycles": 0.1059,+ "gpu-vs-eevee": 0.0679,+ "cpu-vs-cycles": 0.1056,+ "cpu-vs-eevee": 0.0679,"eevee-vs-cycles": 0.0844,"gpu-vs-cpu": 0.0059},"character": {- "gpu-vs-cycles": 0.0823,- "gpu-vs-eevee": 0.0638,- "cpu-vs-cycles": 0.082,- "cpu-vs-eevee": 0.0637,+ "gpu-vs-cycles": 0.0799,+ "gpu-vs-eevee": 0.0553,+ "cpu-vs-cycles": 0.0796,+ "cpu-vs-eevee": 0.0552,"eevee-vs-cycles": 0.0622,- "gpu-vs-cpu": 0.0064+ "gpu-vs-cpu": 0.0066},"fog": {- "gpu-vs-cycles": 0.2612,- "gpu-vs-eevee": 0.0542,- "cpu-vs-cycles": 0.2608,- "cpu-vs-eevee": 0.0542,+ "gpu-vs-cycles": 0.2643,+ "gpu-vs-eevee": 0.053,+ "cpu-vs-cycles": 0.2639,+ "cpu-vs-eevee": 0.053,"eevee-vs-cycles": 0.2662,"gpu-vs-cpu": 0.0085},"foliage": {- "gpu-vs-cycles": 0.1346,- "gpu-vs-eevee": 0.0956,- "cpu-vs-cycles": 0.1343,- "cpu-vs-eevee": 0.0953,+ "gpu-vs-cycles": 0.129,+ "gpu-vs-eevee": 0.091,+ "cpu-vs-cycles": 0.1287,+ "cpu-vs-eevee": 0.0906,"eevee-vs-cycles": 0.0864,- "gpu-vs-cpu": 0.0099+ "gpu-vs-cpu": 0.01},"glass": {- "gpu-vs-cycles": 0.1033,- "gpu-vs-eevee": 0.1027,- "cpu-vs-cycles": 0.1033,- "cpu-vs-eevee": 0.1031,+ "gpu-vs-cycles": 0.1034,+ "gpu-vs-eevee": 0.0996,+ "cpu-vs-cycles": 0.1034,+ "cpu-vs-eevee": 0.1,"eevee-vs-cycles": 0.1009,- "gpu-vs-cpu": 0.0082+ "gpu-vs-cpu": 0.0083},"light-linking": {"gpu-vs-cycles": 0.0998,@@ -173,50 +173,50 @@"gpu-vs-cpu": 0.0062},"long-street": {- "gpu-vs-cycles": 0.1555,- "gpu-vs-eevee": 0.1396,- "cpu-vs-cycles": 0.1554,- "cpu-vs-eevee": 0.1396,+ "gpu-vs-cycles": 0.1407,+ "gpu-vs-eevee": 0.1252,+ "cpu-vs-cycles": 0.1408,+ "cpu-vs-eevee": 0.1254,"eevee-vs-cycles": 0.0976,- "gpu-vs-cpu": 0.0098+ "gpu-vs-cpu": 0.0095},"material-spheres": {- "gpu-vs-cycles": 0.1337,- "gpu-vs-eevee": 0.0797,- "cpu-vs-cycles": 0.1335,- "cpu-vs-eevee": 0.0795,+ "gpu-vs-cycles": 0.1312,+ "gpu-vs-eevee": 0.0748,+ "cpu-vs-cycles": 0.131,+ "cpu-vs-eevee": 0.0745,"eevee-vs-cycles": 0.1053,- "gpu-vs-cpu": 0.0069+ "gpu-vs-cpu": 0.007},"megacity-dusk": {- "gpu-vs-cycles": 0.1583,- "gpu-vs-eevee": 0.1173,- "cpu-vs-cycles": 0.1589,- "cpu-vs-eevee": 0.1211,+ "gpu-vs-cycles": 0.1627,+ "gpu-vs-eevee": 0.1022,+ "cpu-vs-cycles": 0.162,+ "cpu-vs-eevee": 0.1061,"eevee-vs-cycles": 0.1524,- "gpu-vs-cpu": 0.0277+ "gpu-vs-cpu": 0.0281},"metal": {- "gpu-vs-cycles": 0.1309,- "gpu-vs-eevee": 0.0977,- "cpu-vs-cycles": 0.1306,- "cpu-vs-eevee": 0.0978,+ "gpu-vs-cycles": 0.1294,+ "gpu-vs-eevee": 0.0952,+ "cpu-vs-cycles": 0.1291,+ "cpu-vs-eevee": 0.0953,"eevee-vs-cycles": 0.0916,"gpu-vs-cpu": 0.0067},"mountain-valley": {- "gpu-vs-cycles": 0.3658,- "gpu-vs-eevee": 0.2698,- "cpu-vs-cycles": 0.3644,- "cpu-vs-eevee": 0.2683,+ "gpu-vs-cycles": 0.3473,+ "gpu-vs-eevee": 0.242,+ "cpu-vs-cycles": 0.346,+ "cpu-vs-eevee": 0.2406,"eevee-vs-cycles": 0.1828,- "gpu-vs-cpu": 0.0196+ "gpu-vs-cpu": 0.02},"outdoor-hdri": {- "gpu-vs-cycles": 0.0466,- "gpu-vs-eevee": 0.0301,- "cpu-vs-cycles": 0.046,- "cpu-vs-eevee": 0.0298,+ "gpu-vs-cycles": 0.0462,+ "gpu-vs-eevee": 0.0296,+ "cpu-vs-cycles": 0.0456,+ "cpu-vs-eevee": 0.0293,"eevee-vs-cycles": 0.0403,"gpu-vs-cpu": 0.0065},@@ -229,12 +229,12 @@"gpu-vs-cpu": 0.0032},"temple-hall": {- "gpu-vs-cycles": 0.5841,- "gpu-vs-eevee": 0.4789,- "cpu-vs-cycles": 0.5843,- "cpu-vs-eevee": 0.479,+ "gpu-vs-cycles": 0.2126,+ "gpu-vs-eevee": 0.0803,+ "cpu-vs-cycles": 0.2128,+ "cpu-vs-eevee": 0.0804,"eevee-vs-cycles": 0.2341,- "gpu-vs-cpu": 0.0051+ "gpu-vs-cpu": 0.0025}}}diff --git a/bench/reference/images/brick-flat.jpg b/bench/reference/images/brick-flat.jpgindex 2fdbb73d..4e1e0636 100644Binary files a/bench/reference/images/brick-flat.jpg and b/bench/reference/images/brick-flat.jpg differdiff --git a/bench/reference/images/brick-graph.jpg b/bench/reference/images/brick-graph.jpgindex 27254526..64f482be 100644Binary files a/bench/reference/images/brick-graph.jpg and b/bench/reference/images/brick-graph.jpg differdiff --git a/bench/reference/images/brushed-film.jpg b/bench/reference/images/brushed-film.jpgindex 6a530a6b..1d518448 100644Binary files a/bench/reference/images/brushed-film.jpg and b/bench/reference/images/brushed-film.jpg differdiff --git a/bench/reference/images/car-paint.jpg b/bench/reference/images/car-paint.jpgindex dd01d6c9..ccf683a4 100644Binary files a/bench/reference/images/car-paint.jpg and b/bench/reference/images/car-paint.jpg differdiff --git a/bench/reference/images/character.jpg b/bench/reference/images/character.jpgindex 51ed9d78..b4b124c6 100644Binary files a/bench/reference/images/character.jpg and b/bench/reference/images/character.jpg differdiff --git a/bench/reference/images/fog.jpg b/bench/reference/images/fog.jpgindex 54a2a6e2..ec6f6d3d 100644Binary files a/bench/reference/images/fog.jpg and b/bench/reference/images/fog.jpg differdiff --git a/bench/reference/images/foliage.jpg b/bench/reference/images/foliage.jpgindex bffcf9b9..cc324d18 100644Binary files a/bench/reference/images/foliage.jpg and b/bench/reference/images/foliage.jpg differdiff --git a/bench/reference/images/glass.jpg b/bench/reference/images/glass.jpgindex 9e33e119..8b695191 100644Binary files a/bench/reference/images/glass.jpg and b/bench/reference/images/glass.jpg differdiff --git a/bench/reference/images/long-street.jpg b/bench/reference/images/long-street.jpgindex d3acb17b..4c687e95 100644Binary files a/bench/reference/images/long-street.jpg and b/bench/reference/images/long-street.jpg differdiff --git a/bench/reference/images/material-spheres.jpg b/bench/reference/images/material-spheres.jpgindex 10f4df89..58400c5f 100644Binary files a/bench/reference/images/material-spheres.jpg and b/bench/reference/images/material-spheres.jpg differdiff --git a/bench/reference/images/megacity-dusk.jpg b/bench/reference/images/megacity-dusk.jpgindex 2d906bc9..649ee1f8 100644Binary files a/bench/reference/images/megacity-dusk.jpg and b/bench/reference/images/megacity-dusk.jpg differdiff --git a/bench/reference/images/metal.jpg b/bench/reference/images/metal.jpgindex 782463fb..c5770a51 100644Binary files a/bench/reference/images/metal.jpg and b/bench/reference/images/metal.jpg differdiff --git a/bench/reference/images/mountain-valley.jpg b/bench/reference/images/mountain-valley.jpgindex 45a7679d..741b0a78 100644Binary files a/bench/reference/images/mountain-valley.jpg and b/bench/reference/images/mountain-valley.jpg differdiff --git a/bench/reference/images/outdoor-hdri.jpg b/bench/reference/images/outdoor-hdri.jpgindex 8f3f5443..3461a36f 100644Binary files a/bench/reference/images/outdoor-hdri.jpg and b/bench/reference/images/outdoor-hdri.jpg differdiff --git a/bench/reference/images/temple-hall.jpg b/bench/reference/images/temple-hall.jpgindex 7ca63540..462e7f74 100644Binary files a/bench/reference/images/temple-hall.jpg and b/bench/reference/images/temple-hall.jpg differdiff --git a/src/cascaded-shadows.js b/src/cascaded-shadows.jsindex aac50454..0ea0541c 100644--- a/src/cascaded-shadows.js+++ b/src/cascaded-shadows.js@@ -54,7 +54,7 @@ float cascadeLayerVisibility(int layer, vec3 normal) {float visibility = 0.0;for (int row = -1; row <= 1; row++) {for (int column = -1; column <= 1; column++) {- visibility += mix(0.18, 1.0, cascadeTap(layer, projected.xy + vec2(column, row) * texel * 2.5, projected.z - bias, dimensions));+ visibility += cascadeTap(layer, projected.xy + vec2(column, row) * texel * 2.5, projected.z - bias, dimensions);}}return visibility / 9.0;diff --git a/src/shaders.js b/src/shaders.jsindex 5bdbadf0..a59c37dd 100644--- a/src/shaders.js+++ b/src/shaders.js@@ -487,7 +487,7 @@ float shadowVisibility(vec3 normal) {for (int row = -1; row <= 1; row++) {for (int column = -1; column <= 1; column++) {float comparison = filteredShadow(projected.xy + vec2(column, row) * texel * 2.5, projected.z - bias, dimensions);- visibility += mix(0.18, 1.0, comparison);+ visibility += comparison;}}return visibility / 9.0;