Skip to content

armgit / kiln

Public Imported from GitHub
0

Build and revise procedural 3D assets with your coding agent. Local MCP server, CLI and TypeScript engine with rendered review, editable source and GLB export.

fix: the GPU material conformance check was blocked by its own guard (11.3) (#73)

Matthew Kissinger1ac6ce3ebe47
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 51042867..cd1a473d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,27 @@
Changes to `@kiln/engine`. Source and installable packages are distributed through
GitHub. The package is not published on the npm registry.
+## The GPU material check runs for the first time — 2026-09-11
+
+- `render-service/test/material-conformance.mjs` is the only automated evidence
+ that the GPU path applies textures at all, and it had never passed. It replaces
+ `globalThis.fetch` with a thrower to prove an embedded fixture never crosses a
+ network boundary — but `blob:` is an **in-memory** object URL, and three's
+ `GLTFLoader` mints one per embedded image that `ImageBitmapLoader` reads back
+ through `fetch`. The guard blocked the only path a texture has into the
+ renderer, so the file measured an untextured render and asserted against it:
+ `lumaSpread: 0` on the albedo checker, with the real cause printed as a loader
+ warning nobody read. `blob:` is now exempt, and the guard self-checks that an
+ `https:` fetch still throws.
+- Its normal-map threshold was `>= 3` and had **never been evaluated**, because
+ the albedo assertion above it always failed first. Recalibrated to `>= 1` from
+ measurement. The small number is the tone curve rather than a weak response:
+ that panel sits at mean luma ~242 of 255 under the fixture's own exposure of
+ 1.38, past the ACES shoulder. Measured 1.51 at exposure 1.38 and 2.61 at 0.9
+ with nothing else changed — which is also the proof that the map applies. An
+ absent normal map reads near zero, the way the albedo checker read exactly 0.
+- All six channels now verify: albedo, normal, shared ORM, AO, emissive, alpha.
+
## Artifact identity stops tracking the serializer's version — 2026-09-11
- **`asset.generator` is now a stable `"Kiln"`.** It defaulted to the serializer's
diff --git a/docs/plans/repo-size-and-r2-migration-2026-09-10.md b/docs/plans/repo-size-and-r2-migration-2026-09-10.md
index c8f5efbb..764aa0dc 100644
--- a/docs/plans/repo-size-and-r2-migration-2026-09-10.md
+++ b/docs/plans/repo-size-and-r2-migration-2026-09-10.md
@@ -1354,7 +1354,8 @@ put a renderer on somebody's LAN is not a choice to make on their behalf.
| --- | --- | --- |
| 11.1 | Start the packaged render service on demand from the MCP server, join one already listening, stop only what was started | Done 2026-09-11; closes 9.7 |
| 11.2 | Ship `render-service/` in the package so the `instructions` claim is true, and move `webgpu` to 0.6.0 | Done 2026-09-11, smoked on hardware |
-| 11.3 | `material-conformance.mjs` cannot load `blob:nodedata:` textures, so its albedo/normal/ORM checks assert against an untextured render. Pre-existing on 0.4.0; real assets texture correctly | Open |
+| 11.3 | `material-conformance.mjs` cannot load `blob:nodedata:` textures, so its albedo/normal/ORM checks assert against an untextured render | **Done 2026-09-11, and the cause was the file's own guard.** It replaces `globalThis.fetch` with a thrower to prove an embedded fixture never crosses a network boundary -- but `blob:` is an in-memory object URL, and GLTFLoader mints one per embedded image that `ImageBitmapLoader` reads back through `fetch`. The guard blocked the only path a texture has into the renderer, and the file then measured an untextured render and asserted against it. `blob:` is now exempt and the guard self-checks that `https:` still throws. First `PASS` this file has ever produced |
+| 11.5 | `material-conformance.mjs`'s normal-map threshold was `>= 3` and had never been evaluated, because the albedo assertion above it always failed first. Recalibrated to `>= 1` from measurement | Done 2026-09-11. The small number is the tone curve, not a weak response: the panel sits at mean luma ~242 of 255 under the fixture's own exposure of 1.38, past the ACES shoulder. Measured 1.51 at exposure 1.38 and 2.61 at 0.9 with nothing else changed, which is also the proof the map applies. The check still discriminates what it must -- an absent normal map reads near zero, the way the albedo checker read exactly 0.0 while textures were blocked |
| 11.4 | Give the CLI the same on-demand start behind an explicit flag. Deliberately excluded: a one-shot render should not pay a GPU startup, and `auto` must stay instant on a CPU-only machine | Not planned; revisit if asked |
### 6.4 is not independent of 6.2
diff --git a/render-service/test/material-conformance.mjs b/render-service/test/material-conformance.mjs
index f4b0fb52..c4404890 100644
--- a/render-service/test/material-conformance.mjs
+++ b/render-service/test/material-conformance.mjs
@@ -11,12 +11,35 @@ const noHardware = /(?:no webgpu adapter|no usable .*device|software adapter ref
// A fixture with embedded PNG buffer views has no reason to cross a network
// boundary. Fail closed if a loader regression ever attempts to do so.
+//
+// `blob:` is exempt, and has to be. It is an in-memory object URL, not a network
+// boundary: GLTFLoader mints one per embedded image and ImageBitmapLoader reads
+// it back through `fetch`. Blocking every scheme therefore blocked the only path
+// an embedded texture has into the renderer, and this file then measured an
+// untextured render and asserted against it -- `lumaSpread: 0` on the albedo
+// checker, with the real cause printed as a loader warning nobody read. The
+// guard defeated the thing it was guarding.
+const passthroughFetch = globalThis.fetch;
Object.defineProperty(globalThis, 'fetch', {
configurable: true,
writable: true,
- value: async () => { throw new Error('network disabled in local material conformance'); },
+ value: async (input, init) => {
+ const target = String(typeof input === 'string' ? input : (input?.url ?? input));
+ if (target.startsWith('blob:')) return passthroughFetch(input, init);
+ throw new Error(`network disabled in local material conformance: ${target}`);
+ },
});
+// The exemption is a hole in a guard, so prove the guard is still closed around
+// it before rendering anything through it.
+await globalThis.fetch('https://example.invalid/texture.png').then(
+ () => { throw new Error('network guard is open: an https fetch was permitted'); },
+ (error) => {
+ if (!/network disabled/.test(String(error?.message ?? error)))
+ throw new Error(`network guard failed for an unexpected reason: ${error}`);
+ },
+);
+
function pixelsIn(png, [x0, y0, x1, y1]) {
const pixels = [];
for (let y = y0; y < y1; y += 1) {
@@ -103,8 +126,23 @@ async function main() {
assert.ok(stats.AlbedoChecker.lumaSpread >= 45,
`albedo checker did not modulate base color: ${stats.AlbedoChecker.lumaSpread}`);
+ // This threshold is measured, and it was previously a guess that had never run:
+ // the albedo assertion above always failed first, so nothing below it was ever
+ // evaluated against a real render. What it has to discriminate is "the normal
+ // map perturbs shading" from "the normal map is absent", and absent reads as
+ // roughly zero -- the way the albedo checker read exactly 0 while textures were
+ // being blocked.
+ //
+ // The value is small because the tone curve compresses it, not because the
+ // response is weak. This panel sits at mean luma ~242 of 255 under the fixture's
+ // own `neutral-studio-v1` exposure of 1.38, which is past the shoulder of the
+ // ACES curve where a perturbation barely moves an 8-bit output. Measured on
+ // dawn-vulkan/GTX 1660 Ti: 1.51 at exposure 1.38, and 2.61 at the
+ // `gallery-studio-v1` exposure of 0.9 with nothing else changed. Re-exposing the
+ // fixture would buy headroom and is the better instrument, but it would change
+ // what this file conforms -- the default tool rig.
const normalDelta = lumaDelta(halves(png, region('NormalResponse')));
- assert.ok(normalDelta >= 3,
+ assert.ok(normalDelta >= 1,
`normal map halves did not change lighting response: ${normalDelta.toFixed(1)}`);
assert.ok(stats.SharedOrmResponse.lumaSpread >= 5,