3D engine that AI agents drive
Fall back to the GPU a-trous filter when OIDN is missing on native jobs (#1018)
Nguyen Xuan Anc5d10501efeb
diff --git a/changes/1018.md b/changes/1018.mdnew file mode 100644index 00000000..94a8138a--- /dev/null+++ b/changes/1018.md@@ -0,0 +1 @@+- A native render job without Open Image Denoise now filters with the GPU a-trous filter of the native tracer instead of the slow CPU wavelet filter, and the report says `denoiser: "atrous"` (#1018)diff --git a/docs/agent-render-jobs.md b/docs/agent-render-jobs.mdindex 16aeeecf..674d7d55 100644--- a/docs/agent-render-jobs.md+++ b/docs/agent-render-jobs.md@@ -185,7 +185,7 @@ An `image`, `stills` or `video` job can ask for the offline [path tracer](https:"renderer": { "type": "pathTracer", "backend": "gpu", "samples": 64, "bounces": 8, "denoise": true, "seed": 0, "maxSeconds": 120 } }```-Every field after `type` is optional. `backend` is `cpu` (the default, byte-identical on SwiftShader smokes), `gpu`, which traces in a WebGL2 shader and needs a runtime started on the GPU backend (a `--backend cpu` runtime refuses it), or `native`, which traces on hardware ray queries (Vulkan) through the optional `@codepawlhq/67js-render-native` package. A native job exports the scene from the job page, traces it in the job runner with the Cycles-matching kernel (`JS67_NATIVE_KERNEL=legacy` keeps the older one), then denoises and writes the PNG as the other backends do: `denoise: true` means OIDN with the albedo and normal guides when `@codepawlhq/67js-denoise-oidn` and its binary are installed, else the wavelet filter with a note in `metrics.pathTracer.denoiserNote`. The report carries `kernel` and `averageSamples`. It never fails for lack of the package: without it, without its built binary or without a Vulkan ray query adapter the job runs on `gpu` (`cpu` on a cpu runtime) and `metrics.pathTracer.backendNote` says why; `metrics.pathTracer.backend` always names what ran. The look up costs one import and is cached per process. Native traces volume fog and subsurface scattering with the same walk as the WebGPU megakernel, honours `maxSeconds`, and honours `noiseThreshold` on the GPU (after 16 samples, and then every 8, a converged pixel draws no more; `report.averageSamples` is the mean a pixel drew). The `gpu` fallback ignores `noiseThreshold`. The report in `metrics.pathTracer` names the `backend` that ran, the `gpu`, `gpuCompileSeconds` and `gpuKernelCompiles`. A `stills` or `video` job traces every frame with the same options: the kernel compiles once per job page and each frame reuses it, so a film shows `gpuKernelCompiles: 1`. A video of traced frames goes through the ffmpeg encoder (the browser H.264 encoder has no drawn frame to read), `maxSeconds` limits each frame, and the job deadline is `maxSeconds` times the frame count plus 60 seconds, up to the job ceiling. Limits: `samples` 1 to 1024, `bounces` 1 to 16, `seed` 0 to 2147483647, `maxSeconds` 1 to 600 (the job's deadline is `maxSeconds` plus 60 seconds; a 1920 by 1080 still of a 180,000 triangle room at 64 samples took 246 s, so give a large still `maxSeconds` 600). `passes` are refused with it. The tracer loads in the job page on demand, uses eight threads at below-normal priority, stops pixels that have converged (`report.averageSamples`), and writes `render.png`; `scene_render_result` metrics carry `pathTracer` with the samples, threads, seconds and what the scene asked for that was not drawn. The same recipe and seed give the same PNG on the cpu and gpu backends; the native Cycles-matching kernel is not always byte-identical between runs (on the demo room at 960 by 540 and 256 samples two jobs differed in a few bytes; a 480 by 270 job with OIDN did not). A job that passes `maxSeconds` fails and writes no image.+Every field after `type` is optional. `backend` is `cpu` (the default, byte-identical on SwiftShader smokes), `gpu`, which traces in a WebGL2 shader and needs a runtime started on the GPU backend (a `--backend cpu` runtime refuses it), or `native`, which traces on hardware ray queries (Vulkan) through the optional `@codepawlhq/67js-render-native` package. A native job exports the scene from the job page, traces it in the job runner with the Cycles-matching kernel (`JS67_NATIVE_KERNEL=legacy` keeps the older one), then denoises and writes the PNG as the other backends do: `denoise: true` means OIDN with the albedo and normal guides when `@codepawlhq/67js-denoise-oidn` and its binary are installed, else (or when OIDN fails) the GPU a-trous filter of the native tracer with a note in `metrics.pathTracer.denoiserNote` (`denoiser: "atrous"`; it is biased, it smooths; `denoise: "wavelet"` asks for the CPU filter). The report carries `kernel` and `averageSamples`. It never fails for lack of the package: without it, without its built binary or without a Vulkan ray query adapter the job runs on `gpu` (`cpu` on a cpu runtime) and `metrics.pathTracer.backendNote` says why; `metrics.pathTracer.backend` always names what ran. The look up costs one import and is cached per process. Native traces volume fog and subsurface scattering with the same walk as the WebGPU megakernel, honours `maxSeconds`, and honours `noiseThreshold` on the GPU (after 16 samples, and then every 8, a converged pixel draws no more; `report.averageSamples` is the mean a pixel drew). The `gpu` fallback ignores `noiseThreshold`. The report in `metrics.pathTracer` names the `backend` that ran, the `gpu`, `gpuCompileSeconds` and `gpuKernelCompiles`. A `stills` or `video` job traces every frame with the same options: the kernel compiles once per job page and each frame reuses it, so a film shows `gpuKernelCompiles: 1`. A video of traced frames goes through the ffmpeg encoder (the browser H.264 encoder has no drawn frame to read), `maxSeconds` limits each frame, and the job deadline is `maxSeconds` times the frame count plus 60 seconds, up to the job ceiling. Limits: `samples` 1 to 1024, `bounces` 1 to 16, `seed` 0 to 2147483647, `maxSeconds` 1 to 600 (the job's deadline is `maxSeconds` plus 60 seconds; a 1920 by 1080 still of a 180,000 triangle room at 64 samples took 246 s, so give a large still `maxSeconds` 600). `passes` are refused with it. The tracer loads in the job page on demand, uses eight threads at below-normal priority, stops pixels that have converged (`report.averageSamples`), and writes `render.png`; `scene_render_result` metrics carry `pathTracer` with the samples, threads, seconds and what the scene asked for that was not drawn. The same recipe and seed give the same PNG on the cpu and gpu backends; the native Cycles-matching kernel is not always byte-identical between runs (on the demo room at 960 by 540 and 256 samples two jobs differed in a few bytes; a 480 by 270 job with OIDN did not). A job that passes `maxSeconds` fails and writes no image.## Controller APIdiff --git a/docs/path-tracer.md b/docs/path-tracer.mdindex 54a1a8ed..f7697d12 100644--- a/docs/path-tracer.md+++ b/docs/path-tracer.md@@ -71,7 +71,7 @@ The same scene and options give the same bytes. Random numbers come from a hash`backend: "native"` is an agent render job setting, not a `renderPathTracedImage` option: [`packages/render-native`](../packages/render-native/README.md) runs the same kernel on Vulkan ray queries. On the demo room at 1920 by 1080 and 64 samples an MCP image job took 25 to 35 s with native against 58 s with gpu (trace alone 2.7 to 3.1 s against 38.8 s; the rest is the page export, the wavelet denoise and the PNG), FLIP 0.0047 between them. A missing package, binary or adapter falls back to gpu with a note in the job report. `maxSeconds` is honoured: past it the native trace stops and the job fails, as on the other backends, instead of rerunning on gpu; `noiseThreshold` is too (the kernel applies the CPU stop rule per pixel, so `averageSamples` falls below `samples`; the `gpu` and `webgpu` backends still draw every sample). Volume fog and subsurface scattering are in the native kernel, compiled in only for a scene that uses them; `bench/native-tracer/scenes.mjs` draws the reference scenes on native and on the WebGPU megakernel for a FLIP comparison. Alpha cutouts (`alphaMode: "mask"`) work: cutout triangles are their own geometry and the kernel confirms a hit only when the colour map alpha reaches the cutoff, with no step limit. In a dense cutout scene native is the more correct tracer: the CPU and WebGL2 shadow ray takes the first hit the traversal finds, not the nearest, and when that hit is a transparent texel it skips occluders it had not reached yet, so those backends leak light (300 leaf cards: native vs cpu FLIP 0.043, and 0.0002 once the CPU shadow ray takes the nearest hit; bench/native-tracer/cutout-bisect.mjs shows one card agrees exactly). The steps before: up to 8 layers deep (`bench/native-tracer/cutout.mjs`: 300 masked leaf cards trace in 0.1 s at 640 by 360 and 64 samples). See [agent-render-jobs.md](agent-render-jobs.md#path-tracer).-The native package has two kernels. `traceNative` keeps `legacy`, the kernel described above, as its own default, but a render job with `backend: "native"` (issue #970) traces with the `cycles` kernel and denoises with OIDN and the albedo and normal guides when `denoise` is `true` (the default); `JS67_NATIVE_KERNEL=legacy` makes the job runner use the legacy kernel again, and without OIDN installed the wavelet filter runs with a note in `denoiserNote`. The job report names the `kernel`, the `noiseThreshold` and the `averageSamples`. On the `metal` reference scene (960 by 540, 256 samples, NVIDIA A10, Vulkan, scored against Cycles 5.3 at 4096 samples with relMSE, the 100 worst pixels dropped, and FLIP): the default job frame step (`bench/native-tracer/metal-job.mjs`) took 1.64 s (1.22 s trace, 0.23 s OIDN) with relMSE 0.00007, against 5.57 s for the wavelet filter (relMSE 0.00014), 1.36 s for no filter (relMSE 0.00019, flat-area grain 0.0076 against 0.0024 filtered) and 1.23 s for the legacy kernel with OIDN (relMSE 0.00093, FLIP 0.039 against 0.009). `cycles` is the opt-in kernel that follows Blender Cycles 5.3: on six reference scenes at 4096 samples it matches Cycles within 1 percent of the mean and within 1.8 percent on every 8 by 8 tile, and its error at 256 samples on `lit-interior` is 0.0027 against 0.0198 for the legacy kernel (Cycles: 0.0031). Three options follow Cycles: `sampler` (`'sobol-burley'` blue-noise pattern by default, `'white'` for the hash sampler), `filterType` and `filterWidth` (`'box'` width 1 by default, `'gaussian'` and `'blackman-harris'` from the Cycles filter table) and `lightSampling` (`'auto'`, `'tree'` or `'uniform'`; the Cycles light tree is used from more than one emitter). It is 2.3 to 3.1 times slower per sample than the legacy kernel before the light tree (0.92 s against 2.86 s on `lit-interior`, 960 by 540, 256 samples), and the light tree adds 16 to 32 percent per sample on top; at equal error against Cycles 5.3 it is 1.2 times faster on `lit-interior` and 3 to 6 percent slower on `many-lights-500` on an RTX 3060, and 1.5 times faster and level (1.02 to 1.03 times) on an NVIDIA A10G. Tables, method and the equal-error caveat are in [cycles-parity.md](cycles-parity.md#selecting-the-kernel).+The native package has two kernels. `traceNative` keeps `legacy`, the kernel described above, as its own default, but a render job with `backend: "native"` (issue #970) traces with the `cycles` kernel and denoises with OIDN and the albedo and normal guides when `denoise` is `true` (the default); `JS67_NATIVE_KERNEL=legacy` makes the job runner use the legacy kernel again, and without OIDN installed (or when it fails) the GPU a-trous filter of the native tracer runs (`denoiser: "atrous"`, biased: it smooths) with a note in `denoiserNote`; `denoise: "wavelet"` picks the CPU filter (on `metal`, `lit-interior` and `metal-room` at 960 by 540, 64 and 256 samples, NVIDIA A10: the a-trous filter took 6 to 8 ms against 3.8 to 4.3 s for the wavelet filter and 0.23 s for OIDN, with the same relMSE as the wavelet filter to six digits and OIDN at 0.5 to 0.9 of it, #1018). The job report names the `kernel`, the `noiseThreshold` and the `averageSamples`. On the `metal` reference scene (960 by 540, 256 samples, NVIDIA A10, Vulkan, scored against Cycles 5.3 at 4096 samples with relMSE, the 100 worst pixels dropped, and FLIP): the default job frame step (`bench/native-tracer/metal-job.mjs`) took 1.64 s (1.22 s trace, 0.23 s OIDN) with relMSE 0.00007, against 5.57 s for the wavelet filter (relMSE 0.00014), 1.36 s for no filter (relMSE 0.00019, flat-area grain 0.0076 against 0.0024 filtered) and 1.23 s for the legacy kernel with OIDN (relMSE 0.00093, FLIP 0.039 against 0.009). `cycles` is the opt-in kernel that follows Blender Cycles 5.3: on six reference scenes at 4096 samples it matches Cycles within 1 percent of the mean and within 1.8 percent on every 8 by 8 tile, and its error at 256 samples on `lit-interior` is 0.0027 against 0.0198 for the legacy kernel (Cycles: 0.0031). Three options follow Cycles: `sampler` (`'sobol-burley'` blue-noise pattern by default, `'white'` for the hash sampler), `filterType` and `filterWidth` (`'box'` width 1 by default, `'gaussian'` and `'blackman-harris'` from the Cycles filter table) and `lightSampling` (`'auto'`, `'tree'` or `'uniform'`; the Cycles light tree is used from more than one emitter). It is 2.3 to 3.1 times slower per sample than the legacy kernel before the light tree (0.92 s against 2.86 s on `lit-interior`, 960 by 540, 256 samples), and the light tree adds 16 to 32 percent per sample on top; at equal error against Cycles 5.3 it is 1.2 times faster on `lit-interior` and 3 to 6 percent slower on `many-lights-500` on an RTX 3060, and 1.5 times faster and level (1.02 to 1.03 times) on an NVIDIA A10G. Tables, method and the equal-error caveat are in [cycles-parity.md](cycles-parity.md#selecting-the-kernel).`backend: 'cpu'` (the default) is the reference: it reuses `src/triangle-bvh.js` and `src/ray-query.js`, runs on workers in the job page next to the scene, needs no GPU, and gives the same bytes for the same scene and options. It measured 25 to 238 seconds for a 960 by 540 still at 32 samples on a Ryzen 5 5600X with four threads, while another session also loaded the machine (table in `bench/reference/README.md`).diff --git a/packages/denoise-oidn/README.md b/packages/denoise-oidn/README.mdindex 35227902..1a9acaca 100644--- a/packages/denoise-oidn/README.md+++ b/packages/denoise-oidn/README.md@@ -7,6 +7,6 @@ npm install @codepawlhq/67js-denoise-oidnnpm run fetch --prefix node_modules/@codepawlhq/67js-denoise-oidn # downloads the release for this platform into ./vendor after a SHA-256 check```-Then ask a render job for it: `settings.renderer: { type: "pathTracer", denoise: "oidn" }`. Samples default to 16 for `oidn`. If the package or its binary is missing, the job uses the wavelet filter and says so in `metrics.pathTracer.denoiserNote`. `OIDN_DENOISE_PATH` points at an `oidnDenoise` you installed yourself.+Then ask a render job for it: `settings.renderer: { type: "pathTracer", denoise: "oidn" }`. Samples default to 16 for `oidn`. If the package or its binary is missing, the job uses the wavelet filter (the GPU a-trous filter of the native tracer on `backend: "native"`) and says so in `metrics.pathTracer.denoiserNote`. `OIDN_DENOISE_PATH` points at an `oidnDenoise` you installed yourself.`denoiseWithOidn({ width, height, color, albedo, normal })` takes row-major `Float32Array`s with three floats per pixel and returns the filtered colour. It runs on the CPU by default, so the GPU stays free and the result does not depend on a graphics driver. On one machine the same input gave the same bytes twice (measured).diff --git a/scripts/agent-native-trace.mjs b/scripts/agent-native-trace.mjsindex 08434461..0c058313 100644--- a/scripts/agent-native-trace.mjs+++ b/scripts/agent-native-trace.mjs@@ -108,12 +108,29 @@ export function chooseNativeKernel(environment = process.env) {}/**- * Traces one frame the page exported and returns the PNG (base64) with the job report. `denoise` is "none", "wavelet" or- * "oidn"; `denoiser` is the loaded OIDN package for "oidn". Throws when the tracer cannot run, so the caller can fall back.+ * The traced colour after the GPU a-trous filter, three floats per pixel. The cycles kernel already returned it when the+ * trace asked for `denoise: "atrous"`; otherwise (the legacy kernel, or the filter after OIDN failed) the tracer filters+ * the traced image with its guide buffers. Throws when the installed package cannot filter.+ */+function atrousColor({ tracer, traced, width, height }) {+ let filtered = traced.denoisedRgba;+ if (!filtered) {+ if (typeof tracer.denoiseAtrous !== 'function') throw new Error('the installed render-native package has no a-trous filter');+ const { rgba, albedo, normal, depth, variance } = traced;+ filtered = tracer.denoiseAtrous({ width, height, rgba, albedo, normal, depth, variance }).rgba;+ }+ return withoutAlpha(filtered, width * height);+}++/**+ * Traces one frame the page exported and returns the PNG (base64) with the job report. `denoise` is "none", "wavelet",+ * "atrous" (the tracer's GPU filter, which is also where a missing or failing OIDN lands) or "oidn"; `denoiser` is the+ * loaded OIDN package for "oidn". Throws when the tracer cannot run, so the caller can fall back.*/export async function traceFrameNative({ tracer, exported, width, height, samples, bounces, seed, denoise, denoiser, maxSeconds, noiseThreshold = 0, kernel = chooseNativeKernel() }) {const started = performance.now();- const traced = tracer.traceNative(decodeTables(exported), { width, height, samples, maxSeconds, kernel, noiseThreshold });+ const filtersInTrace = denoise === 'atrous' && kernel === 'cycles';+ const traced = tracer.traceNative(decodeTables(exported), { width, height, samples, maxSeconds, kernel, noiseThreshold, ...(filtersInTrace ? { denoise: 'atrous' } : {}) });const tracedSeconds = (performance.now() - started) / 1000;const pixelCount = width * height;const features = { color: withoutAlpha(traced.rgba, pixelCount), albedo: traced.albedo, normal: traced.normal,@@ -130,7 +147,17 @@ export async function traceFrameNative({ tracer, exported, width, height, samplelinear = await denoiser.denoiseWithOidn({ width, height, color: features.color, albedo: features.albedo, normal: features.normal });Object.assign(report, { denoised: true, denoiser: 'oidn', oidnVersion: denoiser.OIDN_VERSION });} catch (error) {- report.denoiserNote = `OIDN failed (${error.message}): the wavelet filter ran instead.`;+ report.denoiserNote = `OIDN failed (${error.message}): the GPU a-trous filter ran instead.`;+ denoise = 'atrous';+ }+ }+ if (denoise === 'atrous') {+ try {+ linear = atrousColor({ tracer, traced, width, height });+ Object.assign(report, { denoised: true, denoiser: 'atrous' });+ } catch (error) {+ const failure = `The GPU a-trous filter failed (${error.message}): the wavelet filter ran instead.`;+ report.denoiserNote = [report.denoiserNote, failure].filter(Boolean).join(' ');denoise = 'wavelet';}}diff --git a/scripts/agent-path-trace-denoise.mjs b/scripts/agent-path-trace-denoise.mjsindex 4bba73b6..7e10fa6d 100644--- a/scripts/agent-path-trace-denoise.mjs+++ b/scripts/agent-path-trace-denoise.mjs@@ -26,7 +26,9 @@ async function loadOidnPackage() {* What a job's `settings.renderer.denoise` becomes. "oidn" needs the optional package and its binary; without them the* wavelet filter runs instead and `note` says so, so the job result never claims a denoiser that did not run.* `preferOidn` is set for the native backend: there the default (`true`) means OIDN with the albedo and normal guides when- * it is installed, else the wavelet filter with the same guides, and the note says why. Explicit values keep their meaning.+ * it is installed, and the GPU a-trous filter of the native tracer when it is not ("atrous", biased: it smooths), with a note+ * that says why. An explicit "oidn" falls back the same way on native. Other backends fall back to the wavelet filter, and+ * explicit values ("wavelet", "none", false) keep their meaning everywhere.*/export async function chooseDenoiser(requested, { preferOidn = false, loadOidn = loadOidnPackage } = {}) {const defaultsToOidn = preferOidn && requested === true;@@ -38,9 +40,9 @@ export async function chooseDenoiser(requested, { preferOidn = false, loadOidn =: { denoise: 'oidn', denoiser };}const reason = `needs ${OIDN_PACKAGE} and its binary (npm run fetch in that package, or OIDN_DENOISE_PATH)`;- return { denoise: 'wavelet', note: defaultsToOidn- ? `The native backend denoises with OIDN, which ${reason}: the wavelet filter ran instead.`- : `denoise "oidn" ${reason}: the wavelet filter ran instead.` };+ const lead = defaultsToOidn ? 'The native backend denoises with OIDN, which' : 'denoise "oidn"';+ if (preferOidn) return { denoise: 'atrous', note: `${lead} ${reason}: the GPU a-trous filter ran instead (it smooths, so it is biased; denoise "wavelet" picks the CPU filter).` };+ return { denoise: 'wavelet', note: `${lead} ${reason}: the wavelet filter ran instead.` };}function floatsFromBase64(base64) {diff --git a/scripts/agent-runtime.mjs b/scripts/agent-runtime.mjsindex c9977f0b..f20b7b5e 100644--- a/scripts/agent-runtime.mjs+++ b/scripts/agent-runtime.mjs@@ -587,7 +587,8 @@ export function createAgentRuntime({ kernelWorkers = true, backend = 'gpu', brow}}if (backendNote) traced.report.backendNote = backendNote;- if (choice.note) traced.report.denoiserNote = choice.note;+ const denoiserNote = [choice.note, traced.report.denoiserNote].filter(Boolean).join(' ');+ if (denoiserNote) traced.report.denoiserNote = denoiserNote;metrics.renderSeconds += (performance.now() - renderStarted) / 1000;metrics.width = width;metrics.height = height;diff --git a/tests/agent-native-trace.test.js b/tests/agent-native-trace.test.jsindex 0d863dc2..c006b5dd 100644--- a/tests/agent-native-trace.test.js+++ b/tests/agent-native-trace.test.js@@ -104,3 +104,64 @@ test('the wavelet filter and OIDN both run on the native features', async () =>const withWavelet = await traceFrameNative({ tracer: tracerRecording(calls), exported: emptyExport, width: 4, height: 4, samples: 8, denoise: 'wavelet' });assert.equal(withWavelet.report.denoiser, 'wavelet');});++function tracerWithAtrous(calls, { failFilter = false } = {}) {+ const pixels = 4 * 4;+ const tracer = tracerRecording(calls);+ const traceNative = tracer.traceNative;+ tracer.traceNative = (tables, options) => {+ const traced = traceNative(tables, options);+ return options.denoise === 'atrous' ? { ...traced, denoisedRgba: new Float32Array(pixels * 4).fill(0.25) } : traced;+ };+ tracer.denoiseAtrous = input => {+ calls.push({ afterwards: Object.keys(input).sort() });+ if (failFilter) throw new Error('no adapter');+ return { rgba: new Float32Array(pixels * 4).fill(0.25) };+ };+ return tracer;+}++const failingDenoiser = { OIDN_VERSION: 'test', async denoiseWithOidn() { throw new Error('binary crashed'); } };++test('denoise "atrous" asks the cycles kernel for the filtered image and reports it', async () => {+ const calls = [];+ const traced = await traceFrameNative({ tracer: tracerWithAtrous(calls), exported: emptyExport, width: 4, height: 4, samples: 8, denoise: 'atrous', kernel: 'cycles' });+ assert.equal(calls[0].denoise, 'atrous');+ assert.equal(calls.length, 1);+ assert.equal(traced.report.denoiser, 'atrous');+ assert.equal(traced.report.denoised, true);+ assert.equal(typeof traced.report.denoiseSeconds, 'number');+});++test('denoise "atrous" on the legacy kernel filters the traced image afterwards', async () => {+ const calls = [];+ const traced = await traceFrameNative({ tracer: tracerWithAtrous(calls), exported: emptyExport, width: 4, height: 4, samples: 8, denoise: 'atrous', kernel: 'legacy' });+ assert.equal(calls[0].denoise, undefined);+ assert.deepEqual(calls[1].afterwards, ['albedo', 'depth', 'height', 'normal', 'rgba', 'variance', 'width']);+ assert.equal(traced.report.denoiser, 'atrous');+});++test('OIDN failing on native falls back to the GPU a-trous filter and says so', async () => {+ const calls = [];+ const traced = await traceFrameNative({ tracer: tracerWithAtrous(calls), exported: emptyExport, width: 4, height: 4, samples: 8, denoise: 'oidn', denoiser: failingDenoiser, kernel: 'cycles' });+ assert.equal(traced.report.denoiser, 'atrous');+ assert.match(traced.report.denoiserNote, /OIDN failed \(binary crashed\): the GPU a-trous filter ran instead/);+});++test('the wavelet filter is the last resort when the a-trous filter cannot run', async () => {+ const traced = await traceFrameNative({ tracer: tracerWithAtrous([], { failFilter: true }), exported: emptyExport, width: 4, height: 4, samples: 8, denoise: 'oidn', denoiser: failingDenoiser, kernel: 'legacy' });+ assert.equal(traced.report.denoiser, 'wavelet');+ assert.match(traced.report.denoiserNote, /OIDN failed.*a-trous filter failed \(no adapter\): the wavelet filter ran instead/);+ const withoutFilter = await traceFrameNative({ tracer: tracerRecording([]), exported: emptyExport, width: 4, height: 4, samples: 8, denoise: 'atrous', kernel: 'legacy' });+ assert.equal(withoutFilter.report.denoiser, 'wavelet');+ assert.match(withoutFilter.report.denoiserNote, /no a-trous filter/);+});++test('explicit wavelet and no filter never reach the a-trous filter', async () => {+ const calls = [];+ const wavelet = await traceFrameNative({ tracer: tracerWithAtrous(calls), exported: emptyExport, width: 4, height: 4, samples: 8, denoise: 'wavelet', kernel: 'cycles' });+ const none = await traceFrameNative({ tracer: tracerWithAtrous(calls), exported: emptyExport, width: 4, height: 4, samples: 8, denoise: 'none', kernel: 'cycles' });+ assert.equal(wavelet.report.denoiser, 'wavelet');+ assert.equal(none.report.denoiser, 'none');+ assert.ok(calls.every(call => call.denoise === undefined && !call.afterwards));+});diff --git a/tests/path-tracer-denoise-oidn.test.js b/tests/path-tracer-denoise-oidn.test.jsindex ce4fea8a..a13aca73 100644--- a/tests/path-tracer-denoise-oidn.test.js+++ b/tests/path-tracer-denoise-oidn.test.js@@ -77,15 +77,21 @@ test('the installed OIDN removes noise from a flat image and gives the same byteassert.deepEqual(first, second);});-test('the native default (denoise true) picks OIDN when it is installed and the wavelet filter with a note when it is not', async () => {+test('the native default (denoise true) picks OIDN when it is installed and the GPU a-trous filter with a note when it is not', async () => {const installed = { findOidnBinary: () => 'oidn' };const withOidn = await chooseDenoiser(true, { preferOidn: true, loadOidn: async () => installed });assert.equal(withOidn.denoise, 'oidn');assert.equal(withOidn.denoiser, installed);assert.match(withOidn.note, /OIDN and the albedo and normal guides by default/);const without = await chooseDenoiser(true, { preferOidn: true, loadOidn: async () => null });- assert.equal(without.denoise, 'wavelet');- assert.match(without.note, /native backend denoises with OIDN.*wavelet filter ran instead/s);+ assert.equal(without.denoise, 'atrous');+ assert.match(without.note, /native backend denoises with OIDN.*GPU a-trous filter ran instead/s);+ const explicit = await chooseDenoiser('oidn', { preferOidn: true, loadOidn: async () => null });+ assert.equal(explicit.denoise, 'atrous');+ assert.match(explicit.note, /denoise "oidn".*GPU a-trous filter ran instead/s);+ const otherBackends = await chooseDenoiser(true, { loadOidn: async () => null });+ assert.deepEqual(otherBackends, { denoise: true });+ assert.equal((await chooseDenoiser('oidn', { loadOidn: async () => null })).denoise, 'wavelet');});test('explicit denoise values keep their meaning on native and the other backends keep the plain default', async () => {