Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Score the brick control and Khronos sample assets; accept glTF metadata extensions

Nguyen Xuan Anb8d88f41f7a0
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fe88feb7..bdd71e60 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
## Unreleased
+- Score material scenes and Khronos sample assets against their baseline (parts of issues #50 and #51). `brick-flat` is the control for `brick-graph`: the same wall in the graph's average colour with no maps. `npm run reference -- --khronos` draws Khronos sample assets downloaded into gitignored `artifacts/khronos/` and scores them against Cycles reading the same GLB, on the pixels the asset covers (`khronos.json`, `images/khronos-*.jpg`; `baseline.json` is unchanged). The brick bump is not weaker than Blender's: its bright edge is stronger and bump 0 would score better (0.2065 against 0.2269), so no engine change. The assets found two importer faults, fixed in `src/gltf.js`: `KHR_xmp` and `KHR_xmp_json_ld` metadata refused the whole file, and `KHR_materials_variants` is now accepted with a warning. Still open: texture slots in layer extensions (the anisotropy textures matter, both anisotropy assets score worse with the factor than with none) and occlusion on TEXCOORD_1 (`SheenChair`).
+
- Fix the recipe light bake budget, which rejected the demo room at samples 96, bounces 2, texelsPerUnit 3 (11.5 s before the budget) and scaled `standard` there to 16 samples (part of issue #55). The ray work estimate multiplied by every light and so overcounted open scenes by about 4 times. The budget now counts path steps (texels x samples x bounces), which cost about the same per path in a closed 56 part room and in the demo room. A preset scales down to 5 million path steps (the demo room at `standard` keeps about 52 samples, not 16); explicit settings are limited only by a hard bound of 24 million path steps and by the real 20 s limit, which fails the edit with the scene unchanged and names a lower samples and texelsPerUnit to try. A bake on a worker has 90 s instead of 20 s (the page's own thread keeps 20 s), and the preview's 30 s call deadline grows by 90 s for a `scene_create` with a `bake` and a `scene_apply` with `set-bake`. `bake.used` and `bake.reduced` are unchanged; the capability limit `maxRayWork` is now `maxPathWork`.
- Make room in the npm package without adding a dependency (part of issue #36). The archive fell from 802,581 to 695,041 bytes (353,535 free under 1 MiB; the target was 300,000), and every library and MCP install stays as light as before. Two causes: (1) every one of the 80 built files began with the full `LICENSE` and `THIRD-PARTY-NOTICES.md` text, about 4 KB each; they now carry a one-line notice and the complete texts stay once at the package root, about 61,000 bytes saved; (2) the MCP SDK's Node shim pulls in Ajv (the validator for elicitation answers, about 270 KB before minification) that this server never uses, so `build/mcp/server.mjs` now bundles `scripts/mcp-sdk-shims.mjs` instead, which fails with a clear message if elicitation is ever requested: `server.mjs` fell from 677,484 to 484,111 bytes and the archive by about 47,000 bytes. `build/mcp/LICENSES.md` no longer lists the Ajv family because that code is gone, and its unused copies left `licenses/mcp/`. Measured, and not worth doing: `zod/mini` (zod's classic layer is 30 KB of the server before gzip), source maps (none are shipped), standalone core copies (none in the archive), and docs (every packaged page is linked from the README, `llms.txt`, the MCP guide or the skills). `npm run smoke:package` now loads every `exports` entry in a clean consumer. Film and site code were already outside the archive. Separate lazy-loaded packages were not built: the lazy addons together are about 157 KB gzip, so splitting them out could return at most that much, for the cost of a package, a release pipeline and a version matrix each. `archiveBytes` budget 815,000 to 705,500. Module load of the server is no slower (minimum of 25 runs, 217 and 188 ms against 231 and 209 ms).
diff --git a/bench/reference/README.md b/bench/reference/README.md
index 08deb697..2be43dd0 100644
--- a/bench/reference/README.md
+++ b/bench/reference/README.md
@@ -25,7 +25,7 @@ Measured on 2026-10-30 with an RTX 3060, SwiftShader and Blender 5.2.2. The metr
| `fog` | 0.2612 | 0.2662 | 0.0542 | No multiple scattering |
| `lit-interior` | 0.4997 | 0.5159 | 0.1204 | No indirect light, and point lights cast no shadows |
| `spot-area` | 0.1242 | 0.1935 | 0.1707 | The sphere is lit more weakly at its shaded edge, and the wall has no bounce light |
-| `brick-graph` | 0.2269 | 0.1440 | 0.1480 | Bump is weaker than Blender's Bump node, so the joints cast less shadow, and Blender's noise is not 67js noise, so brick tone differs |
+| `brick-graph` | 0.2269 | 0.1440 | 0.1480 | Bump is stronger than Blender's Bump node (measured 2026-11-01, see below; an earlier note said weaker), and Blender's noise is not 67js noise, so brick tone differs |
| `brushed-film` | 0.1613 | 0.0939 | 0.1601 | The film colours on the dark sphere are close to Cycles, but its reflections are softer; the brushed highlight is pinched less at the pole, and there is no ground bounce under the spheres |
Rows are the baseline taken before shadows for point lights. The `lit-interior` scene now sets `castShadow` on its three point lights. With shadows, 67js scores 0.5055 against Cycles (0.4997 before, so 0.0058 worse) and 0.0923 against EEVEE (0.1204 before, better): the shadow shape now matches, but Cycles fills its shadows with indirect light and 67js leaves them dark. The committed `lit-interior` row stays at the earlier numbers. `spot-area` is new with shadows, a spot light and an area light.
@@ -53,6 +53,19 @@ EEVEE against Cycles is a yardstick: it shows what a good rasterizer scores. In
- **Display:** Blender writes linear pixels, and `score.py` applies the tone curve and gamma from `src/post.js`. Both sides then use one display transform.
- **Lighting tricks:** the 67js fill lights are off. All light comes from the sun, the environment and point lights.
+Khronos sample assets (issue #51): `npm run reference -- --khronos` draws files from [KhronosGroup/glTF-Sample-Assets](https://github.com/KhronosGroup/glTF-Sample-Assets) that you download by hand into `artifacts/khronos/<name>/<name>.glb` (gitignored; nothing is committed). Blender imports the same GLB with its own importer, so Cycles is the reference for the file and not for our reading of it. The run uses its own work directory and writes `khronos.json` and `images/khronos-<name>.jpg`; `baseline.json` stays as it is. The sky fills most of each frame and both sides draw it alike, so the whole-frame FLIP score is about 0.05 for every asset and says little. The `asset-` columns score only the pixels the asset changes (a second render of the empty sky decides which, threshold 0.03). Licences, checked in each model's `LICENSE.md`: ClearCoatTest and AnisotropyBarnLamp are CC BY 4.0 (Analytical Graphics, Inc. and Wayfair, LLC), TransmissionTest and AnisotropyDiscTest are CC0 1.0. Measured 2026-11-01 on the RTX 3060 (SwiftShader within 0.0004 on the whole frame):
+
+| Asset | Pixels covered | 67js against Cycles (asset only) | 67js against EEVEE | EEVEE against Cycles | What differs |
+| --- | --- | --- | --- | --- | --- |
+| `ClearCoatTest` | 0.1353 | 0.2344 | 0.1859 | 0.1336 | Only factors are read, and the asset's coat and normal textures sit in layer slots |
+| `TransmissionTest` | 0.1356 | 0.2708 | 0.2371 | 0.1656 | Refraction through the front surface only, no roughness-blurred background |
+| `AnisotropyDiscTest` | 0.1073 | 0.3481 | 0.3174 | 0.1535 | The anisotropy and rotation textures are ignored: 0.2773 with anisotropy switched off |
+| `AnisotropyBarnLamp` | 0.0734 | 0.4758 | 0.4199 | 0.3761 | The copper shade is lighter and less saturated; 0.3945 with anisotropy switched off |
+
+Switching anisotropy off scores better than our anisotropy on both anisotropy assets, so the missing `anisotropyTexture` (strength and direction per texel) is what matters there, and it is ours; the layer factor alone spreads a highlight over the whole shade. Not added in this change. `SheenChair` was refused: its occlusion texture uses TEXCOORD_1, which `parseGltf` rejects. Both Blender's engines disagree on the lamp by 0.3761, so part of that gap is Blender's own anisotropy and clear coat. Two importer bugs the assets found are fixed: `KHR_xmp` and `KHR_xmp_json_ld` (metadata) stopped the whole import, and `KHR_materials_variants` is now accepted with a warning and draws the default material.
+
+`brick-flat` is the control for `brick-graph` (issue #50): the same wall and light in the average colour of the graph, with no maps. Measured 2026-11-01 it scores 0.1999 against Cycles (0.1119 against EEVEE, EEVEE against Cycles 0.1351), and `brick-graph` 0.2269 (0.1480), so by this baseline the graph does not score above it: the picture is more like Cycles in kind but FLIP punishes the misplaced bevel highlights and the tone differences of noise more than it rewards the brick pattern. The bump of `brick-graph` is not weaker than Blender's. In a profile across one brick edge (columns 365 to 420, rows 150 to 215 of the render) the dark side of the bevel is the same in both (about 0.25 below the wall), and the bright side is about 0.3 above the wall in 67js against 0.17 in Cycles; the luminance spread over the brick area is 0.132 against 0.109 (EEVEE 0.109), and the edges fall on the same rows. Turning the bump down only lowers the score: 0.2065 with a bump of 0.01, 0.2209 at 0.5, 0.2247 at 0.75 and 0.2269 at 1 against Cycles. So the earlier note, that bump is weaker, was wrong. The rim of 67js is brighter because it keeps the full slope of the steep joint edge; the flat wall brightness is also 0.07 lower than Cycles, which has indirect light from the floor (EEVEE matches 67js there).
+
## Limits
- Scores come from one camera for each scene and one machine. They do not measure motion or speed.
diff --git a/bench/reference/baseline.json b/bench/reference/baseline.json
index 21e8feba..0a8257ee 100644
--- a/bench/reference/baseline.json
+++ b/bench/reference/baseline.json
@@ -1,168 +1,180 @@
{
- "metric": "FLIP (LDR), mean error, lower is better",
- "blenderVersion": "5.2.2 LTS",
- "seconds": {
- "brick-graph": {
- "cycles": 8.9,
- "eevee": 15.2
- },
- "brick-room": {
- "cycles": 56.7,
- "eevee": 7.1
- },
- "brushed-film": {
- "cycles": 7.6,
- "eevee": 7.4
- },
- "car-paint": {
- "cycles": 35.4,
- "eevee": 82.5
- },
- "character": {
- "cycles": 19.2,
- "eevee": 4.5
- },
- "fog": {
- "cycles": 63.5,
- "eevee": 36.3
- },
- "foliage": {
- "cycles": 39.5,
- "eevee": 27.4
- },
- "glass": {
- "cycles": 29.5,
- "eevee": 13.7
- },
- "lit-interior": {
- "cycles": 77.4,
- "eevee": 2.6
- },
- "material-spheres": {
- "cycles": 25,
- "eevee": 60.5
- },
- "metal": {
- "cycles": 42.2,
- "eevee": 30.4
- },
- "outdoor-hdri": {
- "cycles": 42.9,
- "eevee": 12.9
- },
- "spot-area": {
- "cycles": 28.5,
- "eevee": 10.1
- }
- },
- "graphics": {
- "cpu": "ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device (Subzero) (0x0000C0DE)), SwiftShader driver)",
- "gpu": "ANGLE (NVIDIA, NVIDIA GeForce RTX 3060 (0x00002487) Direct3D11 vs_5_0 ps_5_0, D3D11)"
- },
- "scores": {
- "brick-graph": {
- "gpu-vs-cycles": 0.2269,
- "gpu-vs-eevee": 0.148,
- "cpu-vs-cycles": 0.2268,
- "cpu-vs-eevee": 0.1479,
- "eevee-vs-cycles": 0.144,
- "gpu-vs-cpu": 0.0074
- },
- "brick-room": {
- "gpu-vs-cycles": 0.5102,
- "gpu-vs-eevee": 0.071,
- "cpu-vs-cycles": 0.5096,
- "cpu-vs-eevee": 0.0713,
- "eevee-vs-cycles": 0.502,
- "gpu-vs-cpu": 0.0071
- },
- "brushed-film": {
- "gpu-vs-cycles": 0.1613,
- "gpu-vs-eevee": 0.1601,
- "cpu-vs-cycles": 0.1613,
- "cpu-vs-eevee": 0.1601,
- "eevee-vs-cycles": 0.0939,
- "gpu-vs-cpu": 0.0058
- },
- "car-paint": {
- "gpu-vs-cycles": 0.1521,
- "gpu-vs-eevee": 0.1323,
- "cpu-vs-cycles": 0.152,
- "cpu-vs-eevee": 0.1323,
- "eevee-vs-cycles": 0.0819,
- "gpu-vs-cpu": 0.0055
- },
- "character": {
- "gpu-vs-cycles": 0.0995,
- "gpu-vs-eevee": 0.0833,
- "cpu-vs-cycles": 0.099,
- "cpu-vs-eevee": 0.0826,
- "eevee-vs-cycles": 0.074,
- "gpu-vs-cpu": 0.0068
- },
- "fog": {
- "gpu-vs-cycles": 0.2612,
- "gpu-vs-eevee": 0.0542,
- "cpu-vs-cycles": 0.2608,
- "cpu-vs-eevee": 0.0542,
- "eevee-vs-cycles": 0.2662,
- "gpu-vs-cpu": 0.0085
- },
- "foliage": {
- "gpu-vs-cycles": 0.1594,
- "gpu-vs-eevee": 0.1386,
- "cpu-vs-cycles": 0.159,
- "cpu-vs-eevee": 0.1384,
- "eevee-vs-cycles": 0.0783,
- "gpu-vs-cpu": 0.0096
- },
- "glass": {
- "gpu-vs-cycles": 0.1326,
- "gpu-vs-eevee": 0.1471,
- "cpu-vs-cycles": 0.1323,
- "cpu-vs-eevee": 0.1474,
- "eevee-vs-cycles": 0.115,
- "gpu-vs-cpu": 0.0075
- },
- "lit-interior": {
- "gpu-vs-cycles": 0.5055,
- "gpu-vs-eevee": 0.0923,
- "cpu-vs-cycles": 0.5051,
- "cpu-vs-eevee": 0.0928,
- "eevee-vs-cycles": 0.5159,
- "gpu-vs-cpu": 0.0062
- },
- "material-spheres": {
- "gpu-vs-cycles": 0.1598,
- "gpu-vs-eevee": 0.1196,
- "cpu-vs-cycles": 0.1595,
- "cpu-vs-eevee": 0.1194,
- "eevee-vs-cycles": 0.1006,
- "gpu-vs-cpu": 0.0069
- },
- "metal": {
- "gpu-vs-cycles": 0.1868,
- "gpu-vs-eevee": 0.1565,
- "cpu-vs-cycles": 0.1867,
- "cpu-vs-eevee": 0.1565,
- "eevee-vs-cycles": 0.0934,
- "gpu-vs-cpu": 0.0063
- },
- "outdoor-hdri": {
- "gpu-vs-cycles": 0.0676,
- "gpu-vs-eevee": 0.052,
- "cpu-vs-cycles": 0.0672,
- "cpu-vs-eevee": 0.0515,
- "eevee-vs-cycles": 0.0384,
- "gpu-vs-cpu": 0.0058
- },
- "spot-area": {
- "gpu-vs-cycles": 0.1242,
- "gpu-vs-eevee": 0.1707,
- "cpu-vs-cycles": 0.1242,
- "cpu-vs-eevee": 0.1709,
- "eevee-vs-cycles": 0.1935,
- "gpu-vs-cpu": 0.0032
- }
+ "metric": "FLIP (LDR), mean error, lower is better",
+ "blenderVersion": "5.2.2 LTS",
+ "seconds": {
+ "brick-flat": {
+ "cycles": 24.4,
+ "eevee": 6.4
+ },
+ "brick-graph": {
+ "cycles": 34.6,
+ "eevee": 2.8
+ },
+ "brick-room": {
+ "cycles": 230.4,
+ "eevee": 1.1
+ },
+ "brushed-film": {
+ "cycles": 18.7,
+ "eevee": 0.9
+ },
+ "car-paint": {
+ "cycles": 27.5,
+ "eevee": 0.7
+ },
+ "character": {
+ "cycles": 14.9,
+ "eevee": 0.7
+ },
+ "fog": {
+ "cycles": 475.8,
+ "eevee": 2.4
+ },
+ "foliage": {
+ "cycles": 159.4,
+ "eevee": 1.0
+ },
+ "glass": {
+ "cycles": 15.8,
+ "eevee": 0.8
+ },
+ "lit-interior": {
+ "cycles": 82.6,
+ "eevee": 1.4
+ },
+ "material-spheres": {
+ "cycles": 35.2,
+ "eevee": 0.9
+ },
+ "metal": {
+ "cycles": 27.8,
+ "eevee": 1.6
+ },
+ "outdoor-hdri": {
+ "cycles": 52.4,
+ "eevee": 0.8
+ },
+ "spot-area": {
+ "cycles": 17.4,
+ "eevee": 0.8
+ }
+ },
+ "graphics": {
+ "gpu": "ANGLE (NVIDIA, NVIDIA GeForce RTX 3060 (0x00002487) Direct3D11 vs_5_0 ps_5_0, D3D11)",
+ "cpu": "ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device (Subzero) (0x0000C0DE)), SwiftShader driver)"
+ },
+ "scores": {
+ "brick-flat": {
+ "gpu-vs-cycles": 0.1999,
+ "gpu-vs-eevee": 0.1119,
+ "cpu-vs-cycles": 0.1996,
+ "cpu-vs-eevee": 0.1116,
+ "eevee-vs-cycles": 0.1351,
+ "gpu-vs-cpu": 0.0061
+ },
+ "brick-graph": {
+ "gpu-vs-cycles": 0.2269,
+ "gpu-vs-eevee": 0.148,
+ "cpu-vs-cycles": 0.2268,
+ "cpu-vs-eevee": 0.1479,
+ "eevee-vs-cycles": 0.144,
+ "gpu-vs-cpu": 0.0074
+ },
+ "brick-room": {
+ "gpu-vs-cycles": 0.5102,
+ "gpu-vs-eevee": 0.071,
+ "cpu-vs-cycles": 0.5096,
+ "cpu-vs-eevee": 0.0713,
+ "eevee-vs-cycles": 0.502,
+ "gpu-vs-cpu": 0.0071
+ },
+ "brushed-film": {
+ "gpu-vs-cycles": 0.1613,
+ "gpu-vs-eevee": 0.1601,
+ "cpu-vs-cycles": 0.1613,
+ "cpu-vs-eevee": 0.1601,
+ "eevee-vs-cycles": 0.0939,
+ "gpu-vs-cpu": 0.0058
+ },
+ "car-paint": {
+ "gpu-vs-cycles": 0.1521,
+ "gpu-vs-eevee": 0.1323,
+ "cpu-vs-cycles": 0.152,
+ "cpu-vs-eevee": 0.1323,
+ "eevee-vs-cycles": 0.0819,
+ "gpu-vs-cpu": 0.0055
+ },
+ "character": {
+ "gpu-vs-cycles": 0.0995,
+ "gpu-vs-eevee": 0.0833,
+ "cpu-vs-cycles": 0.099,
+ "cpu-vs-eevee": 0.0826,
+ "eevee-vs-cycles": 0.074,
+ "gpu-vs-cpu": 0.0068
+ },
+ "fog": {
+ "gpu-vs-cycles": 0.2612,
+ "gpu-vs-eevee": 0.0542,
+ "cpu-vs-cycles": 0.2608,
+ "cpu-vs-eevee": 0.0542,
+ "eevee-vs-cycles": 0.2662,
+ "gpu-vs-cpu": 0.0085
+ },
+ "foliage": {
+ "gpu-vs-cycles": 0.1594,
+ "gpu-vs-eevee": 0.1386,
+ "cpu-vs-cycles": 0.159,
+ "cpu-vs-eevee": 0.1384,
+ "eevee-vs-cycles": 0.0783,
+ "gpu-vs-cpu": 0.0096
+ },
+ "glass": {
+ "gpu-vs-cycles": 0.1326,
+ "gpu-vs-eevee": 0.1472,
+ "cpu-vs-cycles": 0.1323,
+ "cpu-vs-eevee": 0.1474,
+ "eevee-vs-cycles": 0.115,
+ "gpu-vs-cpu": 0.0075
+ },
+ "lit-interior": {
+ "gpu-vs-cycles": 0.5055,
+ "gpu-vs-eevee": 0.0923,
+ "cpu-vs-cycles": 0.5051,
+ "cpu-vs-eevee": 0.0928,
+ "eevee-vs-cycles": 0.5159,
+ "gpu-vs-cpu": 0.0062
+ },
+ "material-spheres": {
+ "gpu-vs-cycles": 0.1598,
+ "gpu-vs-eevee": 0.1196,
+ "cpu-vs-cycles": 0.1595,
+ "cpu-vs-eevee": 0.1194,
+ "eevee-vs-cycles": 0.1006,
+ "gpu-vs-cpu": 0.0069
+ },
+ "metal": {
+ "gpu-vs-cycles": 0.1868,
+ "gpu-vs-eevee": 0.1565,
+ "cpu-vs-cycles": 0.1867,
+ "cpu-vs-eevee": 0.1565,
+ "eevee-vs-cycles": 0.0934,
+ "gpu-vs-cpu": 0.0063
+ },
+ "outdoor-hdri": {
+ "gpu-vs-cycles": 0.0676,
+ "gpu-vs-eevee": 0.052,
+ "cpu-vs-cycles": 0.0672,
+ "cpu-vs-eevee": 0.0515,
+ "eevee-vs-cycles": 0.0383,
+ "gpu-vs-cpu": 0.0058
+ },
+ "spot-area": {
+ "gpu-vs-cycles": 0.1242,
+ "gpu-vs-eevee": 0.1707,
+ "cpu-vs-cycles": 0.1242,
+ "cpu-vs-eevee": 0.1709,
+ "eevee-vs-cycles": 0.1935,
+ "gpu-vs-cpu": 0.0032
}
+ }
}
diff --git a/bench/reference/harness.js b/bench/reference/harness.js
index 28d37874..c03d4a1a 100644
--- a/bench/reference/harness.js
+++ b/bench/reference/harness.js
@@ -1,10 +1,13 @@
// Runs in the page: draws one reference scene, and describes it as plain data for Blender.
import { Renderer67 } from '/src/renderer.js';
-import { REFERENCE_SCENES } from './scenes.js';
+import { REFERENCE_SCENES, KHRONOS_SCENES } from './scenes.js';
import { skinnedGeometry } from '/src/path-tracer-scene.js';
import { boxProjectedGeometry } from '/src/export-box-uv.js';
import '/src/material-layer-shaders.js';
+// ?set=khronos draws the Khronos sample assets (npm run reference -- --khronos) instead of the fixed scenes.
+const SCENES = new URLSearchParams(location.search).get('set') === 'khronos' ? KHRONOS_SCENES : REFERENCE_SCENES;
+
function encodeBytes(typedArray) {
const bytes = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength);
let text = '';
@@ -47,6 +50,8 @@ function boxProjectedFor(part, cache) {
// skinned result as plain geometry. A score then measures shading, and not an importer's pose.
function describeScene(id, scene) {
const { map: _map, ...environment } = scene.environment;
+ // A sample asset reaches Blender as its own file, not as parts.
+ if (scene.glb) return { id, camera: scene.camera, environment, world: scene.blenderWorld, glb: scene.glb, parts: [], geometries: [] };
const geometries = new Map();
const boxProjected = new Map();
const describedParts = scene.parts.map(part => {
@@ -70,11 +75,12 @@ async function bakeScene(scene, bakeOptions) {
return { parts: baked.parts, report: baked.report, seconds: (performance.now() - started) / 1000 };
}
-async function renderReferenceScene(id, { describe, ambientOcclusion = 0, ambientOcclusionRadius = 0.5, bake = null }) {
- const scene = await REFERENCE_SCENES[id]();
+async function renderReferenceScene(id, { describe, ambientOcclusion = 0, ambientOcclusionRadius = 0.5, bake = null, backgroundOnly = false }) {
+ const scene = await SCENES[id]();
const baked = bake ? await bakeScene(scene, bake) : null;
const canvas = document.querySelector('canvas');
- const renderer = new Renderer67(canvas, baked ? baked.parts : scene.parts, {
+ // backgroundOnly draws the sky alone, so a score can be limited to the pixels the asset covers.
+ const renderer = new Renderer67(canvas, backgroundOnly ? [] : baked ? baked.parts : scene.parts, {
ground: false, hdr: true, depth: true, samples: 4, pixelRatio: 1, memoryBudgetMiB: 1024, world: true,
environment: scene.environment, shadowBounds: scene.shadow,
});
@@ -140,4 +146,4 @@ async function renderReferencePathTraced(id, options) {
window.renderReferenceScene = renderReferenceScene;
window.renderReferencePathTraced = renderReferencePathTraced;
-window.referenceSceneIds = Object.keys(REFERENCE_SCENES);
+window.referenceSceneIds = Object.keys(SCENES);
diff --git a/bench/reference/images/brick-flat.jpg b/bench/reference/images/brick-flat.jpg
new file mode 100644
index 00000000..ac30b9ed
Binary files /dev/null and b/bench/reference/images/brick-flat.jpg differ
diff --git a/bench/reference/images/khronos-AnisotropyBarnLamp.jpg b/bench/reference/images/khronos-AnisotropyBarnLamp.jpg
new file mode 100644
index 00000000..01a49dec
Binary files /dev/null and b/bench/reference/images/khronos-AnisotropyBarnLamp.jpg differ
diff --git a/bench/reference/images/khronos-AnisotropyDiscTest.jpg b/bench/reference/images/khronos-AnisotropyDiscTest.jpg
new file mode 100644
index 00000000..b0c2bab8
Binary files /dev/null and b/bench/reference/images/khronos-AnisotropyDiscTest.jpg differ
diff --git a/bench/reference/images/khronos-ClearCoatTest.jpg b/bench/reference/images/khronos-ClearCoatTest.jpg
new file mode 100644
index 00000000..514e2cbb
Binary files /dev/null and b/bench/reference/images/khronos-ClearCoatTest.jpg differ
diff --git a/bench/reference/images/khronos-TransmissionTest.jpg b/bench/reference/images/khronos-TransmissionTest.jpg
new file mode 100644
index 00000000..2ff11792
Binary files /dev/null and b/bench/reference/images/khronos-TransmissionTest.jpg differ
diff --git a/bench/reference/khronos.json b/bench/reference/khronos.json
new file mode 100644
index 00000000..d8dd0d36
--- /dev/null
+++ b/bench/reference/khronos.json
@@ -0,0 +1,76 @@
+{
+ "metric": "FLIP (LDR), mean error, lower is better",
+ "blenderVersion": "5.2.2 LTS",
+ "seconds": {
+ "AnisotropyBarnLamp": {
+ "cycles": 7.7,
+ "eevee": 3.9
+ },
+ "AnisotropyDiscTest": {
+ "cycles": 4.7,
+ "eevee": 1.3
+ },
+ "ClearCoatTest": {
+ "cycles": 6.9,
+ "eevee": 9.9
+ },
+ "TransmissionTest": {
+ "cycles": 7.2,
+ "eevee": 6.5
+ }
+ },
+ "graphics": {
+ "gpu": "ANGLE (NVIDIA, NVIDIA GeForce RTX 3060 (0x00002487) Direct3D11 vs_5_0 ps_5_0, D3D11)",
+ "cpu": "ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device (Subzero) (0x0000C0DE)), SwiftShader driver)"
+ },
+ "scores": {
+ "AnisotropyBarnLamp": {
+ "gpu-vs-cycles": 0.0449,
+ "gpu-vs-eevee": 0.0289,
+ "cpu-vs-cycles": 0.0447,
+ "cpu-vs-eevee": 0.0286,
+ "eevee-vs-cycles": 0.0398,
+ "gpu-vs-cpu": 0.0063,
+ "asset-pixels": 0.0731,
+ "asset-gpu-vs-cycles": 0.3945,
+ "asset-gpu-vs-eevee": 0.2401,
+ "asset-eevee-vs-cycles": 0.3767
+ },
+ "AnisotropyDiscTest": {
+ "gpu-vs-cycles": 0.0447,
+ "gpu-vs-eevee": 0.038,
+ "cpu-vs-cycles": 0.0444,
+ "cpu-vs-eevee": 0.0377,
+ "eevee-vs-cycles": 0.024,
+ "gpu-vs-cpu": 0.0058,
+ "asset-pixels": 0.1074,
+ "asset-gpu-vs-cycles": 0.2773,
+ "asset-gpu-vs-eevee": 0.2416,
+ "asset-eevee-vs-cycles": 0.1534
+ },
+ "ClearCoatTest": {
+ "gpu-vs-cycles": 0.0454,
+ "gpu-vs-eevee": 0.034,
+ "cpu-vs-cycles": 0.0451,
+ "cpu-vs-eevee": 0.0337,
+ "eevee-vs-cycles": 0.0271,
+ "gpu-vs-cpu": 0.0075,
+ "asset-pixels": 0.1353,
+ "asset-gpu-vs-cycles": 0.2344,
+ "asset-gpu-vs-eevee": 0.1859,
+ "asset-eevee-vs-cycles": 0.1336
+ },
+ "TransmissionTest": {
+ "gpu-vs-cycles": 0.0485,
+ "gpu-vs-eevee": 0.042,
+ "cpu-vs-cycles": 0.0483,
+ "cpu-vs-eevee": 0.0417,
+ "eevee-vs-cycles": 0.0286,
+ "gpu-vs-cpu": 0.0063,
+ "asset-pixels": 0.1356,
+ "asset-gpu-vs-cycles": 0.2708,
+ "asset-gpu-vs-eevee": 0.2371,
+ "asset-eevee-vs-cycles": 0.1656
+ }
+ }
+}
diff --git a/bench/reference/render-blender.py b/bench/reference/render-blender.py
index 97a4ee3a..e8496000 100644
--- a/bench/reference/render-blender.py
+++ b/bench/reference/render-blender.py
@@ -569,10 +569,18 @@ def render_to_numpy(scene, work_directory, name):
return seconds
+def import_glb(root, glb_file):
+ """A Khronos sample asset goes through Blender's own glTF importer, so Cycles shades the file as its authors meant."""
+ bpy.ops.import_scene.gltf(filepath=os.path.join(root, glb_file))
+
+
def build_scene(description, root):
clear_scene()
scene = bpy.context.scene
- build_parts(scene, description)
+ if "glb" in description:
+ import_glb(root, description["glb"])
+ else:
+ build_parts(scene, description)
build_world(scene, description["world"], root)
build_lights(scene, description["environment"])
if "volumeFog" in description["environment"]:
diff --git a/bench/reference/run.mjs b/bench/reference/run.mjs
index 193200e1..adb297d5 100644
--- a/bench/reference/run.mjs
+++ b/bench/reference/run.mjs
@@ -12,7 +12,10 @@ import { resolve } from 'node:path';
import { chromium } from 'playwright';
import { createServer } from 'vite';
-const WORK_DIRECTORY = resolve('artifacts/reference');
+// --khronos draws the Khronos sample assets in artifacts/khronos (Blender imports the same files) into their own work
+// directory, and scores them into khronos.json. Nothing in baseline.json or images/<scene>.jpg changes.
+const khronos = process.argv.includes('--khronos');
+const WORK_DIRECTORY = resolve(khronos ? 'artifacts/reference-khronos' : 'artifacts/reference');
const OUTPUT_DIRECTORY = resolve('bench/reference');
const CHROME = process.env.CHROME_PATH ?? 'C:/Program Files/Google/Chrome/Application/chrome.exe';
const BLENDER = process.env.BLENDER_PATH ?? 'C:/Program Files/Blender Foundation/Blender 5.2/blender.exe';
@@ -48,7 +51,7 @@ async function renderBackend(backend, serverUrl, graphics) {
const page = await browser.newPage({ viewport: { width: WIDTH, height: HEIGHT } });
const errors = [];
page.on('pageerror', error => errors.push(error.message));
- await page.goto(`${serverUrl}/bench/reference/harness.html`, { timeout: PAGE_LOAD_TIMEOUT });
+ await page.goto(`${serverUrl}/bench/reference/harness.html${khronos ? '?set=khronos' : ''}`, { timeout: PAGE_LOAD_TIMEOUT });
await page.waitForFunction(() => window.renderReferenceScene, null, { timeout: PAGE_LOAD_TIMEOUT });
const sceneIds = await page.evaluate(() => window.referenceSceneIds);
for (const id of sceneIds) {
@@ -61,6 +64,10 @@ async function renderBackend(backend, serverUrl, graphics) {
graphics[backend] = result.graphics;
await writeFile(`${WORK_DIRECTORY}/${id}-${backend}.png`, Buffer.from(result.image, 'base64'));
if (describe) await writeFile(`${WORK_DIRECTORY}/scenes/${id}.json`, JSON.stringify(result.description));
+ if (khronos && describe) {
+ const background = await page.evaluate(sceneId => window.renderReferenceScene(sceneId, { describe: false, backgroundOnly: true }), id);
+ await writeFile(`${WORK_DIRECTORY}/${id}-background.png`, Buffer.from(background.image, 'base64'));
+ }
const bakeNote = result.bake ? `, bake ${result.bake.seconds.toFixed(1)} s, ${result.bake.report.texels} texels` : '';
console.log(`${id} on ${backend}: ${Math.round(performance.now() - started)} ms${bakeNote}`);
}
@@ -134,6 +141,6 @@ if (!scoreOnly && !pathTracerFlag) {
if (!onlyScene || pathTracerFlag) {
runChecked('uv', [
'run', '--no-project', '--python', '3.12', '--with', 'flip-evaluator', '--with', 'pillow', '--with', 'numpy',
- 'python', '-I', 'bench/reference/score.py', WORK_DIRECTORY, OUTPUT_DIRECTORY, ...(pathTracerFlag ? ['--path-tracer'] : []),
+ 'python', '-I', 'bench/reference/score.py', WORK_DIRECTORY, OUTPUT_DIRECTORY, ...(pathTracerFlag ? ['--path-tracer'] : []), ...(khronos ? ['--khronos'] : []),
]);
}
diff --git a/bench/reference/scenes.js b/bench/reference/scenes.js
index 6c86b9a7..6c45ccb3 100644
--- a/bench/reference/scenes.js
+++ b/bench/reference/scenes.js
@@ -76,20 +76,97 @@ function wallQuad(width, height) {
};
}
-export const REFERENCE_SCENES = {
- async 'brick-graph'() {
- const lighting = await skyLighting();
- const pattern = normalizeMaterialPattern({ type: 'graph', graph: brickGraph(), mapping: 'uv', bump: 1, resolution: 512 });
- const { map, normalMap, boxMapScale, boxMapAxis } = materialPatternTextures(pattern);
- const wall = part('wall', wallQuad(6, 4), [0, 0, 0], [1, 1, 1], { color: [1, 1, 1], roughness: 0.85, map, normalMap, boxMapScale, boxMapAxis });
+function srgbToLinear(value) {
+ return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
+}
+
+function averageLinearColor(colorImage) {
+ const sums = [0, 0, 0];
+ const pixelCount = colorImage.width * colorImage.height;
+ for (let pixel = 0; pixel < pixelCount; pixel++) {
+ for (let channel = 0; channel < 3; channel++) {
+ sums[channel] += srgbToLinear(colorImage.data[pixel * 4 + channel] / 255);
+ }
+ }
+ return sums.map(sum => sum / pixelCount);
+}
+
+async function brickWallScene({ withGraph }) {
+ const lighting = await skyLighting();
+ const pattern = normalizeMaterialPattern({ type: 'graph', graph: brickGraph(), mapping: 'uv', bump: 1, resolution: 512 });
+ const { map, normalMap, boxMapScale, boxMapAxis } = materialPatternTextures(pattern);
+ const wall = withGraph
+ ? part('wall', wallQuad(6, 4), [0, 0, 0], [1, 1, 1], { color: [1, 1, 1], roughness: 0.85, map, normalMap, boxMapScale, boxMapAxis })
+ : part('wall', wallQuad(6, 4), [0, 0, 0], [1, 1, 1], { color: averageLinearColor(map.image), roughness: 0.85 });
+ if (withGraph) {
wall.material.graph = pattern.graph;
wall.material.graphBump = pattern.bump;
- return {
- parts: [floor([0.4, 0.38, 0.32]), wall], blenderWorld: lighting.blenderWorld,
- environment: environment(lighting, { keyColor: SUN_COLOR }),
- camera: { eye: [0, 2, 8.5], target: [0, 2, 0], up: [0, 1, 0], fov: 40, near: 0.1, far: 100 },
- shadow: { eye: [-6, 10, 8], target: [0, 1, 0], up: [0, 1, 0], extent: 8, near: 0.1, far: 40 },
- };
+ }
+ return {
+ parts: [floor([0.4, 0.38, 0.32]), wall], blenderWorld: lighting.blenderWorld,
+ environment: environment(lighting, { keyColor: SUN_COLOR }),
+ camera: { eye: [0, 2, 8.5], target: [0, 2, 0], up: [0, 1, 0], fov: 40, near: 0.1, far: 100 },
+ shadow: { eye: [-6, 10, 8], target: [0, 1, 0], up: [0, 1, 0], extent: 8, near: 0.1, far: 40 },
+ };
+}
+
+// Khronos glTF sample assets (issue #51), downloaded by hand into artifacts/khronos/<name>/<name>.glb. Blender imports
+// the same file with its own importer, so the reference is Cycles reading the asset, not our reading of it.
+// SheenChair is left out: its occlusion texture uses TEXCOORD_1, which parseGltf refuses (README, Khronos table).
+const KHRONOS_ASSET_NAMES = ['ClearCoatTest', 'TransmissionTest', 'AnisotropyBarnLamp', 'AnisotropyDiscTest'];
+const KHRONOS_VIEW_DIRECTION = [0.35, 0.25, 1];
+const KHRONOS_FIELD_OF_VIEW = 35;
+
+function worldBounds(parts) {
+ const minimum = [Infinity, Infinity, Infinity];
+ const maximum = [-Infinity, -Infinity, -Infinity];
+ for (const { geometry, matrix } of parts) {
+ for (let index = 0; index < geometry.positions.length; index += 3) {
+ const [x, y, z] = [geometry.positions[index], geometry.positions[index + 1], geometry.positions[index + 2]];
+ for (let axis = 0; axis < 3; axis++) {
+ const coordinate = matrix[axis] * x + matrix[4 + axis] * y + matrix[8 + axis] * z + matrix[12 + axis];
+ minimum[axis] = Math.min(minimum[axis], coordinate);
+ maximum[axis] = Math.max(maximum[axis], coordinate);
+ }
+ }
+ }
+ return { minimum, maximum };
+}
+
+function cameraAroundBounds({ minimum, maximum }) {
+ const center = minimum.map((low, axis) => (low + maximum[axis]) / 2);
+ const radius = Math.hypot(...minimum.map((low, axis) => maximum[axis] - low)) / 2;
+ const distance = (radius / Math.sin((KHRONOS_FIELD_OF_VIEW / 2) * Math.PI / 180)) * 1.05;
+ const length = Math.hypot(...KHRONOS_VIEW_DIRECTION);
+ const eye = center.map((value, axis) => value + (KHRONOS_VIEW_DIRECTION[axis] / length) * distance);
+ return { center, radius, camera: { eye, target: center, up: [0, 1, 0], fov: KHRONOS_FIELD_OF_VIEW, near: distance / 100, far: distance * 10 } };
+}
+
+async function khronosAssetScene(name) {
+ const lighting = await skyLighting();
+ const file = `artifacts/khronos/${name}/${name}.glb`;
+ const response = await fetch(`/${file}`);
+ const asset = await parseGltf(await response.arrayBuffer());
+ const { center, radius, camera } = cameraAroundBounds(worldBounds(asset.parts));
+ return {
+ parts: asset.parts, glb: file, blenderWorld: lighting.blenderWorld,
+ environment: environment(lighting, { keyColor: SUN_COLOR }),
+ camera,
+ shadow: { eye: [center[0] - radius, center[1] + radius * 2, center[2] + radius], target: center, up: [0, 1, 0], extent: radius * 1.5, near: radius * 0.1, far: radius * 8 },
+ };
+}
+
+export const KHRONOS_SCENES = Object.fromEntries(KHRONOS_ASSET_NAMES.map(name => [name, () => khronosAssetScene(name)]));
+
+export const REFERENCE_SCENES = {
+ async 'brick-graph'() {
+ return brickWallScene({ withGraph: true });
+ },
+
+ // The control for brick-graph: the same wall in the colour the graph averages to, with no maps, which is all a
+ // material without a graph could say. brick-graph must score better than this against Cycles (issue #50).
+ async 'brick-flat'() {
+ return brickWallScene({ withGraph: false });
},
async 'material-spheres'() {
diff --git a/bench/reference/score.py b/bench/reference/score.py
index a04d687b..66b351b4 100644
--- a/bench/reference/score.py
+++ b/bench/reference/score.py
@@ -27,6 +27,19 @@ def load_png(path):
return np.asarray(Image.open(path).convert("RGB"), dtype=np.float32) / 255
+COVERAGE_THRESHOLD = 0.03
+
+
+def asset_coverage_mask(background, asset_render):
+ """The pixels the asset changes, so a score is not diluted by the sky that both sides draw the same way."""
+ return np.abs(asset_render - background).max(axis=2) > COVERAGE_THRESHOLD
+
+
+def masked_flip_score(reference, test, mask):
+ error_map, _, _ = flip_evaluator.evaluate(reference.astype(np.float32), test.astype(np.float32), "LDR", inputsRGB=True)
+ return round(float(error_map[mask].mean()), 4)
+
+
def flip_score(reference, test):
_, mean_error, _ = flip_evaluator.evaluate(reference.astype(np.float32), test.astype(np.float32), "LDR", inputsRGB=True)
return round(float(mean_error), 4)
@@ -73,6 +86,7 @@ def main():
if "--path-tracer" in sys.argv:
score_path_tracer(Path(sys.argv[1]), Path(sys.argv[2]))
return
+ khronos = "--khronos" in sys.argv
work_directory = Path(sys.argv[1])
output_directory = Path(sys.argv[2])
images_directory = output_directory / "images"
@@ -92,13 +106,23 @@ def main():
"eevee-vs-cycles": flip_score(cycles, eevee),
"gpu-vs-cpu": flip_score(cpu, gpu),
}
+ if khronos:
+ mask = asset_coverage_mask(load_png(work_directory / f"{scene_id}-background.png"), gpu)
+ scores["asset-pixels"] = round(float(mask.mean()), 4)
+ scores["asset-gpu-vs-cycles"] = masked_flip_score(cycles, gpu, mask)
+ scores["asset-gpu-vs-eevee"] = masked_flip_score(eevee, gpu, mask)
+ scores["asset-eevee-vs-cycles"] = masked_flip_score(cycles, eevee, mask)
results[scene_id] = scores
- side_by_side(cycles, eevee, gpu, scores).save(images_directory / f"{scene_id}.jpg", quality=80)
+ image_name = f"khronos-{scene_id}" if khronos else scene_id
+ side_by_side(cycles, eevee, gpu, scores).save(images_directory / f"{image_name}.jpg", quality=80)
timings = json.loads((work_directory / "blender-timings.json").read_text(encoding="utf-8"))
graphics = json.loads((work_directory / "graphics.json").read_text(encoding="utf-8"))
report = {"metric": "FLIP (LDR), mean error, lower is better", **timings, "graphics": graphics, "scores": results}
- (output_directory / "baseline.json").write_text(json.dumps(report, indent=1) + "\n", encoding="utf-8")
+ report_name = "khronos.json" if khronos else "baseline.json"
+ (output_directory / report_name).write_text(json.dumps(report, indent=1) + "\n", encoding="utf-8")
columns = ["gpu-vs-cycles", "gpu-vs-eevee", "cpu-vs-cycles", "cpu-vs-eevee", "eevee-vs-cycles", "gpu-vs-cpu"]
+ if khronos:
+ columns += ["asset-pixels", "asset-gpu-vs-cycles", "asset-gpu-vs-eevee", "asset-eevee-vs-cycles"]
print("scene".ljust(20) + "".join(column.rjust(17) for column in columns))
for scene_id, scores in results.items():
print(scene_id.ljust(20) + "".join(f"{scores[column]:.4f}".rjust(17) for column in columns))
diff --git a/docs/parity.md b/docs/parity.md
index d297b8b1..f2cd0e12 100644
--- a/docs/parity.md
+++ b/docs/parity.md
@@ -200,8 +200,8 @@ To move to a new Blender release, run `node scripts/parity-manual-snapshot.mjs`.
| Rendering > Materials > Line Art | missing | No line rendering. | | |
| Rendering > Materials > Legacy Textures | out of scope | Blender keeps these for old files. | | |
| Rendering > Shader Nodes > Input | partial | `uv` coordinates only. There is no object, geometry, camera or light-path input. | [material-graph](../tests/material-graph.test.js) | #50 |
-| Rendering > Shader Nodes > Output | partial | A graph makes base colour, roughness, metallic, emission and height. It is baked to textures on the CPU, so it can not react to light, view or position. | [material-graph](../tests/material-graph.test.js), [brick-graph scene](../bench/reference/scenes.js) | #50 |
-| Rendering > Shader Nodes > Shader | partial | A metallic-roughness surface with clear coat, transmission, sheen and specular layers, and unlit, liquid and foam tags. Anisotropy (key, fill and local lights, and a bent environment lookup) and thin-film iridescence follow the glTF extensions rather than Blender's tangent and thin-film inputs, scored in the `brushed-film` reference scene. There is no subsurface. | [material-layers](../tests/material-layers.test.js) | #51 |
+| Rendering > Shader Nodes > Output | partial | A graph makes base colour, roughness, metallic, emission and height. It is baked to textures on the CPU, so it can not react to light, view or position. The `brick-graph` reference scene scores 0.2269 against Cycles; its `brick-flat` control (the graph's average colour, no maps) is the baseline it is compared with, and a bump of 0 would score 0.2065, so the bump is stronger than Blender's, not weaker. | [material-graph](../tests/material-graph.test.js), [brick-graph scene](../bench/reference/scenes.js) | #50 |
+| Rendering > Shader Nodes > Shader | partial | A metallic-roughness surface with clear coat, transmission, sheen and specular layers, and unlit, liquid and foam tags. Anisotropy (key, fill and local lights, and a bent environment lookup) and thin-film iridescence follow the glTF extensions rather than Blender's tangent and thin-film inputs, scored in the `brushed-film` reference scene. Khronos sample assets (`npm run reference -- --khronos`, files downloaded by hand) score 0.23 to 0.48 against Cycles on the pixels the asset covers (0.13 to 0.38 for EEVEE): the glTF anisotropy textures and the other texture slots inside layer extensions are not read, and on both anisotropy assets the factor alone scores worse than no anisotropy. There is no subsurface. | [material-layers](../tests/material-layers.test.js) | #51 |
| Rendering > Shader Nodes > Displacement | partial | Bump: a graph's height becomes a normal map. There is no displacement of the surface. | [material-graph](../tests/material-graph.test.js) | #50 |
| Rendering > Shader Nodes > Texture | partial | Image maps, 11 pattern presets, and graph nodes for noise, voronoi, wave, checker and gradient. Noise is not Blender's noise function, and there is no brick, musgrave, magic or environment node. Patterns follow UVs or box projection. | [material-patterns](../tests/material-patterns.test.js), [material-graph](../tests/material-graph.test.js), [brick-graph scene](../bench/reference/scenes.js) | #50 |
| Rendering > Shader Nodes > Color | partial | Color ramp, mix and invert. There is no hue, curves, gamma or blend modes. | [material-graph](../tests/material-graph.test.js) | #50 |
diff --git a/src/gltf.js b/src/gltf.js
index 8e148d0a..6483196d 100644
--- a/src/gltf.js
+++ b/src/gltf.js
@@ -10,7 +10,8 @@ import { MAX_MORPH_TARGETS, createMorphPose, validateMorphGeometry, validateMorp
export const GLTF_CAPABILITIES = Object.freeze({
formats: ['glb', 'gltf'],
supported: ['triangle meshes', 'world transforms', 'rigid node animations', 'four-influence skeletal skinning', 'joint node animations', 'relative POSITION/NORMAL morph targets', 'morph weight animations', 'PNG/JPEG base color textures', 'normal/occlusion/emissive/metallic-roughness textures', 'TEXCOORD_0', 'linear RGB vertex colors', 'metallic roughness factors', 'emissive factors', 'alpha mask and blend modes', 'double-sided materials', 'KHR_mesh_quantization', 'KHR_materials_emissive_strength', 'KHR_materials_clearcoat, transmission, volume, ior, specular, sheen, anisotropy and iridescence factors', 'KHR_texture_transform baked into UVs', 'EXT_mesh_gpu_instancing expanded into parts', 'KHR_draco_mesh_compression with options.decoders.draco', 'EXT_meshopt_compression with options.decoders.meshopt', 'KHR_texture_basisu with options.decoders.ktx2'],
- ignoredExtensions: [],
+ // The primitive's own material is drawn; the other variants are not selectable.
+ ignoredExtensions: ['KHR_materials_variants'],
unsupported: ['more than four skin influences', 'singular weighted skin transforms', 'reflected skin transforms', 'TANGENT morph targets', 'morph targets without authored base normals', 'vertex alpha below one', 'different texture transforms on one material', 'skinned or morphed GPU instancing', 'textures inside material layer extensions (factors only)'],
});
@@ -26,7 +27,10 @@ const DEFAULT_MAX_BYTES = 32 * 1024 * 1024;
const DEFAULT_MAX_VERTICES = 2_000_000;
const GLTF_ALPHA_MODES = { OPAQUE: 'opaque', MASK: 'mask', BLEND: 'blend' };
const DEFAULT_MAX_INSTANCES = 4096;
-const ALLOWED_EXTENSIONS = new Set(['KHR_mesh_quantization', 'KHR_materials_emissive_strength', 'KHR_texture_transform', 'EXT_mesh_gpu_instancing', ...GLTF_LAYER_EXTENSIONS]);
+// KHR_xmp_json_ld and its earlier name KHR_xmp only carry metadata (authors, licences) and change nothing drawn: the
+// Khronos sample assets list them, and a file must not be refused for them.
+const METADATA_EXTENSIONS = ['KHR_xmp_json_ld', 'KHR_xmp'];
+const ALLOWED_EXTENSIONS = new Set(['KHR_mesh_quantization', 'KHR_materials_emissive_strength', 'KHR_texture_transform', 'EXT_mesh_gpu_instancing', ...METADATA_EXTENSIONS, ...GLTF_LAYER_EXTENSIONS]);
const DECODER_BY_EXTENSION = { KHR_draco_mesh_compression: 'draco', EXT_meshopt_compression: 'meshopt', KHR_texture_basisu: 'ktx2' };
// Accepted when optional, because 67js does not render them. Rejected when listed in extensionsRequired.
const IGNORED_EXTENSIONS = new Set(GLTF_CAPABILITIES.ignoredExtensions);
diff --git a/tests/gltf-extensions.test.js b/tests/gltf-extensions.test.js
index 6bc4f9e3..9753dbc4 100644
--- a/tests/gltf-extensions.test.js
+++ b/tests/gltf-extensions.test.js
@@ -209,6 +209,18 @@ test('anisotropy and iridescence import as material layers without a warning', a
assert.deepEqual(asset.warnings, []);
});
+test('metadata extensions such as KHR_xmp_json_ld and the earlier KHR_xmp do not stop an import', async () => {
+ const asset = await parseGltf(triangleDocument({
+ edit: document => {
+ document.extensionsUsed = ['KHR_xmp', 'KHR_xmp_json_ld'];
+ document.extensions = { KHR_xmp_json_ld: { packets: [] } };
+ document.asset.extensions = { KHR_xmp: { packet: 0 } };
+ },
+ }));
+ assert.equal(asset.parts.length, 1);
+ assert.deepEqual(asset.warnings, []);
+});
+
test('required material extensions, bad layer values and missing decoders are rejected', async () => {
const required = triangleDocument({ edit: document => { document.extensionsRequired = ['KHR_materials_unlit']; } });
await assert.rejects(parseGltf(required), /Unsupported glTF extension: KHR_materials_unlit/);
diff --git a/tests/reference-baseline.test.js b/tests/reference-baseline.test.js
index f4787f4c..00f241ce 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-graph', 'brick-room', 'brushed-film', 'car-paint', 'character', 'fog', 'foliage', 'glass', 'lit-interior', 'material-spheres', 'metal', 'outdoor-hdri', 'spot-area'];
+const EXPECTED_SCENES = ['brick-flat', 'brick-graph', 'brick-room', 'brushed-film', 'car-paint', 'character', 'fog', 'foliage', 'glass', 'lit-interior', 'material-spheres', 'metal', 'outdoor-hdri', 'spot-area'];
const EXPECTED_SCORES = ['cpu-vs-cycles', 'cpu-vs-eevee', 'eevee-vs-cycles', 'gpu-vs-cpu', 'gpu-vs-cycles', 'gpu-vs-eevee'];
test('the render baseline scores every scene with every renderer pair', () => {