Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Make the three picked looks the grand scenes, with rectangular facade windows (closes #168)

Nguyen Xuan An87b68ae0c366
diff --git a/bench/reference/README.md b/bench/reference/README.md
index 667ad46a..873efae2 100644
--- a/bench/reference/README.md
+++ b/bench/reference/README.md
@@ -1556,6 +1556,22 @@ Nothing is kept: `h^2.5` is 0.0002 better, inside the spread between runs, and p
Terrain shape: the rim is rounded massifs (erosion noise) with a little ridged noise for crags, in place of the reference's needle ridges. Towers have a lit podium, one to three setbacks and a crown (plant, stepped or spire), and a facade graph gives panes in a wall with lit panes in drifts instead of full-width stripes. No downloaded textures or models are used: the terrain chunks and tower boxes carry no UV sets in the export, so a scanned texture would not reach Blender the same way.
+## The three picked looks are the grand scenes (2026-11-04, issue #168)
+
+An picked `mountain-valley:dawn`, `temple-hall:rose` and `megacity-dusk:blue-hour`. `GRAND_PICKS` in `look-options.js` adds them to the grand set (`?set=grand`), so `node bench/reference/run.mjs --grand --scene mountain-valley-dawn,temple-hall-rose,megacity-dusk-blue-hour` draws them and Blender renders them; the option names still work. Their entries sit in `grand.json` beside the letter variants, which are unchanged, and the old plain scenes are replaced by these picks (no old against new comparison is kept). `final-sheet.py` writes the contact sheet of the 67js and Cycles frames.
+
+Facade fix: the lit windows of `facadeMaterial` came from a voronoi, whose cells cut the 6 by 10 window grid into shards. A noise read at the centre of each window cell now lights a window as a whole, in drifts, and both noises use `"tile": false` so `render-blender.py` builds the same nodes.
+
+FLIP mean error, lower is better (measured, one run, Blender 5.2.2, 960 by 540):
+
+| Scene | 67js GPU vs Cycles | 67js GPU vs EEVEE | EEVEE vs Cycles |
+| --- | --- | --- | --- |
+| `mountain-valley-dawn` | 0.2008 | 0.3720 | 0.3039 |
+| `temple-hall-rose` | 0.5652 | 0.5727 | 0.8878 |
+| `megacity-dusk-blue-hour` | 0.1128 | 0.1081 | 0.0688 |
+
+Known gaps shown on purpose, not hidden by a per-scene setting: the dark band of mid-distance trees in the dawn frame is a 67js defect (the lower tree levels shade near black under sky light and a low sun, issue #394); the temple hall is lit flat in 67js while Cycles leaves it dark, the closed-room-without-bake gap (an open roof is not a bake).
+
## 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.
diff --git a/bench/reference/final-sheet.py b/bench/reference/final-sheet.py
new file mode 100644
index 00000000..c2d7721f
--- /dev/null
+++ b/bench/reference/final-sheet.py
@@ -0,0 +1,48 @@
+"""Contact sheet of the three picked grand scenes (issue #168): one row per scene, the 67js GPU frame beside the Cycles frame.
+
+ uv run --no-project --with pillow --with numpy python -I bench/reference/final-sheet.py artifacts/reference-grand artifacts/look-168/final.png
+"""
+import sys
+from pathlib import Path
+
+import numpy as np
+from PIL import Image, ImageDraw
+
+SCENES = ["mountain-valley-dawn", "temple-hall-rose", "megacity-dusk-blue-hour"]
+GAMMA = 2.2
+
+
+def tone_map_like_67js(linear):
+ color = np.maximum(linear, 0)
+ mapped = np.clip((color * (2.51 * color + 0.03)) / (color * (2.43 * color + 0.59) + 0.14), 0, 1)
+ return mapped ** (1 / GAMMA)
+
+
+def labelled(image, text):
+ draw = ImageDraw.Draw(image)
+ draw.rectangle([0, 0, 8 * len(text) + 12, 20], fill=(0, 0, 0))
+ draw.text((6, 4), text, fill=(255, 255, 255))
+ return image
+
+
+def main():
+ work_directory, output_path = Path(sys.argv[1]), Path(sys.argv[2])
+ rows = []
+ for scene in SCENES:
+ gpu = Image.open(work_directory / f"{scene}-gpu.png").convert("RGB")
+ cycles_array = tone_map_like_67js(np.load(work_directory / f"{scene}-cycles.npy"))
+ cycles = Image.fromarray((np.clip(cycles_array, 0, 1) * 255).astype(np.uint8)).convert("RGB").resize(gpu.size)
+ row = Image.new("RGB", (gpu.width * 2, gpu.height))
+ row.paste(labelled(gpu, f"67js GPU {scene}"), (0, 0))
+ row.paste(labelled(cycles, "Cycles"), (gpu.width, 0))
+ rows.append(row)
+ sheet = Image.new("RGB", (rows[0].width, sum(row.height for row in rows)))
+ offset = 0
+ for row in rows:
+ sheet.paste(row, (0, offset))
+ offset += row.height
+ output_path.parent.mkdir(parents=True, exist_ok=True)
+ sheet.save(output_path)
+
+
+main()
diff --git a/bench/reference/grand.json b/bench/reference/grand.json
index af7fe426..ee281f7f 100644
--- a/bench/reference/grand.json
+++ b/bench/reference/grand.json
@@ -37,6 +37,18 @@
"mountain-valley-a": {
"cycles": 26.3,
"eevee": 20
+ },
+ "megacity-dusk-blue-hour": {
+ "cycles": 7.8,
+ "eevee": 2.7
+ },
+ "mountain-valley-dawn": {
+ "cycles": 19.3,
+ "eevee": 16.9
+ },
+ "temple-hall-rose": {
+ "cycles": 34.9,
+ "eevee": 8.7
}
},
"graphics": {
@@ -115,6 +127,30 @@
"cpu-vs-eevee": 0.3679,
"eevee-vs-cycles": 0.3992,
"gpu-vs-cpu": 0.0025
+ },
+ "megacity-dusk-blue-hour": {
+ "gpu-vs-cycles": 0.1128,
+ "gpu-vs-eevee": 0.1081,
+ "cpu-vs-cycles": 0.1132,
+ "cpu-vs-eevee": 0.1064,
+ "eevee-vs-cycles": 0.0688,
+ "gpu-vs-cpu": 0.0126
+ },
+ "mountain-valley-dawn": {
+ "gpu-vs-cycles": 0.2008,
+ "gpu-vs-eevee": 0.372,
+ "cpu-vs-cycles": 0.2008,
+ "cpu-vs-eevee": 0.3708,
+ "eevee-vs-cycles": 0.3039,
+ "gpu-vs-cpu": 0.0146
+ },
+ "temple-hall-rose": {
+ "gpu-vs-cycles": 0.5652,
+ "gpu-vs-eevee": 0.5727,
+ "cpu-vs-cycles": 0.5656,
+ "cpu-vs-eevee": 0.5724,
+ "eevee-vs-cycles": 0.8878,
+ "gpu-vs-cpu": 0.0072
}
}
}
diff --git a/bench/reference/harness.js b/bench/reference/harness.js
index d9451562..6c0ace60 100644
--- a/bench/reference/harness.js
+++ b/bench/reference/harness.js
@@ -2,7 +2,7 @@
import { Renderer67 } from '/src/renderer.js';
import { REFERENCE_SCENES, KHRONOS_SCENES, KTX2_SCENES, loadBarnLampVariant, CLOTH_SCENES } from './scenes.js';
import { GRAND_SCENES } from './grand-scenes.js';
-import { LOOK_OPTIONS } from './look-options.js';
+import { LOOK_OPTIONS, GRAND_PICKS } from './look-options.js';
import { skinnedGeometry } from '/src/path-tracer-scene.js';
import { boxProjectedGeometry } from '/src/export-box-uv.js';
import '/src/material-layer-shaders.js';
@@ -47,7 +47,7 @@ function withFloorSky(id, parts) {
// ?set=khronos draws the Khronos sample assets (npm run reference -- --khronos) and ?set=cloth the cloth scenes
// (npm run reference -- --cloth) instead of the fixed scenes.
-const SCENE_SETS = { khronos: KHRONOS_SCENES, ktx2: KTX2_SCENES, cloth: CLOTH_SCENES, grand: GRAND_SCENES, look: LOOK_OPTIONS };
+const SCENE_SETS = { khronos: KHRONOS_SCENES, ktx2: KTX2_SCENES, cloth: CLOTH_SCENES, grand: { ...GRAND_SCENES, ...GRAND_PICKS }, look: LOOK_OPTIONS };
const SCENES = SCENE_SETS[new URLSearchParams(location.search).get('set')] ?? REFERENCE_SCENES;
function encodeBytes(typedArray) {
diff --git a/bench/reference/images/grand-megacity-dusk-blue-hour.jpg b/bench/reference/images/grand-megacity-dusk-blue-hour.jpg
new file mode 100644
index 00000000..2a87aa04
Binary files /dev/null and b/bench/reference/images/grand-megacity-dusk-blue-hour.jpg differ
diff --git a/bench/reference/images/grand-mountain-valley-dawn.jpg b/bench/reference/images/grand-mountain-valley-dawn.jpg
new file mode 100644
index 00000000..a3d34eb3
Binary files /dev/null and b/bench/reference/images/grand-mountain-valley-dawn.jpg differ
diff --git a/bench/reference/images/grand-temple-hall-rose.jpg b/bench/reference/images/grand-temple-hall-rose.jpg
new file mode 100644
index 00000000..bd913c14
Binary files /dev/null and b/bench/reference/images/grand-temple-hall-rose.jpg differ
diff --git a/bench/reference/look-options.js b/bench/reference/look-options.js
index 0368d9ce..6e05ae89 100644
--- a/bench/reference/look-options.js
+++ b/bench/reference/look-options.js
@@ -301,9 +301,18 @@ function facadeMaterial({ wall, glass, lit, litShare, warm, cool, seed }) {
const across = { smoothstep: [0.22, 0.34, { wave: { frequency: 6, direction: 'u', shape: 'triangle' } }] };
const along = { smoothstep: [0.18, 0.3, { wave: { frequency: 10, direction: 'v', shape: 'triangle' } }] };
const pane = { min: [across, along] };
- const litPane = { mul: [pane, { smoothstep: [1 - litShare, 1 - litShare + 0.02, { voronoi: { scale: 8, seed, output: 'cell' } }] }] };
- // A cell of the voronoi is about a window across, so each window is lit or dark as a whole.
- const tint = { ramp: { value: { noise: { scale: 4, seed: seed + 5 } }, stops: [[0, warm], [1, cool]] } };
+ // The lit test reads a noise at the centre of each window cell (the same 6 by 10 grid as the panes), so a window is lit or dark
+ // as a whole and the lit ones fall in drifts. A voronoi cell does not follow the grid and cut panes into shards.
+ const windowCentre = {
+ vec: [
+ { div: [{ add: [{ floor: { mul: [{ uv: 'u' }, 6] } }, 0.5] }, 6] },
+ { div: [{ add: [{ floor: { mul: [{ uv: 'v' }, 10] } }, 0.5] }, 10] },
+ 0,
+ ],
+ };
+ const litThreshold = 0.5 + (0.5 - litShare) * 0.5;
+ const litPane = { mul: [pane, { smoothstep: [litThreshold, litThreshold + 0.03, { noise: { scale: 9, seed, tile: false, at: windowCentre } }] }] };
+ const tint = { ramp: { value: { noise: { scale: 4, seed: seed + 5, tile: false } }, stops: [[0, warm], [1, cool]] } };
const graph = { color: { mix: [wall, glass, pane] }, emission: { mix: [[0, 0, 0], tint, litPane] } };
const pattern = normalizeMaterialPattern({ type: 'graph', graph, size: 36, bump: 0, resolution: 512 });
const textures = materialPatternTextures(pattern);
@@ -491,3 +500,11 @@ export const LOOK_OPTIONS = {
'megacity-dusk-blue-hour': megacityBlueHour,
'megacity-dusk-night-grid': megacityNightGrid,
};
+
+// The three looks An picked (issue #168, 2026-11-04). The grand set of harness.js draws them beside the letters of grand-scenes.js, so
+// `npm run reference -- --grand --scene mountain-valley-dawn,temple-hall-rose,megacity-dusk-blue-hour` scores them into grand.json.
+export const GRAND_PICKS = {
+ 'mountain-valley-dawn': LOOK_OPTIONS['mountain-valley-dawn'],
+ 'temple-hall-rose': LOOK_OPTIONS['temple-hall-rose'],
+ 'megacity-dusk-blue-hour': LOOK_OPTIONS['megacity-dusk-blue-hour'],
+};