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(render-service): a preset's shadow filter now selects a filter (#86)

Matthew Kissinger929562755e4d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6c7d7e28..16f9e1c3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,37 @@
Changes to `@kiln/engine`. Source and installable packages are distributed through
GitHub. The package is not published on the npm registry.
+## A preset's shadow filter now selects a filter — 2026-09-12
+
+- Going to compare shadow filters by eye turned up the reason there was nothing to
+ compare: **no shipped presentation preset enables shadows.** `neutral-studio-v1` sets
+ `shadows.enabled: false` to preserve the pre-registry visual, `gallery-studio-v1` is a
+ spread of it, and every light has `castsShadow: false`. So r186 deleting the PCFSoft
+ implementation is not a visible regression here, and yesterday's switch to
+ `PCFShadowMap` corrected a line that never runs. Its claim to keep the log clean was
+ overstated: the assignment sits inside `if (preset.shadows.enabled)`, so three's
+ deprecation warning never fired from this service either.
+- What was actually wrong is that `shadows.type` described a filter and selected nothing.
+ The validator demanded the exact string `pcf-soft` while the renderer ignored the field
+ and hardcoded a constant — and after r186, the one name the schema accepted was the one
+ name that no longer exists.
+- It selects a filter now. `SHADOW_FILTERS` is `basic`, `pcf`, `vsm` — what r186 left —
+ and the renderer maps each to its three constant. `vsm` is the soft option that
+ survives, with one catch recorded where someone choosing it will read it: under VSM
+ every shadow receiver also casts, so a ground plane starts casting too.
+- The names live in the schema that validates them and the constants live in the module
+ that imports three, so the renderer checks at load that the map covers the list. A name
+ the validator accepts and the map lacks would set `shadowMap.type` to `undefined` mid
+ render — not a crash, just a quietly different image. Verified by adding `pcf-soft` back
+ to the list and watching the service refuse to start.
+- The gallery is not affected either, for a different reason: neither `<Canvas>` in the
+ site sets r3f's `shadows` prop, so `renderer.shadowMap.enabled` stays false there too,
+ and the only shadowing on that surface is drei's `ContactShadows` — its own depth pass to
+ a texture, which never consults `shadowMap.type`. Between the two paths, r186's PCFSoft
+ removal changes nothing anyone can see in this repository.
+- Worth knowing while reading this: `render-service` runs in **no** CI workflow. Its 37
+ tests and its GPU conformance runs are manual only.
+
## The lint baseline is zero, and stays zero — 2026-09-12
- `bun run lint` reported **14 warnings and 11 infos** and exited 0. All 25 are fixed;
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 05bf53c2..7b401a1e 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
@@ -1575,7 +1575,7 @@ than for more care.
| 13.3 | Raise the coverage ratchet from 92/91 to 94/92. Measured 95.27% functions / 92.49% lines, so this keeps roughly 1.3 and 0.5 points for normal churn | **Done 2026-09-12.** In absolute terms that is 42 functions and 224 lines of room, which is what the gate now prints -- a percentage says whether it passed, and turning that into work needs LCOV totals the person who tripped it does not have. The gate also refuses a threshold set above the baseline it records, and refuses a thresholds file that records no baseline: a threshold above anything ever measured fails in whatever change runs next and reads there as that change's regression |
| 13.4 | Promote the Windows job from `continue-on-error` to blocking | **Done 2026-09-12 in the repository; one GitHub setting outstanding.** Nine runs with the job: seven green, two red, no recurrence of the GLib fault, and four consecutive greens including two on main. Both reds were this session's own new code and both were real Windows-only defects, which is the argument for blocking. Given a 30-minute bound, since a blocking job that hangs is a blocked merge. A test now rejects `continue-on-error` at job level so this cannot be demoted by one line. **Outstanding:** main's branch protection lists only `typecheck . lint . test`, so a red Windows run fails the workflow and still permits the merge until the Windows context is added there |
| 13.5 | Clear the one substantive lint finding: an unused import in `src/__tests__/optimize.test.ts`. Everything else in the 14/11 baseline is `useTemplate` and `useOptionalChain` style | **Done 2026-09-12, wider than written.** The 14/11 split was not all style: `isFinite` in the render inspector was the coercing global, `forEach` in the Bradley-Terry fit returned a value its callback discards, and three `any` bounds in `buildSandboxGlobals` were guarded by `eslint-disable` comments in a repository that lints with Biome and has no ESLint config -- suppressing nothing while reading as accepted. All 25 findings are fixed and the tree reports zero. `lint` now runs `--error-on-warnings`, and since that does not reach Biome's info severity the seven rules involved carry an explicit `error`; each was verified by reintroducing its defect. A baseline kept in prose is one the next finding arrives invisible against, which is why this went past the single unused import |
-| 13.6 | Decide shadows by comparison, not assumption. r186 deleted the `PCFSoftShadowMap` implementation; `render-service` now names `PCFShadowMap`, and `VSMShadowMap` is the soft filter that survives. Render gallery presets under both and choose by eye, because this is the only user-visible regression in the r186 upgrade and it lands on marketing surface | Approved, not started |
+| 13.6 | Decide shadows by comparison, not assumption. r186 deleted the `PCFSoftShadowMap` implementation; `render-service` now names `PCFShadowMap`, and `VSMShadowMap` is the soft filter that survives. Render gallery presets under both and choose by eye, because this is the only user-visible regression in the r186 upgrade and it lands on marketing surface | **Premise was wrong; the real defect is fixed 2026-09-12.** **No shipped preset enables shadows** -- `neutral-studio-v1` sets `shadows.enabled: false` deliberately, `gallery-studio-v1` spreads it, and every light has `castsShadow: false`. So r186 is not a visible regression here and there is nothing to compare by eye: both filters render the same image, which has no shadow in it. Yesterday's `PCFShadowMap` edit corrected a line that never executes, and its claim about keeping the log clean was overstated -- the assignment is inside `if (preset.shadows.enabled)`, so the deprecation warning never fired either. What WAS wrong: `shadows.type` described a filter and selected nothing, and after r186 the one string the validator accepted was the one filter that no longer exists. It now selects from `basic`/`pcf`/`vsm`, the renderer maps each to its three constant, and the renderer checks at load that the map covers the schema's list -- verified by adding `pcf-soft` back and watching the service refuse to start. The gallery is unaffected for a second, independent reason: neither `<Canvas>` in `site/` sets r3f's `shadows` prop, so `shadowMap.enabled` is false there as well, and the only shadowing on that surface is drei's `ContactShadows`, which runs its own depth pass to a texture and never reads `shadowMap.type`. Across both paths r186's PCFSoft removal changes nothing anyone can see. **Open, and the founder's call:** whether a gallery preset should cast shadows at all -- a visual decision, not a repair, and the only thing a by-eye comparison would actually be for |
### Explicitly not in this phase
diff --git a/render-service/src/presentation-presets.mjs b/render-service/src/presentation-presets.mjs
index 6f110dec..74fe7677 100644
--- a/render-service/src/presentation-presets.mjs
+++ b/render-service/src/presentation-presets.mjs
@@ -46,6 +46,19 @@ function validateDirectional(value, path) {
if (typeof value.castsShadow !== 'boolean') throw new TypeError(`${path}.castsShadow must be boolean`);
}
+/**
+ * The shadow filters that exist, as preset-facing names.
+ *
+ * `pcf-soft` was here until r186 deleted the PCFSoft implementation. three kept the
+ * constant, warns on it, and substitutes PCFShadowMap -- so a preset naming it was
+ * asking for a filter that no longer exists and quietly receiving a different one.
+ * These three survive, and `renderer.mjs` maps each to its three constant, which is
+ * what makes this field select a filter rather than describe one. `vsm` is the soft
+ * option now, with one behavioural catch worth knowing before choosing it: under VSM
+ * every shadow receiver also casts, so a ground plane starts casting too.
+ */
+export const SHADOW_FILTERS = Object.freeze(['basic', 'pcf', 'vsm']);
+
function validatePreset(preset) {
exactKeys(preset, PRESET_KEYS, 'presentation preset');
if (!/^[a-z0-9]+(?:-[a-z0-9]+)*-v[1-9][0-9]*$/.test(preset.id)) {
@@ -70,7 +83,8 @@ function validatePreset(preset) {
`${preset.id}.shadows`,
);
if (typeof preset.shadows.enabled !== 'boolean') throw new TypeError(`${preset.id}.shadows.enabled must be boolean`);
- if (preset.shadows.type !== 'pcf-soft') throw new TypeError(`${preset.id}.shadows.type must be pcf-soft`);
+ if (!SHADOW_FILTERS.includes(preset.shadows.type))
+ throw new TypeError(`${preset.id}.shadows.type must be one of ${SHADOW_FILTERS.join(', ')}`);
tuple(preset.shadows.mapSize, 2, `${preset.id}.shadows.mapSize`, (entry, path) => {
if (!Number.isInteger(entry) || entry < 1 || entry > 8192) throw new TypeError(`${path} must be an integer in [1,8192]`);
});
@@ -103,7 +117,7 @@ const definitions = [
// Disabled preserves the exact pre-registry v1 visual behavior.
shadows: {
enabled: false,
- type: 'pcf-soft',
+ type: 'pcf',
mapSize: [1024, 1024],
bias: 0,
normalBias: 0,
diff --git a/render-service/src/renderer.mjs b/render-service/src/renderer.mjs
index a871f355..8c7657a3 100644
--- a/render-service/src/renderer.mjs
+++ b/render-service/src/renderer.mjs
@@ -15,6 +15,7 @@ import { validateRenderMode } from './contract.mjs';
import {
DEFAULT_PRESENTATION_PRESET_ID,
PRESENTATION_PRESET_IDS,
+ SHADOW_FILTERS,
getPresentationPreset,
} from './presentation-presets.mjs';
@@ -163,13 +164,30 @@ function disposeGltf(gltf) {
}
}
+/**
+ * Preset filter name -> three constant. The schema owns the names because it validates
+ * them; this owns the constants because it is the module that imports three.
+ *
+ * The two have to cover each other, so that is checked here rather than remembered: a
+ * name the validator accepts and this map lacks would set `shadowMap.type` to undefined
+ * at render time, which is not a crash -- just a quietly different image. Note the
+ * comparison is against undefined, since BasicShadowMap is 0.
+ */
+const SHADOW_MAP_TYPES = {
+ basic: THREE.BasicShadowMap,
+ pcf: THREE.PCFShadowMap,
+ vsm: THREE.VSMShadowMap,
+};
+for (const name of SHADOW_FILTERS) {
+ if (SHADOW_MAP_TYPES[name] === undefined) {
+ throw new Error(`presentation preset shadow filter '${name}' has no three constant`);
+ }
+}
+
function applyPresentationPreset(renderer, scene, root, preset, environment) {
renderer.toneMappingExposure = preset.exposure;
renderer.shadowMap.enabled = preset.shadows.enabled;
- // r186 removed the PCFSoft implementation: three keeps the constant, warns, and
- // substitutes PCFShadowMap anyway. Naming the real filter keeps the log clean and
- // makes the shadow this service actually produces legible from the source.
- if (preset.shadows.enabled) renderer.shadowMap.type = THREE.PCFShadowMap;
+ if (preset.shadows.enabled) renderer.shadowMap.type = SHADOW_MAP_TYPES[preset.shadows.type];
scene.background = new THREE.Color(preset.background);
scene.environment = environment;
diff --git a/render-service/test/presentation-presets.test.mjs b/render-service/test/presentation-presets.test.mjs
index 9635f178..e402791b 100644
--- a/render-service/test/presentation-presets.test.mjs
+++ b/render-service/test/presentation-presets.test.mjs
@@ -4,6 +4,7 @@ import {
DEFAULT_PRESENTATION_PRESET_ID,
PRESENTATION_PRESET_CAPABILITIES,
PRESENTATION_PRESET_IDS,
+ SHADOW_FILTERS,
getPresentationPreset,
isPresentationPresetId,
} from '../src/presentation-presets.mjs';
@@ -51,7 +52,7 @@ describe('versioned presentation preset registry', () => {
rim: { enabled: true, color: 0xffead6, intensity: 1.2, position: [-2, 5, -5], castsShadow: false },
shadows: {
enabled: false,
- type: 'pcf-soft',
+ type: 'pcf',
mapSize: [1024, 1024],
bias: 0,
normalBias: 0,
@@ -61,6 +62,23 @@ describe('versioned presentation preset registry', () => {
assert.equal(recursivelyFrozen(getPresentationPreset('neutral-studio-v1')), true);
});
+ // `shadows.type` described a filter and selected nothing: the validator demanded the
+ // string `pcf-soft` while the renderer hardcoded a constant and never read the field.
+ // r186 then deleted the PCFSoft implementation outright, so the one name the schema
+ // accepted was the one name that no longer exists. These are the filters that do.
+ it('offers only shadow filters that r186 left, and every preset names one of them', () => {
+ assert.deepEqual(SHADOW_FILTERS, ['basic', 'pcf', 'vsm']);
+ assert.equal(Object.isFrozen(SHADOW_FILTERS), true);
+ assert.equal(SHADOW_FILTERS.includes('pcf-soft'), false);
+ for (const id of PRESENTATION_PRESET_IDS) {
+ const { shadows } = getPresentationPreset(id);
+ assert.ok(
+ SHADOW_FILTERS.includes(shadows.type),
+ `${id} names shadow filter ${shadows.type}, which is not one of ${SHADOW_FILTERS.join(', ')}`,
+ );
+ }
+ });
+
it('resolves by ID only and rejects unknown IDs at the request and receipt boundaries', () => {
assert.equal(isPresentationPresetId('neutral-studio-v1'), true);
assert.equal(isPresentationPresetId('dramatic-night-v1'), false);