Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TASKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ glTF loader made public, hand-written API tables, experimental and research feat
| S15 | Bug: WGSL `rtCascadeStart(0, ..)` hung the GPU (`select` evaluated `rtCascadeEnd(0u - 1u)`, 2^32 multiplies) | agent | ✅ | 2026-11-20, found by `raytracer/intervals`; fixed with an `if`, regression test in `interval.test.ts`. The `rc-interval-check` page never asked for cascade 0's start on the GPU |
| S14 | Public MaterialX scene builder (maintainer 2026-11-20: bench internals may go public when the docs or examples need them): `buildMaterialX`, `mtlxAddToScene`, `mtlxKernelOptions`, `mtlxSyntheticImage`, `mtlxFeatureProbes`, `mtlxImageKey` in `@pmndrs/pathtracer` (`materialx/scene.ts`, `synthetic.ts`), `materialProbes` in `ptSceneOptions`; the bench's lazy-texture `buildMaterialX` uses the shared probes and keys. Example `pathtracer/materialx` | agent | ✅ | Tests `materialx/scene.test.ts`. SwiftShader: procedural stripes blue / gold with codegen, averaged with bake (as documented), constant coat orange, no non-finite pixels |
| S7 | Phase 3: Real time (T*), the remaining showcases, Lab (A/B viewer, caps, convergence), thumbnails captured on the Mac (Playwright, 16:9 webp in `examples/<path>/thumb.webp`), a SwiftShader smoke run of every example in CI (`?offscreen=1`) | agent | ✅ | 2026-11-20 done: `realtime/frame` (planes viewer, plane identity checked on SwiftShader: beauty 0.13277 vs remodulated 0.13274), `realtime/restir` (experimental; single-frame relMSE vs a 128-frame mean on SwiftShader: NEE 3.11, unbiased 0.54, biased 0.53), `lab/caps` (GPU report); `scripts/examples-smoke.mjs` (every catalog example headless: overlay, console, NaN, flat-canvas checks; `--thumbs` writes the card images from the page's own offscreen target) and `.github/workflows/examples.yml` (SwiftShader, PRs touching examples/packages). Gallery bundles `thumb.webp` by path. Every progressive example now has a **Samples** folder (`examples/shared/sampling.ts`: stop at 1..4096 spp, samples per frame, restart; `?spp=N`) and an `image` line in its stats ("ray traced ... no raster · no denoiser"), because a ray tracer that converges in a second reads as raster (maintainer, 2026-11-20); the info panel renders the descriptions' `code` and **bold**. Also `lab/convergence` (relMSE against a reference at 1, 2, 4, ... spp, log-log, Owen-Sobol vs PCG and the 1/spp guide; SwiftShader smoke at `ref=16`) and a template fix: the "Starting WebGPU…" overlay stayed up on a page that never calls `progress(null)` (the GPU report). Moved on 2026-11-24: card images and real-GPU timings to S18, the denoised chain to S17, the Lab A/B viewer stays in Phase 4, more showcases to S19 / S20 |
| S16 | Example principles (maintainer 2026-11-21): every example states its point, gives the controls that make it, and a performance or quality page shows the "bad" version next to the good one | agent | 🟡 | `ExampleBrief` (`kind`, `shows`, `tryThis`, `compare`) on every catalog entry, shown first in the info panel (opens on a first visit), `examples/catalog.test.ts` enforces it. Reworked to make their point: Rays from your own shader (was Hit inspector: shadow / reflection / AO rays from each hit, all off = what raster gives, clicked rays drawn over the image), Interval queries (a final sky-lit image through the cascades = one full ray pixel for pixel, a broken gapped version that leaks), AO (`rtVisible` vs `rtClosest`, same image), Batch (batch passes vs one inline kernel, same image), ReSTIR (split view NEE / ReSTIR with per-frame error, two-sided lamps). Open: one-line overlays on the canvas itself for the comparisons (the briefs live in the info panel), a fresh look at the remaining pages against the principles on a real GPU Issue [#63](https://github.com/pmndrs/pathtracer/issues/63). |
| S16 | Example principles (maintainer 2026-11-21): every example states its point, gives the controls that make it, and a performance or quality page shows the "bad" version next to the good one | agent | 🟡 | `ExampleBrief` (`kind`, `shows`, `tryThis`, `compare`) on every catalog entry, shown first in the info panel (opens on a first visit), `examples/catalog.test.ts` enforces it. Reworked to make their point: Rays from your own shader (was Hit inspector: shadow / reflection / AO rays from each hit, all off = what raster gives, clicked rays drawn over the image), Interval queries (a final sky-lit image through the cascades = one full ray pixel for pixel, a broken gapped version that leaks), AO (`rtVisible` vs `rtClosest`, same image), Batch (batch passes vs one inline kernel, same image), ReSTIR (split view NEE / ReSTIR with per-frame error, two-sided lamps). Canvas labels (2026-12-02, #63): `examples/shared/canvas-labels.ts` (`canvasLabels(pane)`: an HTML layer over the canvas, never in the image; `?labels=0` or the pane's "canvas labels" checkbox hides it) labels AO, Batch, Interval queries, Rays from your own shader, Fog (split), Denoised chain (split) and ReSTIR (split); and, in the follow-up PR (depends on #109), One-bounce shading (Mode), Megakernel or wavefront (scheduler, refill, sort), BVH formats (node format), Alpha cutouts (shadow rays), Many lights (selection + ReSTIR on/off), Spectral (on / RGB), MaterialX (document + approach actually built), Real-time frames (view + sampler) and Convergence (which image the canvas shows: reference, then each sampler at its checkpoint). Not labelled on purpose: Classroom (already has its own left / right tags in the hero page), Hello, glTF models, Material explorer, Fog and clouds, Cloud, GPU report (one thing on screen, nothing to compare; the pane controls already name it). Open: a fresh look at the remaining pages against the principles on a real GPU Issue [#63](https://github.com/pmndrs/pathtracer/issues/63). |
| S8 | Loader follow-ups: KHR_texture_basisu / Draco / meshopt (refused today), point and spot lights (listed in `notes`), occlusion and extension texture slots, an exact PNG decoder option for the browser (canvas premultiplies), keeping glTF instancing instead of baking | — | ⬜ | Issue [#52](https://github.com/pmndrs/pathtracer/issues/52). |
| S17 | Real-time chain example (`realtime/chain/`): path tracer at 1 spp per frame -> `DiffuseSpecularDenoiser` (SVGF) -> composite -> `@pmndrs/upscaler` temporal; split view raw frame | final, views raw / denoised / final, denoiser on/off, upscaler temporal / spatial / bilinear, ratio 1-3x | agent | ✅ | **Built 2026-11-24** on the branch: `examples/shared/realtime-chain.ts` (a trimmed copy of `bench/realtime/chain.ts`: no OIDN arm, meters or A/B knobs; `post` is synchronous, `setUpscalePath` async; `StageView` draws any stage with a split), `examples/realtime/chain/`, catalog entry (experimental), docs `pathtracer/realtime` links it instead of the bench file. `examples/package.json` names `denoiser@^2.0.0`, `@pmndrs/upscaler@^0.5.0`, `three@0.187.0`; `denoiser@2.0.0` reached npm 2026-11-25 (maintainer); the lockfile adds only the three example dependencies, `pnpm install --frozen-lockfile` passes, and the SwiftShader smoke run against the published package matches the local build (final mean 0.0688). Verified against a local build of pmndrs/denoiser main (packed tarball through an uncommitted `pnpm-workspace.yaml` override), SwiftShader, Cornell box 240x135 -> 480x270: smoke PASS, 0 non-finite; stage means at 64 frames raw 0.0825 / denoised 0.0825 (SVGF keeps the energy) / final 0.0681 temporal, 0.0836 bilinear; with values clamped at 1 denoised 0.0384 vs final 0.0377 (-1.8%): the temporal upscaler's loss is the lamp (pixels > 1 hold 59% of the energy; the known emitter darkening, N11.5 / P4.5a). **OIDN added 2026-11-26** (`setDenoiser('svgf' | 'oidn' | 'none')`, page control and `?denoiser=`): the prep pass of the bench (progressive mean of a still camera, view-space normals), the small network while moving, the standard one after 8 still frames, then the frame is held. The weights come from `denoiser`'s default `DEFAULT_TZA_URL` (jsDelivr, pmndrs/denoiser-weights@models-v3; no hosting needed, the earlier note was wrong); `?tza=<url>` overrides it (cloud containers cannot reach jsDelivr: the check served the six `.tza` files from `.cache/tzas`). SwiftShader, Cornell box, 8 still frames: raw 0.0840 / OIDN 0.0843 / final with the bilinear upscaler 0.0843 (exact), spatial 0.0863, temporal 0.1133: the temporal upscaler brightens the lamp INSIDE its footprint (130 display pixels above 13 where its input peaks at 12.6; energy of pixels > 1 per pixel 0.0506 -> 0.0790), the rest within 1% (S21). Open: a real-GPU look and card image (S18), frame times |
| S18 | Card images and timings on a real GPU: `node scripts/examples-smoke.mjs --thumbs --gpu` on the Mac (SwiftShader cards are noisy), AO any-hit vs closest-hit and batch vs inline frame times, the batch fix confirmed on Apple | maintainer (Mac) | ⬜ | Split out of S7 (2026-11-24); a cloud session has no GPU Issue [#63](https://github.com/pmndrs/pathtracer/issues/63). |
Expand Down
4 changes: 4 additions & 0 deletions examples/lab/convergence/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import { PtMegakernel, ptSceneOptions, type PtSamplerKind } from '@pmndrs/pathtracer';
import { buildGpuScene, type GpuScene } from '@pmndrs/raytracer';
import { CORNELL_CAMERA, cornellBox } from '../../shared/cornell.ts';
import { canvasLabels } from '../../shared/canvas-labels.ts';
import { defineExample } from '../../shared/example.ts';
import { LAMPS_CAMERA, lampsScene } from '../../shared/lamps.ts';
import { AccumulationView } from '../../shared/present.ts';
Expand Down Expand Up @@ -69,6 +70,7 @@ defineExample(async (ctx) => {
panel.className = 'conv';
document.body.append(panel);
const view = new AccumulationView(device, ctx.format);
const labels = canvasLabels(pane);
stats.set('image', 'path traced, accumulated · no raster · no denoiser · no upscaler');

let run = 0;
Expand Down Expand Up @@ -114,6 +116,7 @@ defineExample(async (ctx) => {
}
// The reference: Owen-Sobol at `reference` spp with its own seed.
ctx.progress(`Rendering the reference (${params.reference} spp)…`);
labels.set([{ text: `Image: the reference, Owen-Sobol at ${params.reference} spp` }]);
start(kernels[0]!, 9001);
await add(kernels[0]!, params.reference);
if (mine !== run) return;
Expand All @@ -128,6 +131,7 @@ defineExample(async (ctx) => {
for (let target = 1; target <= params.reference / 4 && mine === run; target *= 2) {
await add(pt, target - done);
done = target;
labels.set([{ text: `Image: ${SAMPLERS[s]!}, ${target} spp (the chart plots every checkpoint)` }]);
const img = (await pt.readImage()).data;
lastImage = img;
checkpoints++;
Expand Down
4 changes: 4 additions & 0 deletions examples/pathtracer/bvh/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
import type { NodeFormat } from '@pmndrs/bvh';
import { buildGpuScene, type GpuScene } from '@pmndrs/raytracer';
import { canvasLabels } from '../../shared/canvas-labels.ts';
import { defineExample } from '../../shared/example.ts';
import { loadScene, SCENES, type LoadedScene } from '../../shared/models.ts';
import { OrbitCamera } from '../../shared/orbit.ts';
Expand All @@ -32,6 +33,7 @@ defineExample(async (ctx) => {
let scene: GpuScene | null = null;
let renderer: ProgressiveRenderer | null = null;
let busy = false;
let labels: ReturnType<typeof canvasLabels> | null = null; // made after the controls, before the first build
const timings = new Map<string, string>();

const build = async () => {
Expand All @@ -48,6 +50,7 @@ defineExample(async (ctx) => {
const old = renderer, oldScene = scene;
renderer = r;
scene = next;
labels?.set([{ text: `Node format: ${Object.keys(FORMATS).find((k) => FORMATS[k] === params.format) ?? params.format}` }]);
stats.set('tree', `${params.format}, built in ${buildMs.toFixed(0)} ms`);
stats.set('memory', `${(next.trace.byteLength / 1048576).toFixed(2)} MB on the GPU`);
stats.set('triangles', loaded.input.instances.reduce((n, i) => { const m = loaded!.input.meshes[i.meshIndex]!; return n + (m.indices ? m.indices.length : m.positions.length / 3) / 3; }, 0).toLocaleString());
Expand Down Expand Up @@ -115,6 +118,7 @@ defineExample(async (ctx) => {
f.addButton({ title: 'Benchmark (64 spp)' }).on('click', () => void benchmark());
f.addBinding(params, 'results', { label: 'this GPU', readonly: true, multiline: true, rows: 4 });

labels = canvasLabels(pane);
await load();
ctx.loop((encoder) => (busy ? false : (renderer?.frame(encoder) ?? false)));
});
3 changes: 3 additions & 0 deletions examples/pathtracer/cutouts/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
import { ALPHA_MODE, buildGpuScene, type GpuScene, type SceneCopyInput, type TextureInput } from '@pmndrs/raytracer';
import type { PtIntegratorOptions } from '@pmndrs/pathtracer';
import { canvasLabels } from '../../shared/canvas-labels.ts';
import { defineExample } from '../../shared/example.ts';
import { OrbitCamera } from '../../shared/orbit.ts';
import { ProgressiveRenderer } from '../../shared/progressive.ts';
Expand Down Expand Up @@ -83,6 +84,7 @@ defineExample(async (ctx) => {
if (renderer) Object.assign(next.settings, renderer.settings);
const old = renderer;
renderer = next;
labels.set([{ text: `Shadow rays: ${params.mode}` }]);
ctx.progress(null);
await device.queue.onSubmittedWorkDone();
old?.destroy();
Expand All @@ -101,6 +103,7 @@ defineExample(async (ctx) => {
old.destroy();
});

const labels = canvasLabels(pane);
await rebuild();
ctx.loop((encoder) => renderer?.frame(encoder) ?? false);
});
15 changes: 4 additions & 11 deletions examples/pathtracer/fog/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import { buildGpuScene, type GpuScene, type SceneCopyInput, type RtMaterialInput } from '@pmndrs/raytracer';
import { ptMediumFrom, type PtIntegratorOptions } from '@pmndrs/pathtracer';
import { box, mesh } from '../../shared/cornell.ts';
import { canvasLabels } from '../../shared/canvas-labels.ts';
import { defineExample, type ExampleContext } from '../../shared/example.ts';
import { sunFrom } from '../../shared/models.ts';
import { OrbitCamera } from '../../shared/orbit.ts';
Expand Down Expand Up @@ -118,20 +119,12 @@ defineExample(async (ctx) => {
};
};
const note = document.createElement('div');
note.style.cssText = 'position:fixed;left:50%;top:56px;transform:translateX(-50%);max-width:min(760px,92vw);padding:8px 14px;border-radius:8px;background:rgba(0,0,0,.6);color:#eee;font:13px/1.4 system-ui,sans-serif;text-align:center;pointer-events:none';
note.style.cssText = 'position:fixed;left:50%;top:112px;transform:translateX(-50%);max-width:min(760px,92vw);padding:8px 14px;border-radius:8px;background:rgba(0,0,0,.6);color:#eee;font:13px/1.4 system-ui,sans-serif;text-align:center;pointer-events:none';
note.textContent = NOTE;
document.body.append(note);
const labels = [0, 1].map((i) => {
const el = document.createElement('div');
el.style.cssText = `position:fixed;top:12px;${i === 0 ? 'left:14px' : 'right:14px'};padding:4px 10px;border-radius:6px;background:rgba(0,0,0,.6);color:#fff;font:600 13px system-ui,sans-serif;pointer-events:none`;
document.body.append(el);
return el;
});
const labels = canvasLabels(ctx.pane);
const updateLabels = () => {
labels[0]!.textContent = NAMES[params.left];
labels[1]!.textContent = NAMES[params.right];
labels[0]!.style.left = '14px';
labels[1]!.style.display = params.split < 0.95 ? '' : 'none';
labels.set(params.split < 0.95 ? [{ text: NAMES[params.left], side: 'left' }, { text: NAMES[params.right], side: 'right' }] : [{ text: NAMES[params.left] }], { split: params.split });
ctx.stats.set('optical depth across the room', (params.density * 6).toFixed(2));
};
let presentDirty = true;
Expand Down
6 changes: 6 additions & 0 deletions examples/pathtracer/lights/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* previous frame and from neighbours: far less noise per sample with many lights, at the cost of extra passes.
*/
import { buildGpuScene, type GpuScene, type LightSelection } from '@pmndrs/raytracer';
import { canvasLabels } from '../../shared/canvas-labels.ts';
import { defineExample } from '../../shared/example.ts';
import { LAMPS_CAMERA, lampsScene } from '../../shared/lamps.ts';
import { OrbitCamera } from '../../shared/orbit.ts';
Expand All @@ -26,6 +27,8 @@ defineExample(async (ctx) => {
let renderer: ProgressiveRenderer | null = null;
stats.set('lights', '64 lamps, sun, sky');

// The selection lives in the scene copy, ReSTIR in the kernel: the label names both, whichever just changed.
const showLabel = () => labels.set([{ text: `Light selection: ${params.strategy} · ReSTIR DI ${params.restir ? 'on' : 'off'}` }]);
const rebuild = async () => {
ctx.progress('Compiling…');
try {
Expand All @@ -34,6 +37,7 @@ defineExample(async (ctx) => {
next.settings.samplesPerFrame = 1;
const old = renderer;
renderer = next;
showLabel();
ctx.progress(null);
await device.queue.onSubmittedWorkDone();
old?.destroy();
Expand All @@ -49,6 +53,7 @@ defineExample(async (ctx) => {
const old = scene;
scene = await buildGpuScene(device, lampsScene(STRATEGIES[params.strategy]!), { label: 'lamps' });
renderer?.setScene(scene);
showLabel();
await device.queue.onSubmittedWorkDone();
old.destroy();
});
Expand All @@ -59,6 +64,7 @@ defineExample(async (ctx) => {
renderer.restart();
});

const labels = canvasLabels(pane);
await rebuild();
ctx.loop((encoder) => renderer?.frame(encoder) ?? false);
});
3 changes: 3 additions & 0 deletions examples/pathtracer/materialx/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/
import { buildMaterialX, mtlxAddToScene, mtlxKernelOptions, mtlxSyntheticImage, type MtlxBuildMode } from '@pmndrs/pathtracer';
import { buildGpuScene, type GpuScene, type RtMaterialInput, type SceneCopyInput, type SceneCopyMesh } from '@pmndrs/raytracer';
import { canvasLabels } from '../../shared/canvas-labels.ts';
import { defineExample } from '../../shared/example.ts';
import { sunFrom } from '../../shared/models.ts';
import { OrbitCamera } from '../../shared/orbit.ts';
Expand Down Expand Up @@ -129,6 +130,7 @@ defineExample(async (ctx) => {
const r = await ProgressiveRenderer.create(ctx, next, orbit.camera, kernel);
r.settings.maxDepth = 6;
stats.set('mode', use.built.mode);
labels.set([{ text: `${params.document} · ${use.built.mode === 'bake' ? 'Approach: Bake (textures over uv)' : use.built.mode === 'codegen' ? 'Approach: Codegen (WGSL per hit)' : 'Constants (nothing to bake or generate)'}` }]);
if (kernel.notes.length) console.info(`MaterialX notes:\n${kernel.notes.join('\n')}`);
const old = renderer, oldScene = gpuScene;
renderer = r;
Expand All @@ -147,6 +149,7 @@ defineExample(async (ctx) => {
folder.addBinding(params, 'document', { options: Object.fromEntries(names.map((n) => [n, n])) }).on('change', () => void rebuild());
folder.addBinding(params, 'mode', { label: 'approach', options: { 'Codegen (WGSL per hit)': 'codegen', 'Bake (textures over uv)': 'bake' } }).on('change', () => void rebuild());

const labels = canvasLabels(pane);
await rebuild();
ctx.loop((encoder) => renderer?.frame(encoder) ?? false);
});
Loading
Loading