Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Merge origin/main

Nguyen Xuan An7b2d675d6c8b
diff --cc bench/reference/README.md
index f4948a1c,9e3e63a7..e020b20f
--- a/bench/reference/README.md
+++ b/bench/reference/README.md
@@@ -1782,33 -1782,19 +1782,50 @@@ What was measured
What would close it is a finer height-to-normal source than a 512 texel map (an analytic or 1024 texel bake of a graph that fits the work limit), which is engine work and costs memory or bytes; it is outside the data-only brief and the size goals. `brick-graph` is 0.0734 against Cycles, 0.1249 for EEVEE against Cycles on the same scene, so 67js is closer to Cycles than EEVEE is on this wall.
+## Sky seen from the floor, on by default for sunlit closed rooms (2026-11-04, part of issue #197)
+
+The opt-in trace above helped halls and studio floors and hurt streets, cities and rooms lit by lamps alone. The split is by what lights the scene, not by geometry: the mean traced visibility of the floor did not separate them (`temple-hall` 0.45, `dark-shaft` 0.54, but also `lit-interior` 0.55, `metal-room` 0.49 and `brick-room` 0.26, measured at strength 1). The rule that does separate them: a closed room (the ray test of the ground bounce) that a sun lights. `applyFloorSkyVisibility(parts, { onlyClosedRooms: true })` traces only closed rooms, at `FLOOR_SKY_ROOM_STRENGTH` 0.2, and returns open scenes unchanged (`report.reason` `open scene`). `applyDefaultFloorSky(parts, environment)` adds the sun test and the opt-out, and it is what `createAgentScene` calls for every recipe that names its sun (the module loads lazily, `environment.floorSkyTrace: false` opts out, see `docs/agent-look.md`). The harness calls the same function with the scene's environment and sets nothing of its own, so a recipe and the reference scene get the same frame; `--no-floor-sky` sets the opt-out on every scene, and `--floor-sky <strength>` is an experiment that traces every floor. Nothing in core; `report.meanVisibility` is new.
+
+GPU, 960 x 540, FLIP against the stored Cycles arrays, change from a render of main on the same machine (24 scenes and the 9 grand options; a scene not listed changed by less than 0.002, and all open scenes and lamp-only rooms are identical by construction):
+
+| Strength | `temple-hall` | `temple-hall-a` | `-b` | `-c` | `dark-shaft` | any other scene |
+| --- | --- | --- | --- | --- | --- | --- |
+| 1 | +0.0113 | -0.0085 | -0.0080 | -0.0285 | +0.0176 | `foliage` +0.0068 |
+| 0.5 | -0.0030 | -0.0106 | -0.0209 | -0.0161 | +0.0073 | none past 0.002 |
+| 0.25 | -0.0032 | -0.0063 | -0.0116 | -0.0079 | +0.0025 | none past 0.002 |
+| 0.2 (kept) | -0.0023 | -0.0051 | -0.0096 | -0.0061 | +0.0017 | none past 0.002 |
+
+0.2 is the largest strength that keeps `dark-shaft` within the 0.002 limit; the shaft's walls and floor get sun bounce in Cycles that a sky trace does not hold, so the shaft is the scene that sets the strength (guessed, not isolated).
+
+Box 2, dark end (`shadow-depth.py`, display luminance, 67js before > after / Cycles):
+
+| Scene | p1 | p5 | p25 | contrast (log2) |
+| --- | --- | --- | --- | --- |
+| `dark-shaft` | 0.0437 > 0.0389 / 0.0293 | 0.0437 > 0.0400 / 0.0313 | 0.0468 > 0.0437 / 0.0430 | 2.46 > 2.48 / 1.96 |
+| `temple-hall` | 0.0246 > 0.0207 / 0.0200 | 0.0246 > 0.0235 / 0.0221 | 0.0389 > 0.0350 / 0.0282 | 1.74 > 1.74 / 1.80 |
+| `temple-hall-a` | 0.0487 > 0.0451 / 0.0334 | 0.0557 > 0.0555 / 0.0363 | 0.0669 > 0.0630 / 0.0466 | 1.16 > 1.17 / 1.33 |
+| `temple-hall-b` | 0.0709 > 0.0709 / 0.0339 | 0.0717 > 0.0717 / 0.0370 | 0.0787 > 0.0751 / 0.0449 | 0.78 > 0.77 / 1.80 |
+| `temple-hall-c` | 0.0386 > 0.0338 / 0.0163 | 0.0394 > 0.0347 / 0.0184 | 0.0552 > 0.0515 / 0.0222 | 1.33 > 1.33 / 2.02 |
+
+The dark percentiles move toward Cycles in every row but by small steps (p1 by 0.000 to 0.005, p25 by 0.003 to 0.004; `temple-hall` p1 is now within 0.0007 of Cycles). The lit to shadow contrast does not move (at most 0.02 log2 step), as the opt-in section said: a sky term lowers lit and shadowed tiles together. `temple-hall-b` p1 and p5 do not move because its darkest pixels are lit by its lamps, not by the sky. The contrast gap needs a deeper sun shadow, not sky light, and is still open.
+
+Cost, measured on a loaded machine (another heavy job ran beside, so read these as ranges; `frame-time.mjs --plain`, one run each): `temple-hall` 1.83 ms without and 2.23 ms with, `dark-shaft` 2.38 ms without and 2.11 ms with. The trace takes 1.2 s and 0.6 s when the scene is prepared. Size: `entry:floor-sky-visibility` +202 bytes gzip, `scene:agent-scene` +448 (102996 to 103444, a goal scene, over its goal of 100000), `scene:agent-scene+lazy` +3836, `scene:lit-box` 0.
+
+Rows refreshed: `temple-hall` and `dark-shaft` in `baseline.json` (with their sheet images) and the three temple options in `grand.json`, from a Blender 5.2.2 rerun of just those scenes with the final code. The other rows, and `long-street` and `megacity-dusk-a`, which render identically, are left as they were.
++
+ ## Water shadows against Cycles (2026-11-04, closes the last box of issue #349)
+
+ `node scripts/score-water-shadows.mjs` draws the pool of the section above from overhead in 67js (480 x 270, 40 degree view) and in Blender 5.2 Cycles (CPU, 6 threads, 96 samples, denoised): the water is a box with Volume Absorption (`1 - absorption / density` as colour, so the coefficient is the preset's per metre) plus Volume Scatter (density = the preset's turbidity per metre, an assumed mapping, since turbidity has no physical unit). The sky and sun in Cycles are set from the dry bed 67js measured (sky = shadowed bed / albedo, sun from the lit minus shadowed difference), so a dry pool is the same exposure in both. `bench/reference/water-shadows-cycles.py` builds it and `bench/reference/water-shadows-score.py` scores it.
+
+ Whole frame FLIP of 67js against Cycles (Cycles tone mapped like 67js), and the bed shadow contrast (lit minus shadowed against the same pool dry; red, green, blue):
+
+ | Pool | FLIP | FLIP, same pool dry | 67js | Cycles | `exp(-absorption * depth)` |
+ | --- | --- | --- | --- | --- | --- |
+ | lake 0.2 m | 0.3027 | 0.3358 | 0.939, 0.970, 0.999 | 0.858, 0.964, 0.979 | 0.932, 0.986, 0.992 |
+ | lake 1 m | 0.4530 | 0.3735 | 0.699, 0.918, 0.937 | 0.463, 0.842, 0.901 | 0.705, 0.932, 0.961 |
+ | lake 4 m | 0.5628 | 0.4834 | 0.227, 0.694, 0.788 | 0.064, 0.527, 0.679 | 0.247, 0.756, 0.852 |
+ | river 0.2 m | 0.4654 | 0.3358 | 0.734, 0.720, 0.631 | 0.710, 0.682, 0.513 | 0.852, 0.835, 0.726 |
+ | river 1 m | 0.5890 | 0.3735 | 0.206, 0.179, 0.089 | 0.294, 0.276, 0.166 | 0.449, 0.407, 0.202 |
+ | river 4 m | 0.5408 | 0.4834 | -0.042, -0.036, -0.035 | 0.254, 0.247, 0.159 | 0.041, 0.027, 0.002 |
+
+ Reading it: the FLIP of the dry pool is already 0.34 to 0.48, so most of the score is the dry pool (the bed, the post, the sun's penumbra and the sky are not the same picture in the two renderers), and water adds 0.0 to 0.2 on top. The shadow contrast agrees in trend. Cycles fades the clear lake faster than the formula because the sun's path to the bed is longer than the eye's (slant of 1/cos 59 degrees), which `exp(-absorption * depth)` does not count: the shadow difference is lit (two paths) against shadowed (the eye's path only). The murky river is where the two differ most: Cycles keeps 0.25 of the contrast at 4 m, where scattered light still reaches the shadow, and 67js reaches zero (slightly negative, -0.04: the lift overshoots the lit side). A river that clears to nothing at 4 m is a known simplification of the in-scatter lift; it is recorded here and not changed.