3D engine that AI agents drive
Score the subsurface reference scenes against Cycles and EEVEE (part of #283)
Nguyen Xuan An5613a73219d3
diff --git a/bench/reference/README.md b/bench/reference/README.mdindex 50530a73..9288420e 100644--- a/bench/reference/README.md+++ b/bench/reference/README.md@@ -8,6 +8,8 @@ Run `npm run reference`. It prints one row for each scene, and it rewrites `baseThe run needs Chrome, Blender 5.2, `uv` and an NVIDIA GPU, and it took 751 s on an RTX 3060 with other jobs on the machine (2026-11-01). Use `--scene <id>,<id>` to render some scenes, then `--score-only` to score the scenes in the work directory; that also rewrites `baseline.json` with only those scenes. Use `CHROME_PATH` and `BLENDER_PATH` to change the program paths.+`raster-only.mjs <out-directory> <gpu|cpu> <scene-id>,<scene-id>` draws scenes with the rasterizer only, without Blender or scoring, to look at a change before the Cycles queue has a turn.+The other sets: `--khronos` (download the five GLB files from [glTF-Sample-Assets](https://github.com/KhronosGroup/glTF-Sample-Assets) into the gitignored `artifacts/khronos/<name>/<name>.glb` first, see below), `--path-tracer --scene <ids>` (needs the Cycles renders of an earlier plain run, for example `--skip-cpu`, which renders without scoring), and `--bake <id>,<id> --skip-blender`, which draws and scores only those scenes baked, against the Cycles renders of an earlier plain run.A baked run writes `artifacts/reference/bake.json` and compares it with the committed `bake.json` (`compare-scores.mjs`): it exits with an error when a score is worse by more than 0.01 FLIP. `--update-baseline` replaces `bake.json` and `images/<id>-baked.jpg`. The bake is deterministic on one machine (two runs gave the same four digits), so 0.01 is a margin for other GPUs and drivers, and well under the 0.047 that went unnoticed in #160.@@ -1534,3 +1536,7 @@ Fix: `harness.js` renders the reference frame with `wind: 0`. Re-run with 67js o| 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.++## Subsurface scattering (2026-11-04, part of issue #283)++`subsurface` (wax candle, skin sphere, leaf slab, weight 1) and `subsurface-off` (the same scene at weight 0 in both renderers) are scored each against its own Cycles render: the rasterizer scores 0.1180 with subsurface on and 0.0940 off, and EEVEE scores 0.1028 and 0.0764, so the scene with subsurface is the harder one for both, and the on scene does not score better than the off scene. Scored against the same Cycles render with subsurface, the weight 0 picture of 67js scores 0.1229 and the weight 1 picture 0.1180 (0.1211 with back translucency 0.5), so the block moves the picture toward Cycles by 0.005. The leaf is the part that stays dark (signed mean luminance error of -0.05, wax and skin +0.01). Frame cost with `frame-time.mjs <scene> gpu --plain`: 0.45 to 0.49 ms on, 0.455 to 0.485 ms off, the same within noise.diff --git a/bench/reference/baseline.json b/bench/reference/baseline.jsonindex 4305b052..4b3327c4 100644--- a/bench/reference/baseline.json+++ b/bench/reference/baseline.json@@ -30,6 +30,10 @@"cycles": 13.7,"eevee": 0.8},+ "fog": {+ "cycles": 14.5,+ "eevee": 0.9+ },"fog-room": {"cycles": 14.5,"eevee": 0.9@@ -38,10 +42,6 @@"cycles": 12.4,"eevee": 0.8},- "fog": {- "cycles": 14.5,- "eevee": 0.9- },"foliage": {"cycles": 5,"eevee": 0.4@@ -70,14 +70,14 @@"cycles": 9.3,"eevee": 0.7},- "metal-room": {- "cycles": 9,- "eevee": 0.3- },"metal": {"cycles": 4.4,"eevee": 0.3},+ "metal-room": {+ "cycles": 9,+ "eevee": 0.3+ },"mountain-valley": {"cycles": 15.5,"eevee": 11.3@@ -90,6 +90,14 @@"cycles": 3.4,"eevee": 0.3},+ "subsurface": {+ "cycles": 5.8,+ "eevee": 0.3+ },+ "subsurface-off": {+ "cycles": 4.2,+ "eevee": 0.9+ },"temple-hall": {"cycles": 16,"eevee": 0.8@@ -284,6 +292,22 @@"eevee-vs-cycles": 0.1957,"gpu-vs-cpu": 0.0033},+ "subsurface": {+ "gpu-vs-cycles": 0.118,+ "gpu-vs-eevee": 0.0885,+ "cpu-vs-cycles": 0.1175,+ "cpu-vs-eevee": 0.087,+ "eevee-vs-cycles": 0.1028,+ "gpu-vs-cpu": 0.0066+ },+ "subsurface-off": {+ "gpu-vs-cycles": 0.094,+ "gpu-vs-eevee": 0.068,+ "cpu-vs-cycles": 0.0935,+ "cpu-vs-eevee": 0.0665,+ "eevee-vs-cycles": 0.0764,+ "gpu-vs-cpu": 0.0063+ },"temple-hall": {"gpu-vs-cycles": 0.064,"gpu-vs-eevee": 0.2319,diff --git a/bench/reference/images/subsurface-off.jpg b/bench/reference/images/subsurface-off.jpgnew file mode 100644index 00000000..de4eb22dBinary files /dev/null and b/bench/reference/images/subsurface-off.jpg differdiff --git a/bench/reference/images/subsurface.jpg b/bench/reference/images/subsurface.jpgnew file mode 100644index 00000000..c57de75eBinary files /dev/null and b/bench/reference/images/subsurface.jpg differdiff --git a/changes/283.md b/changes/283.mdindex 4647c045..e3303e03 100644--- a/changes/283.md+++ b/changes/283.md@@ -1 +1,2 @@- Add a material `subsurface` block for skin, wax and leaves (part of #283): `weight` (0 to 1), `radius` (red, green, blue mean free path in units of `scale`, default `[1, 0.2, 0.1]`), `scale` (metres, default 0.05) and an optional `color`, named as Blender's Principled BSDF Subsurface Weight, Radius and Scale. Recipes and the MCP `scene_create` schema accept it with bounded numbers. The rasterizer widens the sun's diffuse past the shadow edge per channel and lets light through thin parts by the thickness the sun shadow map gives; the code is a lazily loaded addon (`@codepawlhq/67js/addons/subsurface-shader`, loaded by a recipe on its own) that compiles in only when a part has a weight above 0, so a scene without it draws the same picture and pays nothing. The path tracer does not read the block yet. `bench/reference/render-blender.py` exports it as Random Walk subsurface, and the reference scenes `subsurface` and `subsurface-off` score it against Cycles.+- Raise the subsurface addon back-face translucency from 0.5 to 1.0 (part of #283) so thin parts such as leaves pass more light, measured on the `subsurface` reference scene against Cycles; scenes without a subsurface weight draw the same picture.diff --git a/src/subsurface-shader.js b/src/subsurface-shader.jsindex 7c146a12..b590c447 100644--- a/src/subsurface-shader.js+++ b/src/subsurface-shader.js@@ -16,7 +16,7 @@ import { validateSubsurface, subsurfaceUniformValues } from './subsurface-limits// - Only the sun is treated; point, spot and area lights keep their plain diffuse.const REFERENCE_LENGTH = '0.1';-const BACK_TRANSLUCENCY = '0.5';+const BACK_TRANSLUCENCY = '1.0';const SUBSURFACE_DECLARATIONS = `uniform vec4 materialSubsurface;uniform vec3 materialSubsurfaceColor;diff --git a/tests/reference-baseline.test.js b/tests/reference-baseline.test.jsindex b801c930..d1192577 100644--- a/tests/reference-baseline.test.js+++ b/tests/reference-baseline.test.js@@ -4,7 +4,7 @@ import test from 'node:test';const REFERENCE_DIRECTORY = new URL('../bench/reference/', import.meta.url);const baseline = JSON.parse(readFileSync(new URL('baseline.json', REFERENCE_DIRECTORY), 'utf8'));-const EXPECTED_SCENES = ['brick-flat', 'brick-graph', 'brick-room', 'brushed-film', 'car-paint', 'character', 'dark-shaft', 'fog', 'fog-room', 'fog-valley', 'foliage', 'glass', 'light-linking', 'lit-interior', 'long-street', 'material-spheres', 'megacity-dusk', 'metal', 'metal-room', 'mountain-valley', 'outdoor-hdri', 'spot-area', 'temple-hall'];+const EXPECTED_SCENES = ['brick-flat', 'brick-graph', 'brick-room', 'brushed-film', 'car-paint', 'character', 'dark-shaft', 'fog', 'fog-room', 'fog-valley', 'foliage', 'glass', 'light-linking', 'lit-interior', 'long-street', 'material-spheres', 'megacity-dusk', 'metal', 'metal-room', 'mountain-valley', 'outdoor-hdri', 'spot-area', 'subsurface', 'subsurface-off', 'temple-hall'];const EXPECTED_SCORES = ['cpu-vs-cycles', 'cpu-vs-eevee', 'eevee-vs-cycles', 'gpu-vs-cpu', 'gpu-vs-cycles', 'gpu-vs-eevee'];const REGION_SCORES = ['region-eevee-vs-cycles', 'region-gpu-vs-cycles', 'region-gpu-vs-eevee', 'region-pixels'];// Scenes that declare a brightRegion in scenes.js are also scored on the bright pixels of the Cycles image.