3D engine that AI agents drive
Merge origin/main into feat/path-tracer
Nguyen Xuan Anfe66a5845b53
diff --cc CHANGELOG.mdindex 03736a2e,84d2c8bb..c9df8b85--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -2,8 -2,13 +2,15 @@@## Unreleased+- Add `67js/addons/path-tracer` (part of issue #57; the Cycles comparison is partial). `renderPathTracedImage({ parts, environment, camera }, options)` draws a still by CPU path tracing against the triangle BVH of the light bake, with next-event estimation for the sun, point, spot and area lights, an importance-sampled environment map, GGX metal, clear coat, glass, maps and cutouts, and a wavelet denoiser, on up to eight module workers. An `image` render job selects it with `settings.renderer: { type: "pathTracer", samples, bounces, denoise, seed, maxSeconds }`; the same recipe and seed give the same PNG, a job past `maxSeconds` fails with no image, and samples, size and ray work are bounded. It loads on demand: the core bundle and the agent scene do not carry it (the limits live in `src/path-tracer-capabilities.js`, listed under `jobs.pathTracer` in `scene_capabilities`; the tool schemas gain one `renderer` field inside the total budget). `npm run reference -- --path-tracer` scores it against Cycles: better than the rasterizer on 7 of the 11 reference scenes (`lit-interior` 0.5055 to 0.1993, `spot-area` 0.1242 to 0.0639), worse on `outdoor-hdri`, `character` and `fog`, mean 0.171 against 0.189. Not drawn: volume fog, normal maps, translucent leaves, caustics, lights seen in mirrors. `src/ray-query.js` now holds the ray query and light falloff that `light-bake` used to carry. `npm run smoke:path-tracer` checks it through MCP.++ - Fix the next agent tool errors (part of issue #66). `scene_review` and `scene_look` with `labels` on an imported asset failed with "needs the mesh code" because asset creation loaded the on-demand scene modules only for mesh edits; it now always does, and a test walks every preview path in a fresh process. `geometries` and `materials` are optional in a recipe. A failed `scene_create` says no scene was created and to call it again. `scene_inspect` on an asset accepts a source-node ID that holds one part and names the parts of one that holds several.++ - Fix the most common agent tool errors (part of issue #66). `scene_look` and `scene_review` with `labels` on an imported asset threw `Cannot read properties of undefined (reading 'map')` (an asset recipe has no materials list, and asset mesh reports are keyed by part ID); an engine fault now reaches the agent as one advice message and goes to stderr. A node that names a geometry and no material gets an explicit `default` material instead of an error. `sessionId` is optional on every tool and defaults to the active scene (189,159 to 188,872 schema bytes); an ID that names another scene is still rejected. `scene_apply` names the fix when `set-node` fields are wrapped in `node`. The bench look harness loads the on-demand scene modules, so motion recipes get a look score.++ - Rename the project from 67.js to 67js, with no dot, and the GitHub repository to `anxuanng/67js`. The npm package `@codepawlhq/67js`, the site domain and the Worker name stay.+ - Add a recipe timeline, job audio and an encoder choice (part of issue #60, first slice). A recipe `timeline` lists named shots played in order over the motion clock, each with a `duration`, an optional `motionStart`, a partial `camera` on top of the sampled one and a `dip` through black; `set-timeline` edits it. `settings.timeline: { start }` renders it as an image, stills or video: one clock drives the shot, the motion and the renderer, so a seek to any time gives the same frame as inside a video. `settings.audio: { file, offset }` mixes one `.wav`, `.mp3`, `.ogg` or `.flac` from the new `--audio <folder>` option into a video, checks that it covers the video, decodes both streams afterwards and reports `metrics.sync` (a gap over 50 ms fails the job); `settings.encoder` is `cpu` or `nvenc`. File names are plain names without paths, drives or protocols, files must be regular and at most 32 MiB, and ffmpeg gets `-protocol_whitelist file`; nothing else comes from the agent. Video jobs can last 60 s (was 30), still capped at 900 frames, so a 60 s video runs at 15 fps. Measured through MCP on SwiftShader (`npm run smoke:film-timeline`): 9 PNG seeks across three shots and a dip match 8 stills byte for byte, and a 60 s, 900 frame video with sound rendered in 58 s (84 s on a loaded machine) at 128 x 128 with the click in the decoded audio on the decoded cut frame (offset 0.1 ms, streams 20 ms apart). Tool schemas stay inside their budgets (the timeline is a record reference; fields are in `scene_capabilities` `filmTimeline`). Left out: resumable long renders, several audio tracks, gain, markers inside a shot, animation events, crossfades and timelines for imported assets. The video sequence editor stays a non-goal.+ - Decide on WebGPU (part of issue #56, no engine change): wait, WebGL2 stays the only backend. Headless Chrome 156 has a WebGPU adapter on the RTX 3060 with no flags, but none under the MCP `cpu` flags (`--use-angle=swiftshader`); the SwiftShader Vulkan adapter needs `--use-webgpu-adapter=swiftshader`. With three.js as a proxy on 3 bench scenes, WebGPU frames were 2.6 to 4.4 times WebGL on the GPU and 1.4 to 3.0 times on SwiftShader, and first frames were slower. Browser support, shader rewrite size (about 1,400 GLSL lines and 450 call sites) and bundle cost are in `docs/webgpu-decision.md`.- Add recipe particles and hair (part of issue #63, no new tool). A `particles` section holds seeded emitter systems (point, box, sphere or disc; gravity, drag, wind, a landing floor, size over life) and hair systems that grow strands from a surface node, loaded on demand with the new `particles` module (`src/particles.js`, `src/hair.js`). Each particle is a closed-form function of its seed, index and time, so a seek never replays: the same time gives the same particles, a seek backwards repeats them and a seeded system gives identical bytes (`npm run smoke:agent-particles` checks PNG bytes through the MCP preview, including a second session). Counts are bounded to 4 systems, 2000 particles each, 4000 in total and 100000 drawn vertices. New `set-particles` operation and a `particles` report in `scene_inspect`; the schema takes one record reference, so the tool schemas stay within the total budget and the fields live in `scene_capabilities`. Cloth and particles now share validation helpers (`src/agent-recipe-checks.js`). Left out: particle collisions and bounce, rotation, colour and alpha, hair collision and combing. The smoke, fire and liquid decision (no browser solver, with measured grid costs) is in `docs/physics.md`.- Add `67js/addons/light-bake` (part of issue #55; recipes, MCP, GLB export and reflection probes are not done). `bakeLightmaps(parts, lights, options)` traces cosine-weighted paths on the CPU against a triangle BVH and returns new parts that carry the light that bounces between surfaces (point lights and the sun, shadowed) as a lightmap texture drawn through the emissive map, with lightmap UVs from the `uv_unwrap` unwrap. The renderer and its shaders are untouched, so a scene without a bake renders as before and core size is unchanged. Bounded and deterministic: `samples`, `bounces`, `texelsPerUnit`, `maxResolution` and `maxSeconds` are range checked, texel, triangle, light and ray-work totals are checked before any ray is traced, and the same input gives the same bytes. Parts with their own maps, pattern, emission, skin or transparency are skipped and listed in the report. `npm run reference -- --bake lit-interior` takes `lit-interior` from 0.5055 to 0.1444 against Cycles (6 s bake); no other scene moved by more than 0.002. The package archive grows by 3,525 bytes (717,978 to 721,503). See `docs/light-bake.md`.diff --cc bench/reference/README.mdindex f2eadaf0,a66c2e87..7d672835--- a/bench/reference/README.md+++ b/bench/reference/README.md@@@ -52,27 -52,9 +52,27 @@@ EEVEE against Cycles is a yardstick: i- Scores come from one camera for each scene and one machine. They do not measure motion or speed.- This suite sets an HDRI from code and leaves occlusion off; `--ambient-occlusion <strength> [--ambient-occlusion-radius <units>]` turns it on. A recipe reaches only the named procedural setups, so these scores still describe a better environment than an agent gets (issue #53).- - The Blender leaf material has no translucency, and the 67.js foliage shader adds it by a trick. `foliage` is therefore partly a difference in materials.+ - The Blender leaf material has no translucency, and the 67js foliage shader adds it by a trick. `foliage` is therefore partly a difference in materials.- `render-blender.py` does not read normal maps. No scene uses one yet, so a new scene with a normal map must add that first.- - `glass` and `car-paint` use the real 67.js `transmission` and `clearcoat` layers, and the Blender side sets the same values on the Principled BSDF. 67.js refracts through the front surface only, so the sphere does not show the inverted sky that Cycles traces through the back face.+ - `glass` and `car-paint` use the real 67js `transmission` and `clearcoat` layers, and the Blender side sets the same values on the Principled BSDF. 67js refracts through the front surface only, so the sphere does not show the inverted sky that Cycles traces through the back face.- `car-paint` scored 0.1521 against Cycles and `glass` 0.1326 (it was 0.1450 with the `liquid` material). The other scenes scored the same as in the table above, to four digits. The table above is the 2026-10-30 baseline and has not been rewritten.- - `fog` has no noise on either side. EEVEE and 67.js approximate scattering, and Cycles follows 8 volume bounces.- - Sample counts are fixed: 256 for Cycles with denoising, 64 for EEVEE and 4 MSAA samples for 67.js.+ - `fog` has no noise on either side. EEVEE and 67js approximate scattering, and Cycles follows 8 volume bounces.+ - Sample counts are fixed: 256 for Cycles with denoising, 64 for EEVEE and 4 MSAA samples for 67js.++Path tracer (issue #57): `npm run reference -- --path-tracer [--samples 32]` draws each scene with `addons/path-tracer` (CPU, 960 by 540, four threads, below-normal priority) and scores it against the Cycles renders of an earlier run into `path-tracer.json`; `baseline.json` and `images/` stay as they are. Measured 2026-10-31 at 32 samples with the tracer's own denoiser, on a Ryzen 5 5600X that another session was also loading (seconds are wall time and are inflated by that):+- | Scene | 67.js rasterizer | Path tracer | Seconds | Not drawn by the tracer |++| Scene | 67js rasterizer | Path tracer | Seconds | Not drawn by the tracer |+| --- | --- | --- | --- | --- |+| `brick-graph` | 0.2269 | 0.1538 | 34.2 | normal map (bump) |+| `car-paint` | 0.1521 | 0.1372 | 44.5 | |+| `character` | 0.0995 | 0.1143 | 35.5 | |+| `fog` | 0.2612 | 0.5622 | 33.5 | volume fog |+| `foliage` | 0.1594 | 0.1597 | 126.1 | leaf translucency |+| `glass` | 0.1326 | 0.1237 | 50.3 | |+| `lit-interior` | 0.5055 | 0.1993 | 238.0 | |+| `material-spheres` | 0.1598 | 0.1215 | 66.8 | |+| `metal` | 0.1868 | 0.1467 | 43.2 | |+| `outdoor-hdri` | 0.0676 | 0.1036 | 25.1 | |+| `spot-area` | 0.1242 | 0.0639 | 71.6 | |++The mean against Cycles is 0.171 for the path tracer and 0.189 for the rasterizer (the light bake gets `lit-interior` to 0.1444, better than the tracer's 0.1993). The tracer is worse on `outdoor-hdri` and `character`: in the images the floor is darker than in Cycles (the cause is not found), and `fog` shows the missing volume. The denoiser blurs some soft shadows. Cycles used 256 samples. See `docs/path-tracer.md` for what the tracer draws and skips.diff --cc bench/reference/harness.jsindex cb271abc,4968127f..5c1f8672--- a/bench/reference/harness.js+++ b/bench/reference/harness.js@@@ -27,8 -26,35 +27,8 @@@ function plainData(value)return value;}- // Blender's glTF importer cannot reproduce this rig's pose (three.js and 67.js agree on it), so Blender gets the-function addWeightedTransform(output, offset, palette, joint, weight, x, y, z, translationWeight) {- const base = joint * 16;- output[offset] += weight * (palette[base] * x + palette[base + 4] * y + palette[base + 8] * z + palette[base + 12] * translationWeight);- output[offset + 1] += weight * (palette[base + 1] * x + palette[base + 5] * y + palette[base + 9] * z + palette[base + 13] * translationWeight);- output[offset + 2] += weight * (palette[base + 2] * x + palette[base + 6] * y + palette[base + 10] * z + palette[base + 14] * translationWeight);-}-+ // Blender's glTF importer cannot reproduce this rig's pose (three.js and 67js agree on it), so Blender gets the// skinned result as plain geometry. A score then measures shading, and not an importer's pose.-function bakeSkinnedGeometry(part) {- const { geometry, skin } = part;- const positions = new Float32Array(geometry.positions.length);- const normals = new Float32Array(geometry.normals.length);- const influenceCount = geometry.skinWeights.length / (geometry.positions.length / 3);- for (let vertex = 0; vertex < geometry.positions.length / 3; vertex++) {- const offset = vertex * 3;- for (let influence = 0; influence < influenceCount; influence++) {- const weight = geometry.skinWeights[vertex * influenceCount + influence];- if (weight === 0) continue;- const joint = geometry.skinIndices[vertex * influenceCount + influence];- addWeightedTransform(positions, offset, skin.jointMatrices, joint, weight, geometry.positions[offset], geometry.positions[offset + 1], geometry.positions[offset + 2], 1);- addWeightedTransform(normals, offset, skin.jointMatrices, joint, weight, geometry.normals[offset], geometry.normals[offset + 1], geometry.normals[offset + 2], 0);- }- const length = Math.hypot(normals[offset], normals[offset + 1], normals[offset + 2]) || 1;- for (let axis = 0; axis < 3; axis++) normals[offset + axis] /= length;- }- return { ...geometry, positions, normals };-}-function describeScene(id, scene) {const { map: _map, ...environment } = scene.environment;const geometries = new Map();diff --cc bench/reference/run.mjsindex 4b4c59e0,0066b721..193200e1--- a/bench/reference/run.mjs+++ b/bench/reference/run.mjs@@@ -1,9 -1,7 +1,9 @@@- // Renders the reference scenes in 67.js and Blender, then scores them: npm run reference+ // Renders the reference scenes in 67js and Blender, then scores them: npm run reference// --ambient-occlusion <strength> [--ambient-occlusion-radius <units>] turns occlusion on (off by default).- // --bake [<id>,<id>] bakes bounced light into the named scenes (every scene when no ids follow) before 67.js draws them;+ // --bake [<id>,<id>] bakes bounced light into the named scenes (every scene when no ids follow) before 67js draws them;// Blender still gets the plain scene.+// --path-tracer [--samples <n>] draws the scenes with the offline path tracer (src/path-tracer.js) instead, keeps the+// Cycles renders of an earlier run, and scores them into path-tracer.json. Nothing in baseline.json or images/ changes.// Use --score-only to score existing renders, --skip-blender to keep them, and --scene <id> for one scene.import { spawnSync } from 'node:child_process';import { mkdir, writeFile } from 'node:fs/promises';diff --cc bench/size/baseline.jsonindex b05e3a5b,dfc42b9e..36e2bac9--- a/bench/size/baseline.json+++ b/bench/size/baseline.json@@@ -14,9 -14,9 +14,9 @@@},"bundles": {"entry:core": {- "min": 283440,- "gzip": 80969,- "brotli": 68932- "min": 283396,- "gzip": 80960,- "brotli": 69030++ "min": 283499,++ "gzip": 80972,++ "brotli": 69112},"entry:model": {"min": 40093,@@@ -139,24 -134,24 +139,24 @@@"brotli": 762},"entry:agent-scene": {- "min": 203396,- "gzip": 62055,- "brotli": 53770- "min": 204341,- "gzip": 62404,- "brotli": 54057++ "min": 204745,++ "gzip": 62551,++ "brotli": 54219},"entry:agent-scene+lazy": {- "min": 593202,- "gzip": 200387,- "brotli": 174845- "min": 597350,- "gzip": 202187,- "brotli": 176409++ "min": 597754,++ "gzip": 202334,++ "brotli": 176571},"entry:agent-asset": {- "min": 297332,- "gzip": 92384,- "brotli": 80417- "min": 298200,- "gzip": 92709,- "brotli": 80775++ "min": 299072,++ "gzip": 93045,++ "brotli": 81048},"entry:agent-asset+lazy": {- "min": 628877,- "gzip": 210742,- "brotli": 183453- "min": 632948,- "gzip": 212517,- "brotli": 185086++ "min": 633820,++ "gzip": 212853,++ "brotli": 185359},"entry:hdri": {"min": 8075,@@@ -184,14 -179,14 +184,14 @@@"brotli": 67034},"scene:agent-scene": {- "min": 312794,- "gzip": 91262,- "brotli": 78388- "min": 313662,- "gzip": 91569,- "brotli": 78717++ "min": 314066,++ "gzip": 91720,++ "brotli": 78757},"scene:agent-scene+lazy": {- "min": 702600,- "gzip": 229597,- "brotli": 199427- "min": 706671,- "gzip": 231355,- "brotli": 201052++ "min": 707075,++ "gzip": 231506,++ "brotli": 201092}}}diff --cc bench/size/budgets.jsonindex 16696e80,c1facaf7..f11fd99b--- a/bench/size/budgets.json+++ b/bench/size/budgets.json@@@ -1,5 -1,5 +1,5 @@@{- "archiveBytes": 758000,- "archiveBytes": 758400,++ "archiveBytes": 781200,"goals": {"lit-box": 50000,"gltf-box": 80000,@@@ -28,19 -28,18 +28,19 @@@"entry:terrain": 3100,"entry:grass": 4400,"entry:clutter": 5300,- "entry:path-tracer": 12700,"entry:light-bake": 25400,++ "entry:path-tracer": 12900,"entry:texture-set": 900,- "entry:agent-scene": 63300,- "entry:agent-scene+lazy": 204400,- "entry:agent-asset": 94300,- "entry:agent-asset+lazy": 215000,- "entry:agent-scene": 63700,- "entry:agent-scene+lazy": 206300,- "entry:agent-asset": 94600,- "entry:agent-asset+lazy": 216800,++ "entry:agent-scene": 63900,++ "entry:agent-scene+lazy": 206400,++ "entry:agent-asset": 95000,++ "entry:agent-asset+lazy": 217200,"entry:hdri": 3300,"entry:camera-effects": 8600,"entry:render-passes": 1700,"scene:lit-box": 60200,"scene:gltf-box": 79700,- "scene:agent-scene": 93100,- "scene:agent-scene+lazy": 234200- "scene:agent-scene": 93500,- "scene:agent-scene+lazy": 236000++ "scene:agent-scene": 93600,++ "scene:agent-scene+lazy": 236200}}diff --cc bench/tool-cost-budgets.jsonindex bac98006,3ac2b7fd..6fc77d65--- a/bench/tool-cost-budgets.json+++ b/bench/tool-cost-budgets.json@@@ -1,9 -1,9 +1,9 @@@{- "measured": "2026-10-31, from scripts/measure-tool-cost.mjs; raised by 800 total and 150 for scene_apply for branch and labels fields (no new tool); raised by 650 total and 80 for scene_apply for clip layers, bone masks and retargeting through MCP; raised by 20 for scene_create and 20 for the scene_capabilities result after merging the expression language with the material graph; was 373388 schema bytes before shared IDs and recipe references; trimmed after the render-passes merge: material graph, depth of field, motion blur and passes details moved to scene_capabilities, budgets set to the measured value plus 0.5% (total 188267, scene_capabilities result 5167); raised by 95 for scene_apply and 690 for the scene_capabilities result for node relations; curve and text geometry entries shortened to a pointer at scene_capabilities curveText, budgets set to the measured value plus 0.5% (total 189468, scene_capabilities result 6399); then six modifier ops (weld, triangulate, edge_split, smooth, simple_deform, cast) added as one compact schema entry with details in scene_capabilities meshModifiers, entry and mesh_stack description shortened: total 190382 (budget unchanged at 190420), mesh_edit 34216 (budget 34220), scene_capabilities result 7042 (budget 7050); mesh_stack 11682 (budget 11690); after merging imported mesh topology with the modifier ops: raised the total to 190480 (measured 190471), mesh_edit to 34300 (measured 34293) and the scene_capabilities result to 7520 (measured 7512) for imported mesh edits; then cloth (recipe cloth, set-cloth, grid geometry) added with the total unchanged at 190480 (measured 189159): physics descriptions shortened and set-physics now takes the same record reference as set-motion, scene_create raised to 62150 and scene_apply lowered to 44130, scene_capabilities result raised to 8190 (measured 8176) for the cloth details; then particles and hair (recipe `particles`, set-particles) added with the total unchanged at 190480 (measured 189642, scene_create raised to 62350 and scene_apply to 44370 for the recipe particles reference and set-particles): the section is one record reference described in scene_capabilities, so the scene_capabilities result rose to 9570 (measured 9523) for the particle and hair fields",- "schemaTotalBytes": 190480,- "measured": "2026-10-31, from scripts/measure-tool-cost.mjs; raised by 800 total and 150 for scene_apply for branch and labels fields (no new tool); raised by 650 total and 80 for scene_apply for clip layers, bone masks and retargeting through MCP; raised by 20 for scene_create and 20 for the scene_capabilities result after merging the expression language with the material graph; was 373388 schema bytes before shared IDs and recipe references; trimmed after the render-passes merge: material graph, depth of field, motion blur and passes details moved to scene_capabilities, budgets set to the measured value plus 0.5% (total 188267, scene_capabilities result 5167); raised by 95 for scene_apply and 690 for the scene_capabilities result for node relations; curve and text geometry entries shortened to a pointer at scene_capabilities curveText, budgets set to the measured value plus 0.5% (total 189468, scene_capabilities result 6399); then six modifier ops (weld, triangulate, edge_split, smooth, simple_deform, cast) added as one compact schema entry with details in scene_capabilities meshModifiers, entry and mesh_stack description shortened: total 190382 (budget unchanged at 190420), mesh_edit 34216 (budget 34220), scene_capabilities result 7042 (budget 7050); mesh_stack 11682 (budget 11690); after merging imported mesh topology with the modifier ops: raised the total to 190480 (measured 190471), mesh_edit to 34300 (measured 34293) and the scene_capabilities result to 7520 (measured 7512) for imported mesh edits; then cloth (recipe cloth, set-cloth, grid geometry) added with the total unchanged at 190480 (measured 189159): physics descriptions shortened and set-physics now takes the same record reference as set-motion, scene_create raised to 62150 and scene_apply lowered to 44130, scene_capabilities result raised to 8190 (measured 8176) for the cloth details; then particles and hair (recipe `particles`, set-particles) added with the total unchanged at 190480 (measured 189642, scene_create raised to 62350 and scene_apply to 44370 for the recipe particles reference and set-particles): the section is one record reference described in scene_capabilities, so the scene_capabilities result rose to 9570 (measured 9523) for the particle and hair fields; after merging the film timeline (recipe timeline, set-timeline) with particles: total 190719 (budget 190730), scene_create 62464, scene_apply 44620, scene_capabilities result 9902",- "schemaTotalBytes": 190730,++ "measured": "2026-10-31, from scripts/measure-tool-cost.mjs; raised by 800 total and 150 for scene_apply for branch and labels fields (no new tool); raised by 650 total and 80 for scene_apply for clip layers, bone masks and retargeting through MCP; raised by 20 for scene_create and 20 for the scene_capabilities result after merging the expression language with the material graph; was 373388 schema bytes before shared IDs and recipe references; trimmed after the render-passes merge: material graph, depth of field, motion blur and passes details moved to scene_capabilities, budgets set to the measured value plus 0.5% (total 188267, scene_capabilities result 5167); raised by 95 for scene_apply and 690 for the scene_capabilities result for node relations; curve and text geometry entries shortened to a pointer at scene_capabilities curveText, budgets set to the measured value plus 0.5% (total 189468, scene_capabilities result 6399); then six modifier ops (weld, triangulate, edge_split, smooth, simple_deform, cast) added as one compact schema entry with details in scene_capabilities meshModifiers, entry and mesh_stack description shortened: total 190382 (budget unchanged at 190420), mesh_edit 34216 (budget 34220), scene_capabilities result 7042 (budget 7050); mesh_stack 11682 (budget 11690); after merging imported mesh topology with the modifier ops: raised the total to 190480 (measured 190471), mesh_edit to 34300 (measured 34293) and the scene_capabilities result to 7520 (measured 7512) for imported mesh edits; then cloth (recipe cloth, set-cloth, grid geometry) added with the total unchanged at 190480 (measured 189159): physics descriptions shortened and set-physics now takes the same record reference as set-motion, scene_create raised to 62150 and scene_apply lowered to 44130, scene_capabilities result raised to 8190 (measured 8176) for the cloth details; then particles and hair (recipe `particles`, set-particles) added with the total unchanged at 190480 (measured 189642, scene_create raised to 62350 and scene_apply to 44370 for the recipe particles reference and set-particles): the section is one record reference described in scene_capabilities, so the scene_capabilities result rose to 9570 (measured 9523) for the particle and hair fields; after merging the film timeline (recipe timeline, set-timeline) with particles: total 190719 (budget 190730), scene_create 62464, scene_apply 44620, scene_capabilities result 9902; then the path tracer renderer setting (drop z.int bounds, integers still checked by the job validator): total raised to 190830 (measured 190818)",++ "schemaTotalBytes": 190830,"schemaToolBytes": {- "scene_create": 62350,- "scene_apply": 44370,+ "scene_create": 62480,+ "scene_apply": 44640,"mesh_edit": 34300,"scene_create_asset": 19310,"mesh_stack": 11690diff --cc package.jsonindex ed06e302,30f2b4d9..b63feae4--- a/package.json+++ b/package.json@@@ -104,7 -103,7 +104,8 @@@"smoke:agent-assets": "node scripts/smoke-agent-assets.mjs","smoke:agent-render-jobs": "node scripts/smoke-agent-render-jobs.mjs","smoke:render-passes": "node scripts/smoke-render-passes.mjs",+ "smoke:path-tracer": "node scripts/smoke-path-tracer.mjs",+ "smoke:film-timeline": "node scripts/smoke-film-timeline.mjs","smoke:agent-motion": "node scripts/smoke-agent-motion.mjs","smoke:agent-physics": "node scripts/smoke-agent-physics.mjs","smoke:agent-cloth": "node scripts/smoke-agent-cloth.mjs",diff --cc scripts/agent-render-jobs.mjsindex 84b4c036,1e90ae65..afc441d6--- a/scripts/agent-render-jobs.mjs+++ b/scripts/agent-render-jobs.mjs@@@ -2,8 -2,8 +2,9 @@@ import { mkdir, open, readFile, writeFiimport { randomUUID, createHash } from 'node:crypto';import { isAbsolute, join, resolve } from 'node:path';- import { RENDER_PASS_NAMES } from '../src/agent-scene-capabilities.js';+ import { RENDER_PASS_NAMES, VIDEO_ENCODERS, AUDIO_FILE_PATTERN, MAXIMUM_VIDEO_SECONDS } from '../src/agent-scene-capabilities.js';+ import { normalizeFilmTimeline, filmTimelineDuration } from '../src/film-timeline.js';+import { PATH_TRACER_JOB_LIMITS } from '../src/path-tracer-capabilities.js';const UUID =/^[a-f0-9]{8}-[a-f0-9]{4}-[1-8][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/;const STATES = ['queued', 'running', 'finalizing', 'completed', 'cancelling', 'cancelled', 'failed', 'interrupted'];@@@ -58,7 -58,7 +59,7 @@@ function jsonCopy(value, maximum = MAXI}function settingsFrom(input, clips, recipe) {- objectKeys(input, ['kind', 'width', 'height', 'fps', 'duration', 'animation', 'motion', 'rendererTime', 'passes', 'renderer'], 'settings');- objectKeys(input, ['kind', 'width', 'height', 'fps', 'duration', 'animation', 'motion', 'rendererTime', 'passes', 'timeline', 'audio', 'encoder'], 'settings');++ objectKeys(input, ['kind', 'width', 'height', 'fps', 'duration', 'animation', 'motion', 'rendererTime', 'passes', 'renderer', 'timeline', 'audio', 'encoder'], 'settings');if (!['image', 'stills', 'video'].includes(input.kind)) throw new TypeError('kind must be image, stills or video.');const width = boundedNumber(input.width, 64, 1024, 'width', true);const height = boundedNumber(input.height, 64, 1024, 'height', true);@@@ -69,8 -71,18 +72,19 @@@if (frameCount > 900) throw new RangeError('Job exceeds 900 frames.');const result = { kind: input.kind, width, height, fps, duration, frameCount };if (input.passes !== undefined) result.passes = passesFrom(input.passes, input.kind);+ if (input.renderer !== undefined) result.renderer = rendererFrom(input.renderer, input.kind, input.passes);const lastSampleTime = input.kind === 'image' ? 0 : input.kind === 'stills' ? duration : (frameCount - 1) / fps;+ if (timelineStart !== undefined) {+ if (input.motion !== undefined || input.animation !== undefined) throw new TypeError('A timeline owns the motion clock; leave motion and animation out.');+ if (timelineStart + lastSampleTime > filmTimelineDuration(recipe.timeline)) throw new RangeError('Timeline range exceeds the timeline duration.');+ result.timeline = { start: timelineStart };+ }+ if (input.encoder !== undefined) {+ if (input.kind !== 'video') throw new TypeError('encoder needs kind video.');+ if (!VIDEO_ENCODERS.includes(input.encoder)) throw new TypeError(`encoder must be one of ${VIDEO_ENCODERS.join(', ')}.`);+ result.encoder = input.encoder;+ }+ if (input.audio !== undefined) result.audio = audioFrom(input.audio, input.kind);if (input.motion !== undefined) {objectKeys(input.motion, ['start'], 'motion');if (!['67js.scene', '67js.asset'].includes(recipe?.format) || !recipe.motion) {@@@ -104,20 -116,23 +118,37 @@@return result;}+function rendererFrom(renderer, kind, passes) {+ objectKeys(renderer, ['type', 'samples', 'bounces', 'denoise', 'seed', 'maxSeconds'], 'renderer');+ if (renderer.type !== 'pathTracer') throw new TypeError('renderer.type must be pathTracer.');+ if (kind !== 'image') throw new RangeError('The path tracer renders one image: use kind image.');+ if (passes !== undefined) throw new RangeError('The path tracer writes the lit image only: leave passes out.');+ if (renderer.denoise !== undefined && typeof renderer.denoise !== 'boolean') throw new TypeError('renderer.denoise must be a boolean.');+ const result = { type: 'pathTracer', denoise: renderer.denoise ?? true };+ for (const name of Object.keys(PATH_TRACER_JOB_LIMITS)) {+ const { minimum, maximum, default: fallback } = PATH_TRACER_JOB_LIMITS[name];+ result[name] = boundedNumber(renderer[name] ?? fallback, minimum, maximum, `renderer ${name}`, name !== 'maxSeconds');+ }+ return result;+}++ function timelineStartFrom(input, recipe) {+ if (input.timeline === undefined) return undefined;+ objectKeys(input.timeline, ['start'], 'timeline');+ if (recipe?.format !== '67js.scene' || !recipe.timeline) throw new RangeError('Timeline settings require a recipe with a timeline.');+ normalizeFilmTimeline(recipe.timeline, recipe);+ return boundedNumber(input.timeline.start ?? 0, 0, MAXIMUM_VIDEO_SECONDS, 'timeline start');+ }++ function audioFrom(audio, kind) {+ if (kind !== 'video') throw new TypeError('audio needs kind video.');+ objectKeys(audio, ['file', 'offset'], 'audio');+ if (typeof audio.file !== 'string' || !AUDIO_FILE_PATTERN.test(audio.file)) {+ throw new TypeError('audio.file must be a file name in the configured audio folder ending in .wav, .mp3, .ogg or .flac.');+ }+ return { file: audio.file, offset: boundedNumber(audio.offset ?? 0, 0, 3600, 'audio offset') };+ }+function passesFrom(passes, kind) {if (kind === 'video') throw new RangeError('Render passes need kind image or stills; a video holds the lit image only.');if (!Array.isArray(passes) || passes.length < 1 || passes.length > RENDER_PASS_NAMES.length) throw new TypeError(`passes must list 1 to ${RENDER_PASS_NAMES.length} pass names.`);diff --cc scripts/agent-runtime.mjsindex 6525269b,485dbe0c..6390ba08--- a/scripts/agent-runtime.mjs+++ b/scripts/agent-runtime.mjs@@@ -6,8 -6,7 +6,8 @@@ import { dirname, isAbsolute, join } frimport { createRequire } from 'node:module';import { fileURLToPath } from 'node:url';import packageMetadata from '../package.json' with { type: 'json' };- import { AGENT_SCENE_CAPABILITIES, AGENT_SCENE_DEFAULT_LIMITS, RENDER_PASS_NAMES, RENDER_PASS_DEPTH_RANGE } from '../src/agent-scene-capabilities.js';+ import { AGENT_SCENE_CAPABILITIES, AGENT_SCENE_DEFAULT_LIMITS, RENDER_PASS_NAMES, RENDER_PASS_DEPTH_RANGE, VIDEO_ENCODERS, MAXIMUM_VIDEO_SECONDS } from '../src/agent-scene-capabilities.js';+import { PATH_TRACER_CAPABILITIES } from '../src/path-tracer-capabilities.js';import { createAgentAssetCatalog } from './agent-asset-catalog.mjs';import { createAgentRenderJobs, EXPORT_DIRECTORY_NAME } from './agent-render-jobs.mjs';import { createFrameEncoder } from './frame-encoder.mjs';@@@ -324,24 -331,17 +334,30 @@@ export function createAgentRuntime({ basignal.throwIfAborted();const elapsed = settings.kind === 'video' ? frame / settings.fps: settings.kind === 'stills' ? settings.duration * frame / (settings.frameCount - 1) : 0;+ // A timeline job reads one clock for the shot, the motion and the renderer, so a seek matches the frame in a video.+ const timelineTime = timeline ? Math.min(filmTimelineDuration(timeline), settings.timeline.start + elapsed) : undefined;+ const shotSample = timeline ? sampleFilmTimeline(timeline, snapshot.recipe, timelineTime) : undefined;const frameInput = { sessionId: jobId,- rendererTime: (settings.rendererTime?.start ?? 0) + elapsed * (settings.rendererTime?.rate ?? 1),+ rendererTime: (settings.rendererTime?.start ?? 0) + (timelineTime ?? elapsed) * (settings.rendererTime?.rate ?? 1),...(settings.motion ? { motionTime: settings.motion.start + elapsed } : {}),+ ...(shotSample?.motionTime == null ? {} : { motionTime: shotSample.motionTime }),+ ...(shotSample?.camera ? { camera: shotSample.camera } : {}),+ ...(shotSample && shotSample.brightness < 1 ? { brightness: shotSample.brightness } : {}),...(settings.animation ? { animation: { clip: settings.animation.clip, time: settings.animation.start + elapsed } } : {}) };const renderStarted = performance.now();+ if (settings.renderer) {+ const traced = await jobPage.evaluate(input => window.__agentPreview.pathTrace(input), { ...frameInput, options: { width, height, ...settings.renderer, threads: PATH_TRACER_THREADS } });+ metrics.renderSeconds += (performance.now() - renderStarted) / 1000;+ metrics.width = width;+ metrics.height = height;+ metrics.pathTracer = traced.report;+ const tracedBytes = Buffer.from(traced.data, 'base64');+ if (tracedBytes.length > MAXIMUM_IMAGE_BYTES) throw new Error('Path traced image exceeded 1 MiB.');+ await writeFile(join(directory, 'render.png.partial'), tracedBytes, { flag: 'wx' });+ artifacts.push({ temporary: 'render.png.partial', filename: 'render.png', mimeType: 'image/png' });+ await progress({ frames: 1, maximumPendingFrames: 1 });+ continue;+ }const rendered = await jobPage.evaluate(input => window.__agentPreview.frame(input), frameInput);metrics.renderSeconds += (performance.now() - renderStarted) / 1000;if (backend === 'cpu' && !/swiftshader/i.test(rendered.graphics)) throw new Error('CPU job did not select SwiftShader.');@@@ -437,9 -462,9 +478,9 @@@maximumVertices: 250000, maximumParts: 4096, maximumTexturePixels: 4194304, maximumJoints: 1024, maximumClips: 256,commands: ['set-root', 'set-asset-node', 'set-motion', 'set-animation', 'set-material', 'set-camera', 'set-environment', 'set-effects', 'set-shadow'],},- jobs: { configured: Boolean(jobRoot), kinds: ['image', 'stills', 'video'], passes: RENDER_PASS_NAMES, maximumActiveJobs: 1,+ jobs: { configured: Boolean(jobRoot), kinds: ['image', 'stills', 'video'], passes: RENDER_PASS_NAMES, pathTracer: PATH_TRACER_CAPABILITIES, maximumActiveJobs: 1,- maximumDuration: 30, maximumFps: 30, maximumFrames: 900, maximumStills: 8,- encoder: 'CPU H.264', audio: false, previewSuspendedDuringJob: true,+ maximumDuration: MAXIMUM_VIDEO_SECONDS, maximumFps: 30, maximumFrames: 900, maximumStills: 8,+ encoder: 'H.264', encoders: VIDEO_ENCODERS, audio: Boolean(audioRoot), timeline: true, previewSuspendedDuringJob: true,glbExport: { maximumBytes: MAXIMUM_GLB_BYTES, maximumKept: MAXIMUM_KEPT_GLBS, maximumTextureSize: 4096 },records: jobRoot ? (await jobs()).list().map(record => ({ jobId: record.jobId, state: record.state,sourceRevision: record.sourceRevision, progress: record.progress })) : [] },diff --cc scripts/mcp-server.mjsindex a2765cf0,cfce04fd..a32c0b65--- a/scripts/mcp-server.mjs+++ b/scripts/mcp-server.mjs@@@ -568,7 -578,9 +578,10 @@@ const renderSettings = z.strictObject(animation: z.strictObject({ clip: z.number().int().min(0), start: z.number().min(0).max(3600).optional() }).optional(),motion: z.strictObject({ start: z.number().min(0).max(3600).optional() }).optional(),rendererTime: z.strictObject({ start: z.number().min(0).max(3600).optional(), rate: z.number().min(-16).max(16).optional() }).optional(),- renderer: z.strictObject({ type: z.literal('pathTracer'), samples: z.number().int().optional(), bounces: z.number().int().optional(), denoise: z.boolean().optional(), seed: z.number().int().optional(), maxSeconds: z.number().optional() }).optional().describe('image only: offline path tracer instead of the rasterizer; limits and what it skips are in scene_capabilities pathTracer.'),++ renderer: z.strictObject({ type: z.literal('pathTracer'), samples: z.number().optional(), bounces: z.number().optional(), denoise: z.boolean().optional(), seed: z.number().optional(), maxSeconds: z.number().optional() }).optional().describe('image only: offline path tracer; limits and skips in scene_capabilities pathTracer.'),+ timeline: z.strictObject({ start: z.number().min(0).max(60).optional() }).optional().describe('Play the recipe timeline from start (default 0); duration defaults to the rest of it. It owns the motion clock, so leave motion and animation out.'),+ audio: z.strictObject({ file: z.string().max(68), offset: z.number().min(0).max(3600).optional() }).optional().describe('Video only: a file name in the --audio folder (.wav, .mp3, .ogg, .flac) mixed in from offset seconds.'),+ encoder: z.enum(VIDEO_ENCODERS).optional().describe('Video only: cpu (default) or nvenc.'),passes: z.array(z.enum(RENDER_PASS_NAMES)).min(1).max(RENDER_PASS_NAMES.length).optional().describe('image and stills only: also write raw PNGs per frame for these passes; opaque geometry only.'),}).describe('Immutable snapshot render: one PNG, eight evenly spaced PNGs, or CPU H.264 MP4. Video dimensions must be even. Defaults: 24 fps, one second. Use motion.start for authored recipe tracks, animation for an imported clip, or both to layer them. Omitted motion holds time zero. Nonlooping samples must fit the authored duration.');const readOnly = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };