Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Draw the reference frames without wind

Nguyen Xuan Ana80b15f6bb51
diff --git a/bench/reference/README.md b/bench/reference/README.md
index 91ce5ffc..28e4333d 100644
--- a/bench/reference/README.md
+++ b/bench/reference/README.md
@@ -1430,3 +1430,42 @@ The second option was tried: for alpha-mask materials only, the base map got its
| EEVEE against Cycles | 0.0924 | 0.0924 |
Worse by 0.0002 against Cycles, so the default suite and `--grand` were not run and the code was reverted. Reading (inferred): the lost coverage is at full-size edges, not at coarse mips, since the crown is seen at about one texel per pixel; keeping more coverage in the coarse levels cannot reach it. Same direction as the one mip finer attempt (0.0979 to 0.0982). Next idea: match Cycles' edge softness at level 0 (a slightly blurred alpha, or the leaf alpha edge drawn with a ramp wider than a texel) instead of changing the mips.
+
+## The reference harness drew `foliage` in a breeze (2026-11-03, part of issue #191)
+
+Found by comparing the leaf cards of the two sides. No engine code changed and no Blender render changed: the Cycles and EEVEE arrays are the ones of the earlier runs.
+
+| Property | 67js (scene JSON) | Blender (`render-blender.py`) | Same |
+| --- | --- | --- | --- |
+| Cards | 558 in one geometry, 2,232 vertices, UVs 0 to 1 | the same arrays, `build_mesh` | yes |
+| Transform | identity part matrix, Y-up to Z-up | `Y_UP_TO_Z_UP @ matrix` | yes |
+| Winding / back faces | `doubleSided: true`, no culling | Principled has no culling, back face keeps the stored normal | yes |
+| UV orientation | v as stored | image rows reversed and v flipped, net data row = v * height | yes |
+| Alpha mode, cutoff | `mask`, 0.5 | `GREATER_THAN` 0.5 on the texture alpha, then a transparent mix | yes |
+| Filtering | linear, trilinear mips | linear, no mips (Cycles) | differs by design (tried in #191, not kept) |
+| Wrap | clamp | repeat, but the card texture has alpha 0 on all four edges | no effect |
+| Leaf texture | 128 by 128, 22.5 percent of texels above 127 | the same pixels | yes |
+| Wind | renderer default `wind: 0.3` at `time: 0` | a still scene | **no** |
+
+The last row is the mismatch. The foliage vertex shader (`windOffset` in `src/shaders.js`) sways and flutters the cards even at time 0, up to 0.14 m of sway and 0.02 m of flutter at strength 0.3. At the camera distance of 12 m a pixel is 0.016 m, so crown cards were drawn up to about 4 px away from where Blender draws them (the shadow pass moves with them). `harness.js` built its frame without `wind`, so every vegetation scene paid for it.
+
+Measured with a CPU rasteriser of the cards (Python, bilinear alpha above 0.5 at mip 0, 4 by 4 samples per pixel, bark as occluder), over the crown rows of the 960 by 540 frame; mismatch is pixels whose "sky or not" differs between that mask and each render:
+
+| Render | Mismatch before | Best shift of the mask before | Mismatch with `wind: 0` |
+| --- | --- | --- | --- |
+| EEVEE | 1,036 | none | n/a |
+| Cycles | 2,523 | none | n/a |
+| 67js (GPU) | 3,228 | 1.5 px right, 0.5 px down (2,558) | 1,607 |
+| 67js (CPU) | 3,178 | 1.5 px right, 0.5 px down (2,492) | 1,493 |
+
+Fix: `harness.js` renders the reference frame with `wind: 0`. Re-run with 67js only (`--skip-blender`, GPU lock), then `--score-only`; only scenes with leaf cards moved. FLIP against Cycles (GPU), before to after:
+
+| Scene | 67js against Cycles | 67js against EEVEE | EEVEE against Cycles |
+| --- | --- | --- | --- |
+| foliage | 0.0979 to 0.0838 | 0.0771 to 0.0613 | 0.0924 |
+| mountain-valley | 0.1769 to 0.1691 | 0.2668 to 0.2613 | 0.1895 |
+| mountain-valley-a (grand) | 0.1671 to 0.1653 | 0.2392 to 0.2373 | 0.176 |
+| mountain-valley-b (grand) | 0.2096 to 0.2019 | 0.2645 to 0.2567 | 0.1306 |
+| mountain-valley-c (grand) | 0.1836 to 0.1775 | 0.223 to 0.2182 | 0.1522 |
+
+`foliage` now sits 0.0086 under EEVEE against Cycles (was 0.0055 over). Every other default and grand scene has no leaf cards and was not re-rendered; the only score that rose is a GPU against CPU difference (`gpu-vs-cpu` of `foliage` 0.0095 to 0.0097, `mountain-valley-b` 0.0158 to 0.0164). The Cycles and EEVEE columns did not move, so this is a change on the 67js side of the comparison and not a new reference. The score no longer includes the wind, which a real scene still has by default (`wind` 0.3); that is by design and is not scored here.
diff --git a/bench/reference/baseline.json b/bench/reference/baseline.json
index 8bbc6787..13d95e68 100644
--- a/bench/reference/baseline.json
+++ b/bench/reference/baseline.json
@@ -189,12 +189,12 @@
"gpu-vs-cpu": 0.0114
},
"foliage": {
- "gpu-vs-cycles": 0.0979,
- "gpu-vs-eevee": 0.0771,
- "cpu-vs-cycles": 0.0976,
- "cpu-vs-eevee": 0.0753,
+ "gpu-vs-cycles": 0.0838,
+ "gpu-vs-eevee": 0.0613,
+ "cpu-vs-cycles": 0.0833,
+ "cpu-vs-eevee": 0.0594,
"eevee-vs-cycles": 0.0924,
- "gpu-vs-cpu": 0.0095
+ "gpu-vs-cpu": 0.0097
},
"glass": {
"gpu-vs-cycles": 0.0913,
@@ -261,12 +261,12 @@
"gpu-vs-cpu": 0.0062
},
"mountain-valley": {
- "gpu-vs-cycles": 0.1769,
- "gpu-vs-eevee": 0.2668,
- "cpu-vs-cycles": 0.1743,
- "cpu-vs-eevee": 0.2651,
+ "gpu-vs-cycles": 0.1691,
+ "gpu-vs-eevee": 0.2613,
+ "cpu-vs-cycles": 0.1685,
+ "cpu-vs-eevee": 0.2612,
"eevee-vs-cycles": 0.1895,
- "gpu-vs-cpu": 0.0124
+ "gpu-vs-cpu": 0.0114
},
"outdoor-hdri": {
"gpu-vs-cycles": 0.0333,
diff --git a/bench/reference/grand.json b/bench/reference/grand.json
index ce3a615a..af7fe426 100644
--- a/bench/reference/grand.json
+++ b/bench/reference/grand.json
@@ -69,28 +69,28 @@
"gpu-vs-cpu": 0.0424
},
"mountain-valley-a": {
- "gpu-vs-cycles": 0.1671,
- "gpu-vs-eevee": 0.2392,
- "cpu-vs-cycles": 0.1671,
- "cpu-vs-eevee": 0.2389,
+ "gpu-vs-cycles": 0.1653,
+ "gpu-vs-eevee": 0.2373,
+ "cpu-vs-cycles": 0.1653,
+ "cpu-vs-eevee": 0.2371,
"eevee-vs-cycles": 0.176,
- "gpu-vs-cpu": 0.0088
+ "gpu-vs-cpu": 0.0092
},
"mountain-valley-b": {
- "gpu-vs-cycles": 0.2096,
- "gpu-vs-eevee": 0.2645,
- "cpu-vs-cycles": 0.2088,
- "cpu-vs-eevee": 0.2638,
+ "gpu-vs-cycles": 0.2019,
+ "gpu-vs-eevee": 0.2567,
+ "cpu-vs-cycles": 0.202,
+ "cpu-vs-eevee": 0.2567,
"eevee-vs-cycles": 0.1306,
- "gpu-vs-cpu": 0.0158
+ "gpu-vs-cpu": 0.0164
},
"mountain-valley-c": {
- "gpu-vs-cycles": 0.1836,
- "gpu-vs-eevee": 0.223,
- "cpu-vs-cycles": 0.1819,
- "cpu-vs-eevee": 0.2215,
+ "gpu-vs-cycles": 0.1775,
+ "gpu-vs-eevee": 0.2182,
+ "cpu-vs-cycles": 0.1767,
+ "cpu-vs-eevee": 0.217,
"eevee-vs-cycles": 0.1522,
- "gpu-vs-cpu": 0.0156
+ "gpu-vs-cpu": 0.0154
},
"temple-hall-a": {
"gpu-vs-cycles": 0.1642,
diff --git a/bench/reference/harness.js b/bench/reference/harness.js
index ba3cb561..fcc1b409 100644
--- a/bench/reference/harness.js
+++ b/bench/reference/harness.js
@@ -186,7 +186,8 @@ async function renderReferenceScene(id, { describe, ambientOcclusion = 0, ambien
// backgroundOnly draws the sky alone, so a score can be limited to the pixels the asset covers.
const renderer = createSceneRenderer(backgroundOnly ? [] : probed ? probed.parts : baked ? baked.parts : scene.parts, scene, cascades);
renderer.resize();
- const frame = { ...scene.camera, environment: scene.environment, time: 0, exposure: 1, effects: { ambientOcclusion, ambientOcclusionRadius } };
+ // Blender draws a still scene. The renderer's default wind (0.3) would move the leaf cards by up to four pixels at time 0.
+ const frame = { ...scene.camera, environment: scene.environment, time: 0, wind: 0, exposure: 1, effects: { ambientOcclusion, ambientOcclusionRadius } };
renderer.render(frame);
renderer.render(frame);
const debug = renderer.context.getExtension('WEBGL_debug_renderer_info');
diff --git a/bench/reference/images/foliage.jpg b/bench/reference/images/foliage.jpg
index 72b8c477..96f97fa3 100644
Binary files a/bench/reference/images/foliage.jpg and b/bench/reference/images/foliage.jpg differ
diff --git a/bench/reference/images/grand-mountain-valley-a.jpg b/bench/reference/images/grand-mountain-valley-a.jpg
index a7cccf55..aea20995 100644
Binary files a/bench/reference/images/grand-mountain-valley-a.jpg and b/bench/reference/images/grand-mountain-valley-a.jpg differ
diff --git a/bench/reference/images/grand-mountain-valley-b.jpg b/bench/reference/images/grand-mountain-valley-b.jpg
index e9a1c00c..3cfb2fcf 100644
Binary files a/bench/reference/images/grand-mountain-valley-b.jpg and b/bench/reference/images/grand-mountain-valley-b.jpg differ
diff --git a/bench/reference/images/grand-mountain-valley-c.jpg b/bench/reference/images/grand-mountain-valley-c.jpg
index 2d976e1b..1c82fc87 100644
Binary files a/bench/reference/images/grand-mountain-valley-c.jpg and b/bench/reference/images/grand-mountain-valley-c.jpg differ
diff --git a/bench/reference/images/mountain-valley.jpg b/bench/reference/images/mountain-valley.jpg
index ec501a29..fc12ef8a 100644
Binary files a/bench/reference/images/mountain-valley.jpg and b/bench/reference/images/mountain-valley.jpg differ
diff --git a/changes/191-leaf-cards.md b/changes/191-leaf-cards.md
new file mode 100644
index 00000000..d9f5fee5
--- /dev/null
+++ b/changes/191-leaf-cards.md
@@ -0,0 +1 @@
+- Draw the `foliage`, `mountain-valley` and grand valley reference frames without wind (issue #191). The reference harness left the renderer's default `wind: 0.3` on, which moved leaf cards by up to about four pixels at the reference camera while Blender drew them still. `foliage` falls from 0.0979 to 0.0838 against Cycles (EEVEE 0.0924), `mountain-valley` from 0.1769 to 0.1691, the three grand valleys by 0.0018 to 0.0077; no other scene moves. The README has the card-by-card comparison with Blender.