Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Merge origin/main

Nguyen Xuan An09cf818d1aa4
diff --cc bench/reference/README.md
index 6934f6fa,4a4e6990..58e2ea85
--- a/bench/reference/README.md
+++ b/bench/reference/README.md
@@@ -1205,21 -1233,31 +1233,50 @@@ The shadow floors move toward Cycles (m
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.
+## A sky visibility volume read by every surface, measured and not kept (2026-11-03, part of issue #197)
+
+Idea, from the two notes above: a scene-wide scalar can not darken shadowed floors without hurting lit ground, so scale the world light of each surface by how much sky its place sees. Change tried: `skyVisibilityGrid` (24 upward rays per cell, the grid of the fog) over the bounds of all parts at up to 16384 cells, uploaded once as an `R8` 3D texture; a registered shader feature (`surfaceSky`, off unless the renderer is given the option, so no core code for other scenes) multiplied `occlusion` by the lookup at `worldPosition + normal * half a cell`, skipping surfaces that carry baked sky visibility (`vertexSkyVisibility` below 1) or a light map, and scenes with morph targets (the volume took the morph texture's unit). Main at `763e7fe`, GPU, 960 x 540, FLIP against Cycles with the stored arrays; change from the committed `baseline.json` (all 23 scenes; `mountain-valley` and `character` do not change in any row).
+
+| Variant | Better than -0.002 | Worse than +0.002 | Worst |
+| --- | --- | --- | --- |
+| Strength 1, all normals | none | 21 of 23 | `long-street` +0.0804, `metal-room` +0.0631, `lit-interior` +0.0545, `temple-hall` +0.0119 |
+| Strength 0.5, all normals | `temple-hall` -0.0051, `fog-room` -0.0065, `brushed-film` -0.0039, `car-paint` -0.0025 | 12 | `metal-room` +0.0314, `lit-interior` +0.0268, `brick-room` +0.0264, `long-street` +0.0164 |
+| Strength 1, weighted by the upward share of the normal | `brick-flat` -0.0079, `brick-graph` -0.0083, `car-paint` -0.0038 | 14 | `long-street` +0.0373, `dark-shaft` +0.0177, `temple-hall` +0.0113, `metal-room` +0.0209 |
+| Strength 0.5, weighted by the upward share of the normal | `brick-flat` -0.0042, `brick-graph` -0.0044, `car-paint` -0.0054, `brushed-film` -0.0022, `material-spheres` -0.0026, `temple-hall` -0.0030 | 10 | `long-street` +0.0138, `metal-room` +0.0104, `brick-room` +0.0092, `lit-interior` +0.0080, `dark-shaft` +0.0073 |
+
+
+- The lookup is isotropic, a cell sees a whole sphere. Beside a wall about half of the upward rays hit the wall itself (inferred), so a surface that faces the wall is darkened by its own plane as well, which its cosine term already counts: strength 1 on all normals made `brick-flat` worse by 0.0323. Weighting by the upward share of the normal removes that (measured: `brick-flat` -0.0079) and turns the brick scenes and `car-paint` better, so the term is usable for floors only.
+- With floors only, the targets split. `temple-hall` improves at strength 0.5 (-0.0030) and worsens at 1 (+0.0113); `material-spheres` and `car-paint` improve at 0.5 (-0.0026, -0.0054); `long-street` worsens at every strength (+0.0138 at 0.5); `mountain-valley` does not change (its terrain carries baked sky visibility, which the term skips). Cause for the street (guessed, not isolated): the sun-lit street is under narrow sky as well, and the cells of a volume over a street that long are coarse.
+- Ten scenes fail the 0.002 limit at the best variant, so nothing is kept. Guess: the gap is light that comes back from the lit surfaces the blocked rays hit, which a visibility alone does not hold.
+- Not measured, because the change was reverted: the gzip bytes, the frame cost and the ray time at 16384 cells. One run with 100000 cells (to resolve the street) did not finish all 23 scenes in 10 minutes, so the ray build is the limit on a finer volume.
+
+Engine code reverted; `baseline.json` is unchanged. Next idea, if this is taken up again: sky visibility traced from the floor texels themselves (a 2D map of the floor, one value per texel, 64 or more rays) instead of a coarse volume.
++
+ ## Where the rest of `metal` sits, and a metal mirror in the probe trace, measured and not kept (2026-11-03, part of issue #167)
+
+ `bench/reference/region-errors.py <scene> [gpu|cpu]` splits the FLIP error map of a scene by what each pixel shows. It draws each part's triangles back to front with the scene's camera (the floor quad reaches behind the camera, so the floor is the uncovered pixels below the horizon), then prints share, mean error and luminance per region for 67js and EEVEE against Cycles. GPU render, same arrays as the baseline (67js 0.0944, EEVEE 0.0916); the shares of the error are of the error map's own total (its mean is 0.1053, a little above the 0.0944 of the scorer, so use the shares and not the absolute values):
+
+ | Region | Frame share | FLIP 67js | FLIP EEVEE | Share of 67js error | Display luminance 67js / Cycles / EEVEE |
+ | --- | --- | --- | --- | --- | --- |
+ | Floor, open | 0.632 | 0.0883 | 0.0745 | 53% | 0.677 / 0.679 / 0.677 |
+ | Chrome sphere | 0.059 | 0.2430 | 0.2056 | 13% | 0.654 / 0.627 / 0.629 |
+ | Gold torus | 0.053 | 0.2331 | 0.3045 | 12% | 0.633 / 0.646 / 0.601 |
+ | Copper cube | 0.060 | 0.2085 | 0.3082 | 12% | 0.611 / 0.638 / 0.571 |
+ | Steel cylinder | 0.029 | 0.2531 | 0.1894 | 7% | 0.556 / 0.573 / 0.544 |
+ | Sky | 0.161 | 0.0148 | 0.0098 | 2% | 0.860 / 0.860 / 0.860 |
+ | Floor front edge | 0.006 | 0.1200 | 0.0838 | 1% | 0.672 / 0.687 / 0.683 |
+
+ 67js already beats EEVEE on the gold torus (0.0124 against 0.0162 of the frame mean) and the copper cube (0.0125 against 0.0185). EEVEE leads on the open floor (0.0087 of the frame), the chrome sphere (0.0022), the steel cylinder (0.0019) and the sky (0.0008). The floor has the largest gap and no luminance gap (0.677 against 0.679), so what is left there is structure (the shadow shapes and the halo of bounced light around the parts), as #241 found. The steel cylinder is 0.017 too dark and the chrome sphere 0.027 too bright.
+
+ Change tried: in the probe trace, a hit on a metal part returns what that part mirrors toward the probe, times the metal's colour: the environment when the mirrored ray leaves the scene, else the direct and sky light of the part it meets (no further bounce). Either added to the diffuse term or in place of its metallic share. SwiftShader, `metal`, same Cycles arrays:
+
+ | Variant | FLIP | chrome / steel luminance | probe trace |
+ | --- | --- | --- | --- |
+ | Main | 0.0942 | 0.654 / 0.556 | 0.24 s |
+ | Mirror added, gain 1 | 0.0942 | 0.662 / 0.590 | 0.25 s |
+ | Mirror added, gain 0.4 | 0.0938 | 0.658 / not read | 0.25 s |
+ | Mirror replacing the metallic share of the diffuse term | 0.0953 | 0.654 / 0.559 | 0.25 s |
+
+ The best of them is 0.0004 better, which is inside what the choice of gain alone moves, and 0.0022 short of EEVEE. At gain 1 it overshoots the steel cylinder (0.556 to 0.590, Cycles 0.573) and brightens the chrome sphere, which is already too bright; the sphere's error is the structure of the reflection (the cloud pattern and the floor under its base), not its level. This agrees with the earlier "metal parts mirroring the sky too" row (0.0939). Not kept; no engine file, scene or `baseline.json` row changed, and the first box of #167 stays open: `metal` 0.0944 against EEVEE 0.0916. A scene without a reflective part never loads the trace, so its frame cost is as before.
+
+ Next idea: the open floor is more than half of the error and the largest gap, and a surface-level cause there needs a new input (light the metal parts reflect onto the floor, which a diffuse bounce leaves out), for example a few traced caustic-like patches stamped into the ground bounce.