The native runtime for three.js: three.js, down to the metal. 45× smaller than Electron, on a Sony PS3, and path-traced at 60 fps on ray-tracing GPUs.
Rust electron-alternativegame-engineglobal-illuminationgraphicsjavascript-runtimemetalpath-tracingray-tracingreal-time-renderingrenderingrustthreejstypescriptvoxelvulkanwebgpuwgpu
Kernel: each live approximation tested and measured; two removed (#94)
Yujiaab50c813b583
diff --git a/docs/ROADMAP.md b/docs/ROADMAP.mdindex f9d94ab..2668ee2 100644--- a/docs/ROADMAP.md+++ b/docs/ROADMAP.md@@ -2412,6 +2412,21 @@ offline none as before, and a live view can run without them (`THREERT_APPROX=0`the trace is equal (Bistro 8.52 / 8.52 ms). Next: a test for each that holds the live picture without it to the offline one,their bias and cost measured again, and the defaults decided from that.+**Each shortcut measured; two removed (2026-11-15, after it).** A pair of tests holds each approximation: the live+view as shipped reads its bias, without the bit it reads the offline value (light under tinted glass 4.3 x, behind+a medium e x, the sky under a clear cutout card 18 %, an emitter behind one black, panels 150 m away 3 %). Each was+timed with its bit off, the loop guard on, in Bistro, Kabukichō, Zero Day, a glass scene, the fire scene, the+Bistro slice, the 3 x 3 district and Tokyo (docs/RUNTIME.md's table). Two did not pay and are gone: the+single-query shadow ray past cutouts (Bistro 10.13 ms with it, 10.09 without where its foliage is nearest; it lost+hits on Metal) and the switch for white noise (variance only: what live does, not a bit). Two more looked removable+on a small scene and were not on a large one: exact media shadows cost the fire scene 0.10 ms and the Bistro slice+0.84 (9 %); the far-emitter cut saves the district 0.15 ms and Tokyo from the air half its trace (4.7 ms for 9.2).+Both stay. Against main: the trace Bistro 8.57 / 8.50 ms, lamp-rooms 3.71 / 3.73, Zero Day 9.58 / 9.52, Kabukichō+17.10 / 16.95 guarded, Tokyo at night 4.68 / 4.77 guarded (the query's saving there); render-identity in four+layouts changes only the five tests that name bits (renumbered); bench-window's shots as main's, Kabukichō and+Tokyo too. Next: a camera hit's light through a cutout loses the BSDF ray's share of its MIS weight (the 18 %);+then the cutout bits' defaults.+## 2. Temporal fixesTargets (2026-11-08): bench-temporal, bench-ghosting and their UE MRQ references move to Bistro night (§ 0 step 7); thediff --git a/docs/RUNTIME.md b/docs/RUNTIME.mdindex 1d2136a..c9d7238 100644--- a/docs/RUNTIME.md+++ b/docs/RUNTIME.md@@ -1351,23 +1351,25 @@ two kinds.has all (`gpu::A_LIVE`) unless `THREERT_APPROX=<bits>` says otherwise (`0`: the offline estimator's rays in a liveview, the way to hold a live picture to the offline one).-| bit | what a live ray does | recorded when it was taken |-|---|---|---|-| 1 `A_GLASS_SHADOWS` | shadow rays to the analytic lights and the sky pass glass in full, untinted | dark water near the camera +11 % of its +20 %; one more trace a shadow ray in glass scenes |-| 2 `A_MEDIA_SHADOWS` | only homogeneous media dim shadow rays: smoke and fire cast no shadow | the volume functions at every shadow ray: Kabukichō 0.4 ms with a smoke column out of view |-| 4 `A_CUTOUT_PATHS` | cutouts are opaque to rays past a camera hit's own, off mirror paths | Bistro's frame 16.1 / 19.9 -> 14.2 / 16.0 ms; the picture 0.3 % darker |-| 8 `A_CUTOUT_EMITTERS` | cutouts are opaque to emitters' shadow rays | 0.9 ms of the Bistro crowd's frame; 1.7 % of the light under foliage |-| 16 `A_SHADOW_QUERY` | hardware traversal: a shadow ray past a cutout is one query with a candidate loop (it loses hits on Metal) | 1.6 ms of Bistro's trace at its worst; ΔE +0.04 |-| 32 `A_FAR_EMITTERS` | the light tree proposes no emitter beyond 120 m; without a tree, the emitter cull (60 m, 120 m in view) | the 3 x 3 district 2.0 -> 0.5 ms; Tokyo's dusk aerials 10-12 % dark, far emitters' glow in fog lost |-| 64 `A_WHITE_NOISE` | a hash, not Sobol, past the camera hit's own decisions (variance only) | all-Sobol: +2.1 ms of Bistro's 8.4 ms trace |--Bistro held still, all of them off: ΔE against the offline render 1.82 -> 1.67 (bench-window `still-bistro`).+| bit | what a live ray does | its bias (a test pair, `-live` / `-live-exact`) | exact costs the trace |+|---|---|---|---|+| 1 `A_GLASS_SHADOWS` | shadow rays to the analytic lights and the sky pass glass in full, untinted | light under tinted glass 4.3 x (`shadow/glass-tint`) | a glass scene +34 % (khronos-transmission 5.20 -> 6.97 ms) |+| 2 `A_MEDIA_SHADOWS` | only homogeneous media dim shadow rays: smoke and fire cast no shadow | light behind optical depth 1: e x (`shadow/medium`) | the Bistro slice +0.84 ms (9 %), the fire scene +0.10 |+| 4 `A_CUTOUT_PATHS` | cutouts are opaque to rays past a camera hit's own, off mirror paths | the sky under a clear card: 18 % of it (`sky/cutout-clear`) | Bistro +1.48 ms of 9.06 |+| 8 `A_CUTOUT_EMITTERS` | cutouts are opaque to emitters' shadow rays | an emitter behind a clear card: black (`shadow/cutout-emitter`) | Bistro +0.62 ms |+| 16 `A_FAR_EMITTERS` | the light tree proposes no emitter beyond 120 m; without a tree, the emitter cull (60 m, 120 m in view) | panels 150 m up: 3 % of their light (`light/emitter-far`); Kabukichō's and Tokyo's shots unchanged | Tokyo from the air 4.7 -> 9.2 ms; the 3 x 3 district +0.15 |++Measured 2026-11-15 with the loop guard on. Bistro held still, ΔE against the offline render: 1.82 as shipped, 1.66+without the two cutout bits, which cost Kabukichō and Zero Day time instead (0.75 and 0.80 ms less without them).+Two more were removed that day: a single-query shadow ray past cutouts (it saved nothing: Bistro 10.13 ms with it,+10.09 without, Tokyo +0.05) and the switch for the sampler below.**The live architecture**, not switches: the path ends in the radiance cache at its first bounce that is not throughglass; the cache term, its training (4 x) and each sample (256) are clamped beside the kernel's own clamp; at most4 bounces; a camera ray's media are marched and composited after the trace with isotropic in-scatter from thecache's voxels, and later segments meet homogeneous media alone; depth of field is a post pass; translucent-particles are lit from the cache's voxels.+particles are lit from the cache's voxels; past a camera hit's own decisions the sampler is a hash, not Sobol+(variance only).## What the kernel trustsdiff --git a/renderer/shaders/pathtrace.wgsl b/renderer/shaders/pathtrace.wgslindex e3290b8..197a0f0 100644--- a/renderer/shaders/pathtrace.wgsl+++ b/renderer/shaders/pathtrace.wgsl@@ -64,9 +64,7 @@ const A_GLASS_SHADOWS: u32 = 1u; // shadow rays to the analytic lights and theconst A_MEDIA_SHADOWS: u32 = 2u; // of the media only the homogeneous ones dim shadow rays (`media_shadows`)const A_CUTOUT_PATHS: u32 = 4u; // cutouts are opaque to rays past a camera hit's own, off mirror paths (`cutouts_opaque`)const A_CUTOUT_EMITTERS: u32 = 8u; // cutouts are opaque to emitters' shadow rays (`occluded_emitter`)-const A_SHADOW_QUERY: u32 = 16u; // hardware traversal: a shadow ray past a cutout is one query with a candidate loop (trace_hw.wgsl)-const A_FAR_EMITTERS: u32 = 32u; // the light tree proposes no emitter beyond LT_FAR (`lt_imp`; without a tree: the emitter cull)-const A_WHITE_NOISE: u32 = 64u; // variance only: a hash, not Sobol, past the camera hit's own decisions (sample.wgsl `rng_white`)+const A_FAR_EMITTERS: u32 = 16u; // the light tree proposes no emitter beyond LT_FAR (`lt_imp`; without a tree: the emitter cull)fn approx(a: u32) -> bool { return (APPROX & a) != 0u; }// Features the scene uses (gpu::F_*): the rest is compiled out, so plain scenes pay nothing for them.override FEAT: u32 = 0xffffffffu;@@ -346,8 +344,8 @@ fn emitter_pick_u(u: f32) -> vec4<f32> {// them (from entry P.ltree.y).const LT_LEAF: u32 = 0x80000000u;const LT_PATH_BITS: u32 = 26u;-// A_FAR_EMITTERS: tree nodes wholly farther than this (m) from the shading point are not proposed (never within one-// Bistro; in the 3 x 3 district its far copies: 2.0 -> 0.5 ms).+// A_FAR_EMITTERS: tree nodes wholly farther than this (m) from the shading point are not proposed. A city's emitters+// are mostly that far from any one point: Tokyo's aerial view traces in 4.7 ms with the cut, 9.2 without.const LT_FAR: f32 = 120.0;fn lt_on() -> bool { return P.ltree.w > 0.5; }@@ -372,7 +370,7 @@ fn lt_imp(nd: vec4<f32>, x: vec3<f32>, n: vec3<f32>) -> f32 {}}// A_FAR_EMITTERS: nodes wholly farther than LT_FAR from x are not proposed (their light comes by BSDF rays,- // emit_mis weighs them 1): shadow rays across a district cost more than the light they find.+ // emit_mis weighs them 1): shadow rays across a city cost more than the light they find.if (approx(A_FAR_EMITTERS) && d2 > (LT_FAR + czr.y) * (LT_FAR + czr.y)) { return 0.0; }return nd.z * cb / max(d2, r2);}diff --git a/renderer/shaders/sample.wgsl b/renderer/shaders/sample.wgslindex feb1bcb..038564a 100644--- a/renderer/shaders/sample.wgsl+++ b/renderer/shaders/sample.wgsl@@ -129,10 +129,10 @@ const D_VOL_LIGHT: u32 = 14u; // lights at a point in a medium (`phase_direct`,const D_VOXEL: u32 = 15u; // the radiance cache's volume points (`point_sphere`)const D_CACHE: u32 = 16u; // the cache's fixed-point dither-// A_WHITE_NOISE (live): Sobol only for the camera path's first vertex (not a loop's parts: `rng_sub` sets the top-// bit), a hash elsewhere (as NVIDIA's RTXPT; all-Sobol cost 2 ms of Bistro's trace). Without it: Sobol everywhere-// (offline, as Cycles).-fn rng_white(d: u32) -> bool { return approx(A_WHITE_NOISE) && (cur_depth > 0u || RNG_PATH != 0u || d >= 0x80000000u); }+// Live: Sobol only for the camera path's first vertex (not a loop's parts: `rng_sub` sets the top bit), a hash+// elsewhere (as NVIDIA's RTXPT; variance only: all-Sobol is 0.14 ms more of Bistro's trace, 0.9 of Kabukichō's, for+// flicker 0.443 -> 0.431). Offline: Sobol everywhere (as Cycles).+fn rng_white(d: u32) -> bool { return LIVE && (cur_depth > 0u || RNG_PATH != 0u || d >= 0x80000000u); }fn white(d: u32, c: u32) -> f32 { return f32(hash_hp(rng_seed(d) ^ (RNG_INDEX * 0x9e3779b9u + c * 0x85ebca6bu)) >> 8u) * (1.0 / 16777216.0); }// A hash, always: for loops of no fixed length (delta tracking's steps), where a new Sobol dimension a step is QMC'sdiff --git a/renderer/shaders/trace_hw.wgsl b/renderer/shaders/trace_hw.wgslindex 0cc0af6..0925168 100644--- a/renderer/shaders/trace_hw.wgsl+++ b/renderer/shaders/trace_hw.wgsl@@ -12,27 +12,22 @@let h = trace_opaque(o, d, tmax_in, mask, mode != TRACE_CLOSEST);return h;}- // Live secondary rays, and live emitter shadow rays (TRACE_ANY_OPAQUE): cutouts opaque (pathtrace.wgsl- // `cutouts_opaque`, `occluded_emitter`).+ // A_CUTOUT_PATHS, A_CUTOUT_EMITTERS (TRACE_ANY_OPAQUE): cutouts opaque (pathtrace.wgsl `cutouts_opaque`,+ // `occluded_emitter`).@if(!cutout_lite) if (cutouts_opaque() || mode == TRACE_ANY_OPAQUE) { return trace_opaque(o, d, tmax_in, mask, mode != TRACE_CLOSEST); }@if(cutout_lite) if (cutouts_opaque() || mode != TRACE_CLOSEST) { return trace_opaque(o, d, tmax_in, mask, mode != TRACE_CLOSEST); }// Alpha-cutout triangles: every query forces opacity, and a cutout hit that fails its alpha test is stepped// through. The ray query's own candidate loop (non-opaque traversal) lost hits on Metal: ~0.1 % of rays near// cutout foliage missed even the opaque ground behind it or found it unlit (black pixels on the ground; the- // software BVH had none, and confirming every candidate did not help). Fewer whole-scene steps (the opaque- // instances once, then the cutout instances alone; or one candidate loop on them) came out within ±0.4 ms on- // Bistro: the leaves' alpha tests and the traversal past them cost it, however the queries are arranged. Culling- // the cutout geometry by its non-opaque flag (RAY_FLAG_CULL_NO_OPAQUE) is slow on Metal (Bistro's trace +1.7 ms).+ // software BVH had none, and confirming every candidate did not help), differently from run to run (two offline+ // renders of Kabukichō differed in 75 % of their pixels). Fewer whole-scene steps (the opaque instances once, then+ // the cutout instances alone; or one candidate loop on them) came out within ±0.4 ms on Bistro: the leaves' alpha+ // tests and the traversal past them cost it, however the queries are arranged. Culling the cutout geometry by its+ // non-opaque flag (RAY_FLAG_CULL_NO_OPAQUE) is slow on Metal (Bistro's trace +1.7 ms).if (mode != TRACE_CLOSEST) {// Any hit blocks a shadow ray, except a cutout one that its alpha lets through.let h = trace_opaque(o, d, tmax_in, mask, true);if (h.tri == 0xffffffffu || is_proc(h) || !cutout(h.tri) || alpha_pass(h.tri, h.inst, h.u, h.v, h.t)) { return h; }- // A_SHADOW_QUERY: one query whose candidate loop alpha-tests the cutouts (`trace_any_cutout`). It loses hits on Metal- // from run to run, confirmed ones too: offline it made two runs of one render differ in 75 % of Kabukichō's- // pixels and 98 % of Bistro's at 64 spp (the ordered steps below: 0–0.06 % and 2–10 %, Bistro's own share of- // ties). Live it is 1.6 ms of Bistro's trace less at its worst stretch, its image ΔE +0.04 against the- // unbiased render; offline, which is that render, steps in order.- if (approx(A_SHADOW_QUERY)) { return trace_any_cutout(o, d, tmax_in, mask); }}// In order, each query starting past the last cutout hit its alpha let through. Shadow rays take up to 64 of them// and count as blocked past that: with 16, as closest hits take, the rest counted as unblocked (light through dense@@ -51,37 +46,6 @@return Hit(tmax_in, 0xffffffffu, 0.0, 0.0, NO_INST);}-// One query, not forced opaque; each cutout candidate that passes its alpha test is confirmed, which ends it (as does any-// opaque triangle). Live only (see `trace`).-@if(hwrt) fn trace_any_cutout(o: vec3<f32>, d: vec3<f32>, tmax_in: f32, mask: u32) -> Hit {- @if(strict) if (ray_bad(o, d, tmax_in)) { return Hit(tmax_in, 0xffffffffu, 0.0, 0.0, NO_INST); }- var rq: ray_query;- rayQueryInitialize(&rq, acc, RayDesc(RAY_FLAG_TERMINATE_ON_FIRST_HIT, mask, 0.0, tmax_in, o, d));- var pg = GOut(-1.0, vec3<f32>(0.0, 1.0, 0.0), 0u, vec2<f32>(0.0));- var pprim = 0u;- while (rayQueryProceed(&rq)) {- let c = rayQueryGetCandidateIntersection(&rq);- if (has(F_PROC) && c.kind == RAY_QUERY_INTERSECTION_AABB) {- let g = proc_box(c.instance_custom_data, c.primitive_index, c.world_to_object * vec4<f32>(o, 1.0), c.world_to_object * vec4<f32>(d, 0.0), 0.0, tmax_in);- // (naga: the hit distance as its own value, not `g.t`, which it scopes wrongly for the ray-query statement.)- let gt = g.t;- if (gt >= 0.0) {- pg = g;- pprim = c.primitive_index;- rayQueryGenerateIntersection(&rq, gt);- }- continue;- }- if (c.kind != RAY_QUERY_INTERSECTION_TRIANGLE) { continue; }- let ti = hit_tri(c.instance_custom_data, c.geometry_index, c.primitive_index);- if (alpha_pass(ti, hit_inst(c.instance_custom_data), c.barycentrics.x, c.barycentrics.y, c.t)) { rayQueryConfirmIntersection(&rq); }- }- let it = rayQueryGetCommittedIntersection(&rq);- if (it.kind == RAY_QUERY_INTERSECTION_NONE) { return Hit(tmax_in, 0xffffffffu, 0.0, 0.0, NO_INST); }- if (has(F_PROC) && it.kind == RAY_QUERY_INTERSECTION_GENERATED) { return proc_hit(it.t, pg, pprim, it.instance_custom_data); }- return Hit(it.t, hit_tri(it.instance_custom_data, it.geometry_index, it.primitive_index), it.barycentrics.x, it.barycentrics.y, hit_inst(it.instance_custom_data));-}-// The closest (or with `any`, the first found) hit, every triangle opaque.@if(hwrt) fn trace_opaque(o: vec3<f32>, d: vec3<f32>, tmax_in: f32, mask: u32, any: bool) -> Hit {@if(strict) if (ray_bad(o, d, tmax_in)) { return Hit(tmax_in, 0xffffffffu, 0.0, 0.0, NO_INST); }diff --git a/renderer/src/gpu.rs b/renderer/src/gpu.rsindex 8119c35..5f6bc36 100644--- a/renderer/src/gpu.rs+++ b/renderer/src/gpu.rs@@ -19,8 +19,10 @@ pub struct Gpu {pub uniform_tables: bool,/// The kernel's switches this device was opened with (`KernelSwitches`): they are in `source`.pub switches: KernelSwitches,- /// The approximations a live view's kernel takes (`A_*`; `GpuOptions::approx`).+ /// The approximations a live view's kernel takes (`A_*`): the options' (`GpuOptions::approx`) unless a view asked+ /// for others (`set_approx`).pub approx: u32,+ approx_default: u32,/// Compiled pipelines kept between runs (`GpuOptions::pipeline_cache`), where the backend has such a cache.pipeline_cache: Option<crate::pipeline_cache::PipelineCache>,/// Kernel source (hardware or software traversal spliced in); scenes with material functions get their own module.@@ -1463,11 +1465,9 @@ pub const A_GLASS_SHADOWS: u32 = 1;pub const A_MEDIA_SHADOWS: u32 = 2;pub const A_CUTOUT_PATHS: u32 = 4;pub const A_CUTOUT_EMITTERS: u32 = 8;-pub const A_SHADOW_QUERY: u32 = 16;-pub const A_FAR_EMITTERS: u32 = 32;-pub const A_WHITE_NOISE: u32 = 64;+pub const A_FAR_EMITTERS: u32 = 16;/// All of them: what a live view takes unless it asks otherwise (`GpuOptions::approx`).-pub const A_LIVE: u32 = 127;+pub const A_LIVE: u32 = 31;// Kernel features (`override FEAT` in pathtrace.wgsl).pub const F_MASKED: u32 = 1;@@ -1752,7 +1752,7 @@ impl Gpu {} else {(None, None)};- Ok(Gpu { instance, adapter, timestamps, device, queue, adapter_info, uniform_tables, switches, approx, pipeline_cache, source: src, module, merged, modules: Default::default(), pipeline_layout: pl, pipelines: Default::default(), layout, vis_layout, no_vis, no_vis_bufs, no_vis_view, no_grid_view, grid_layout, hwrt, pages: Default::default(), tl_layout, tl_pipeline_layout, tl_pipelines: Default::default(), media_passes: Default::default(), proc_cache: Default::default(), proc_blases: Default::default() })+ Ok(Gpu { instance, adapter, timestamps, device, queue, adapter_info, uniform_tables, switches, approx, approx_default: approx, pipeline_cache, source: src, module, merged, modules: Default::default(), pipeline_layout: pl, pipelines: Default::default(), layout, vis_layout, no_vis, no_vis_bufs, no_vis_view, no_grid_view, grid_layout, hwrt, pages: Default::default(), tl_layout, tl_pipeline_layout, tl_pipelines: Default::default(), media_passes: Default::default(), proc_cache: Default::default(), proc_blases: Default::default() })}/// Whether this device's kernel buffers have the loop guard's count (`guard_room`; always in the merged layout).@@ -1774,6 +1774,11 @@ impl Gpu {}}+ /// The approximations of the live views made on this device from now on (`A_*`; None: the options').+ pub fn set_approx(&mut self, approx: Option<u32>) {+ self.approx = approx.unwrap_or(self.approx_default) & A_LIVE;+ }+/// The path-tracing kernel specialised for a scene (feature mask + material functions), compiled on first use.pub fn pipeline(&self, k: &Kernel, live: bool) -> wgpu::ComputePipeline {let mut cache = self.pipelines.lock().unwrap();@@ -3372,16 +3377,19 @@ mod tests {}let wgsl = include_str!("../shaders/pathtrace.wgsl");// The live approximations: one bit each, the shader's the same, `A_LIVE` all of them.- let approx = [- ("A_GLASS_SHADOWS", A_GLASS_SHADOWS), ("A_MEDIA_SHADOWS", A_MEDIA_SHADOWS), ("A_CUTOUT_PATHS", A_CUTOUT_PATHS), ("A_CUTOUT_EMITTERS", A_CUTOUT_EMITTERS),- ("A_SHADOW_QUERY", A_SHADOW_QUERY), ("A_FAR_EMITTERS", A_FAR_EMITTERS), ("A_WHITE_NOISE", A_WHITE_NOISE),- ];+ let approx = [("A_GLASS_SHADOWS", A_GLASS_SHADOWS), ("A_MEDIA_SHADOWS", A_MEDIA_SHADOWS), ("A_CUTOUT_PATHS", A_CUTOUT_PATHS), ("A_CUTOUT_EMITTERS", A_CUTOUT_EMITTERS), ("A_FAR_EMITTERS", A_FAR_EMITTERS)];assert_eq!(approx.iter().fold(0, |all, a| { assert!(a.1.is_power_of_two() && all & a.1 == 0, "{} = {}", a.0, a.1); all | a.1 }), A_LIVE);let declared: Vec<&str> = wgsl.lines().filter(|l| l.starts_with("const A_")).collect();assert_eq!(declared.len(), approx.len());for (name, bit) in approx {assert!(declared.iter().any(|l| l.starts_with(&format!("const {name}: u32 = {bit}u;"))), "{name}: pathtrace.wgsl and gpu.rs differ");}+ // (The render tests' names for them: tests/render/lib.ts `APPROX`.)+ let lib = include_str!("../../tests/render/lib.ts");+ for (name, bit) in [("glassShadows", A_GLASS_SHADOWS), ("mediaShadows", A_MEDIA_SHADOWS), ("cutoutPaths", A_CUTOUT_PATHS), ("cutoutEmitters", A_CUTOUT_EMITTERS), ("farEmitters", A_FAR_EMITTERS)] {+ assert!(lib.contains(&format!("{name}: {bit},")), "{name}: tests/render/lib.ts and gpu.rs differ");+ }+ assert!(lib.contains(&format!("all: {A_LIVE},")));assert!(wgsl.contains(&format!("const RIS_EXACT: u32 = {RIS_EXACT}u;")), "RIS_EXACT: pathtrace.wgsl and gpu.rs differ");for line in wgsl.lines().filter(|l| l.starts_with("const F_")) {let name = &line[6..line.find(':').unwrap()];@@ -3599,7 +3607,7 @@ mod tests {let plain = v(hwrt, KernelSwitches::default());let strict = v(hwrt, KernelSwitches { strict: true, ..Default::default() });let queries = strict.matches("rayQueryInitialize(").count();- assert_eq!(queries, if hwrt { 3 } else { 0 });+ assert_eq!(queries, if hwrt { 2 } else { 0 });assert_eq!(strict.matches("ray_bad(o, d, tmax").count(), queries, "every ray query is guarded");assert_eq!(strict.matches("fn ray_bad(").count(), hwrt as usize);assert!(!strict.contains("env_cdf_at(y - 1u)") && !strict.contains("env_cdf_at(base + x - 1u)") && plain.contains("env_cdf_at(y - 1u)"));diff --git a/renderer/src/main.rs b/renderer/src/main.rsindex be832dc..fd824b1 100644--- a/renderer/src/main.rs+++ b/renderer/src/main.rs@@ -39,6 +39,8 @@ struct Job {time: Option<f32>,size: (Option<u32>, Option<u32>),hdr: Option<PathBuf>,+ /// A live job's approximations (`gpu::A_*` bits; None: the device's).+ approx: Option<u32>,/// `--signals PREFIX`: PREFIX-diffuse.raw / -specular.raw / -emission.raw, the image's linear signals apart as the/// live denoiser splits them (RGB f32, output size; live snapshots to `*.signals` write the same).signals: Option<PathBuf>,@@ -176,6 +178,7 @@ fn main() -> Result<()> {time: flag("--time").map(|s| s.parse()).transpose()?,size: (flag("--width").map(|s| s.parse()).transpose()?, flag("--height").map(|s| s.parse()).transpose()?),hdr: flag("--hdr").map(PathBuf::from),+ approx: None,signals: flag("--signals").map(PathBuf::from),};let stats = render(&g, &job, &presets, init_ms, &mut Hosts::default())?;@@ -301,7 +304,8 @@ fn main() -> Result<()> {"serve" => {// One job per stdin line: {id, game: bundle path (or game module + runtime: runtime module), assets, room,// seed, state?, seq?, out, spp?, denoise?, overrides?, camera?, preset?, width?, height?, time?, hdr? (raw f32- // RGB linear radiance, nits), live? (frames of the real-time renderer instead, `render_live`)}; one result line+ // RGB linear radiance, nits), live? (frames of the real-time renderer instead, `render_live`), approx? (a+ // live job's approximations, `gpu::A_*` bits; the device's without)}; one result line// each: {id, ok, stats} or// {id, ok: false, error, missing?: [files to put under the asset root before retrying]}.let t0 = Instant::now();@@ -331,6 +335,7 @@ fn main() -> Result<()> {time: v["time"].as_f64().map(|t| t as f32),size: (v["width"].as_u64().map(|x| x as u32), v["height"].as_u64().map(|x| x as u32)),hdr: v["hdr"].as_str().map(PathBuf::from),+ approx: v["approx"].as_u64().map(|x| x as u32),signals: v["signals"].as_str().map(PathBuf::from),};match v["live"].as_u64() {@@ -379,10 +384,11 @@ fn render_live(slot: &mut Option<gpu::Gpu>, job: &Job, presets: &Path, frames: ureturn Err(MissingFiles(missing).into());}let (width, height) = (job.size.0.unwrap_or(w.settings.width), job.size.1.unwrap_or(w.settings.height));- let g = match slot.take() {+ let mut g = match slot.take() {Some(g) => g,None => gpu::Gpu::new()?,};+ g.set_approx(job.approx);let mut core = live::LiveCore::new(g, &w, &job.game.assets, presets, width, height)?;core.set_scale(1.0);drop(w);diff --git a/renderer/src/sample.rs b/renderer/src/sample.rsindex e7d3855..7d6ed1d 100644--- a/renderer/src/sample.rs+++ b/renderer/src/sample.rs@@ -124,7 +124,7 @@ mod tests {}}- /// sample.wgsl on the GPU gives these numbers, offline (no `A_WHITE_NOISE`; to the last place: a u32's conversion to f32+ /// sample.wgsl on the GPU gives these numbers, offline (`LIVE` false; to the last place: a u32's conversion to f32/// may round either way). (Skipped without a GPU.)#[test]fn the_shader_is_this() {@@ -135,7 +135,7 @@ mod tests {};let d = &g.device;let seeds = [0u32, 0x1234_5678, hash_hp(99)];- let src = format!("{}\noverride APPROX: u32 = 0u;\nconst A_WHITE_NOISE: u32 = 64u;\nfn approx(a: u32) -> bool {{ return (APPROX & a) != 0u; }}\nvar<private> cur_depth: u32;\n@group(0) @binding(0) var<storage, read_write> out: array<u32>;\nconst SEEDS = array<u32, 3>({}u, {}u, {}u);\n@compute @workgroup_size(64) fn main(@builtin(global_invocation_id) id: vec3<u32>) {{\n let i = id.x;\n RNG_SEED = SEEDS[i % 3u];\n RNG_INDEX = i;\n let r = rng4(7u + i % 5u);\n for (var k = 0u; k < 4u; k++) {{ out[i * 4u + k] = bitcast<u32>(r[k]); }}\n}}\n", include_str!("../shaders/sample.wgsl"), seeds[0], seeds[1], seeds[2]);+ let src = format!("{}\noverride LIVE: bool = false;\nvar<private> cur_depth: u32;\n@group(0) @binding(0) var<storage, read_write> out: array<u32>;\nconst SEEDS = array<u32, 3>({}u, {}u, {}u);\n@compute @workgroup_size(64) fn main(@builtin(global_invocation_id) id: vec3<u32>) {{\n let i = id.x;\n RNG_SEED = SEEDS[i % 3u];\n RNG_INDEX = i;\n let r = rng4(7u + i % 5u);\n for (var k = 0u; k < 4u; k++) {{ out[i * 4u + k] = bitcast<u32>(r[k]); }}\n}}\n", include_str!("../shaders/sample.wgsl"), seeds[0], seeds[1], seeds[2]);let module = d.create_shader_module(wgpu::ShaderModuleDescriptor { label: None, source: wgpu::ShaderSource::Wgsl(src.into()) });let pipeline = d.create_compute_pipeline(&wgpu::ComputePipelineDescriptor { label: None, layout: None, module: &module, entry_point: Some("main"), compilation_options: Default::default(), cache: None });let n = 256u32;diff --git a/tests/render/lib.ts b/tests/render/lib.tsindex f6d34eb..544b64f 100644--- a/tests/render/lib.ts+++ b/tests/render/lib.ts@@ -24,6 +24,8 @@ export interface TestMeta {spp?: number;/** Render with the real-time renderer for this many frames (radiance cache, temporal passes) instead. */live?: number;+ /** A live test's approximations (`APPROX` bits; default all of them: the live view as it ships). */+ approx?: number;/** Scene time, s (animated materials; default 0). */time?: number;/** Asset files the test needs (unsupported when missing). */@@ -32,6 +34,17 @@ export interface TestMeta {note?: string;}+/** The live renderer's approximations (renderer/src/gpu.rs `A_*`; docs/RUNTIME.md "How live differs from offline"):+ * a live test without one of them is held to what the offline renderer gives. */+export const APPROX = {+ glassShadows: 1,+ mediaShadows: 2,+ cutoutPaths: 4,+ cutoutEmitters: 8,+ farEmitters: 16,+ all: 31,+};+export const SIZE = { width: 160, height: 90 };/** A pure Lambert surface (no specular lobe): radiance = albedo x irradiance / pi. */diff --git a/tests/render/light-emitter-far-live-exact.ts b/tests/render/light-emitter-far-live-exact.tsnew file mode 100644index 0000000..f224851--- /dev/null+++ b/tests/render/light-emitter-far-live-exact.ts@@ -0,0 +1,8 @@+// light/emitter-far in the real-time renderer without `APPROX.farEmitters` (as it ships, the light tree proposes no+// emitter beyond 120 m, and what a path finds of them by chance the clamps cut): the offline value.+import def, { test as base } from "./light-emitter-far.ts";+import { APPROX, type TestMeta } from "./lib.ts";++export const test: TestMeta = { ...base, id: "light/emitter-far-live-exact", metric: { ...base.metric, tolerance: 0.03 }, temporal: true, live: 120, approx: APPROX.all & ~APPROX.farEmitters };++export default def;diff --git a/tests/render/light-emitter-far.ts b/tests/render/light-emitter-far.tsnew file mode 100644index 0000000..ad4f28b--- /dev/null+++ b/tests/render/light-emitter-far.ts@@ -0,0 +1,32 @@+// Emitters far from what they light: 144 emissive panels (1 m, 10,000 nits; 288 triangles: a light tree) in a 12 x 12+// grid 150 m above an albedo-0.5 Lambert plane, facing it. Each gives the centre L A cos^2 / d^2 (cos = H / d), so+// the plane shows 0.5 / pi x their sum. From there the panels are 0.0064 sr of the hemisphere: a path that is not sent+// to them finds them once in 500 tries.+import { Color, Mesh, MeshStandardMaterial, PlaneGeometry } from "@threert/scene";+import { CENTER, camera, lambert, plane, result, sceneWithSky, type TestMeta } from "./lib.ts";++const [N, STEP, H, SIDE, NITS] = [12, 2, 150, 1, 10000];+const at = (k: number) => (k - (N - 1) / 2) * STEP;+const cells = Array.from({ length: N * N }, (_, k) => [at(k % N), at(Math.floor(k / N))]);+const sum = cells.reduce((s, [x, z]) => s + (H * H) / (x * x + z * z + H * H) ** 2, 0);++export const test: TestMeta = {+ id: "light/emitter-far", features: ["emissive", "light-tree", "lambert"], reference: "analytic", temporal: false,+ metric: { kind: "radiance", region: CENTER, expected: (0.5 / Math.PI) * NITS * SIDE * SIDE * sum, tolerance: 0.02 },+ spp: 256,+ note: "144 emissive panels 150 m over a Lambert plane: their sum at the centre",+};++export default function () {+ const scene = sceneWithSky(0);+ const glow = new MeshStandardMaterial({ name: "glow", color: new Color(0, 0, 0), emissive: new Color(1, 1, 1), emissiveIntensity: NITS, roughness: 1 });+ const geometry = new PlaneGeometry(SIDE, SIDE);+ const panels = cells.map(([x, z], k) => {+ const m = new Mesh(geometry, glow);+ m.name = `panel-${k}`;+ m.rotation.x = Math.PI / 2;+ m.position.set(x, H, z);+ return m;+ });+ return result(scene, camera(scene, [0, 0.5, 0.001], [0, 0, 0], 40), [plane(400, lambert(0.5, "floor"), "floor"), ...panels]);+}diff --git a/tests/render/shadow-cutout-blocker-live.ts b/tests/render/shadow-cutout-blocker-live.tsnew file mode 100644index 0000000..477b946--- /dev/null+++ b/tests/render/shadow-cutout-blocker-live.ts@@ -0,0 +1,7 @@+// shadow/cutout-blocker in the real-time renderer: the same ordered queries.+import def, { test as base } from "./shadow-cutout-blocker.ts";+import type { TestMeta } from "./lib.ts";++export const test: TestMeta = { ...base, id: "shadow/cutout-blocker-live", temporal: true, live: 120 };++export default def;diff --git a/tests/render/shadow-cutout-blocker.ts b/tests/render/shadow-cutout-blocker.tsnew file mode 100644index 0000000..1a676df--- /dev/null+++ b/tests/render/shadow-cutout-blocker.ts@@ -0,0 +1,26 @@+// A shadow ray that passes a cutout and then meets an opaque caster: a point light 3 m above an albedo-0.5 Lambert+// plane, a black 0.3 m slab at 2 m, and under it a card that is cut out everywhere. The slab's shadow (0.9 m wide on+// the plane) stays black: its middle against the lit plane 1.1 m to the side reads 0.+import { BoxGeometry, Mesh, PointLight } from "@threert/scene";+import { clearCard } from "./shadow-cutout-emitter.ts";+import { camera, lambert, plane, result, sceneWithSky, type TestMeta } from "./lib.ts";++export const test: TestMeta = {+ id: "shadow/cutout-blocker", features: ["point-light", "alpha-test", "shadows"], reference: "analytic", temporal: false,+ metric: { kind: "ratio", a: [0.48, 0.48, 0.52, 0.52], b: [0.86, 0.48, 0.9, 0.52], expected: 0, tolerance: 0.01 },+ note: "a shadow ray that a cutout lets through goes on in order (trace_hw.wgsl) and stops at the slab",+};++export default function () {+ const scene = sceneWithSky(0);+ const l = new PointLight(0xffffff, 1000, 0);+ l.radius = 0.001;+ l.position.set(0, 3, 0);+ const slab = new Mesh(new BoxGeometry(0.3, 0.05, 0.3), lambert(0, "slab"));+ slab.name = "slab";+ slab.position.set(0, 2, 0);+ const card = clearCard(12, 12);+ card.rotation.x = -Math.PI / 2;+ card.position.set(0, 1, 0);+ return result(scene, camera(scene, [0, 0.6, 3], [0, 0, 0]), [l, slab, card, plane(20, lambert(0.5))]);+}diff --git a/tests/render/shadow-cutout-emitter-live-exact.ts b/tests/render/shadow-cutout-emitter-live-exact.tsnew file mode 100644index 0000000..5188192--- /dev/null+++ b/tests/render/shadow-cutout-emitter-live-exact.ts@@ -0,0 +1,13 @@+// shadow/cutout-emitter in the real-time renderer without `APPROX.cutoutEmitters` and `APPROX.cutoutPaths`: the+// offline value. Both, because an emitter's light comes by two kinds of ray that share it (MIS): its shadow rays,+// and the rays a surface sends on. As it ships the live view takes the card as opaque for both and the plane is+// black (0.0004); without the first alone it reads 31 %.+import def, { test as base } from "./shadow-cutout-emitter.ts";+import { APPROX, type TestMeta } from "./lib.ts";++export const test: TestMeta = {+ ...base, id: "shadow/cutout-emitter-live-exact", metric: { ...base.metric, tolerance: 0.03 }, temporal: true, live: 120,+ approx: APPROX.all & ~APPROX.cutoutEmitters & ~APPROX.cutoutPaths,+};++export default def;diff --git a/tests/render/shadow-cutout-emitter.ts b/tests/render/shadow-cutout-emitter.tsnew file mode 100644index 0000000..42b3335--- /dev/null+++ b/tests/render/shadow-cutout-emitter.ts@@ -0,0 +1,35 @@+// An emitter's light past an alpha-tested card: a 10 x 10 m emissive panel (10 nits) 2 m above an albedo-0.5 Lambert+// plane, and between them a card whose texture is transparent everywhere (alpha 0, alphaTest 0.5): it blocks nothing.+// Under the panel's centre the plane reads 0.5 / pi x L x 4 s atan(s), s = a / sqrt(a^2 + h^2) (a = 5, h = 2).+import { Color, DataTexture, Mesh, MeshStandardMaterial, PlaneGeometry } from "@threert/scene";+import { camera, lambert, plane, result, sceneWithSky, type TestMeta } from "./lib.ts";++const [A, H, NITS] = [5, 2, 10];+const S = A / Math.hypot(A, H);++/** A two-sided card that is cut out everywhere. */+export function clearCard(width: number, height: number): Mesh {+ const texture = new DataTexture(2, 2, new Uint8Array([255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0]));+ const m = new Mesh(new PlaneGeometry(width, height), new MeshStandardMaterial({ name: "card", color: 0xffffff, map: texture, alphaTest: 0.5, roughness: 1, side: "double" }));+ m.name = "card";+ return m;+}++export const test: TestMeta = {+ id: "shadow/cutout-emitter", features: ["emissive", "alpha-test", "shadows"], reference: "analytic", temporal: false,+ metric: { kind: "radiance", region: [0.48, 0.48, 0.52, 0.52], expected: (0.5 / Math.PI) * NITS * 4 * S * Math.atan(S), tolerance: 0.02 },+ spp: 256,+ note: "the card 12 x 12 m at y = 1, the camera at y = 0.6 under it",+};++export default function () {+ const scene = sceneWithSky(0);+ const panel = new Mesh(new PlaneGeometry(2 * A, 2 * A), new MeshStandardMaterial({ name: "panel", color: new Color(0, 0, 0), emissive: new Color(1, 1, 1), emissiveIntensity: NITS, roughness: 1 }));+ panel.name = "panel";+ panel.rotation.x = Math.PI / 2;+ panel.position.set(0, H, 0);+ const card = clearCard(12, 12);+ card.rotation.x = -Math.PI / 2;+ card.position.set(0, 1, 0);+ return result(scene, camera(scene, [0, 0.6, 3], [0, 0, 0]), [panel, card, plane(20, lambert(0.5))]);+}diff --git a/tests/render/shadow-glass-tint-live-exact.ts b/tests/render/shadow-glass-tint-live-exact.tsnew file mode 100644index 0000000..928f54c--- /dev/null+++ b/tests/render/shadow-glass-tint-live-exact.ts@@ -0,0 +1,9 @@+// shadow/glass-tint in the real-time renderer without `APPROX.glassShadows`: the offline value. (5 %: it reads 3 %+// low. The glass passes a shadow ray or stops it by one random decision, 23 % here, and the live clamps darken a+// signal that noisy; carried as a weight it would not be.)+import def, { test as base } from "./shadow-glass-tint.ts";+import { APPROX, type TestMeta } from "./lib.ts";++export const test: TestMeta = { ...base, id: "shadow/glass-tint-live-exact", metric: { ...base.metric, tolerance: 0.05 }, temporal: true, live: 120, approx: APPROX.all & ~APPROX.glassShadows };++export default def;diff --git a/tests/render/shadow-glass-tint-live.ts b/tests/render/shadow-glass-tint-live.tsnew file mode 100644index 0000000..848e320--- /dev/null+++ b/tests/render/shadow-glass-tint-live.ts@@ -0,0 +1,11 @@+// shadow/glass-tint in the real-time renderer as it ships: its shadow rays pass glass in full (`APPROX.glassShadows`),+// so the plane under the pane reads what it would without the pane, 4.3 x the offline value.+import def, { CLEAR, test as base } from "./shadow-glass-tint.ts";+import type { TestMeta } from "./lib.ts";++export const test: TestMeta = {+ ...base, id: "shadow/glass-tint-live", metric: { ...base.metric, expected: CLEAR, tolerance: 0.03 }, temporal: true, live: 120,+ note: "the live approximation's value: the light unattenuated",+};++export default def;diff --git a/tests/render/shadow-glass-tint.ts b/tests/render/shadow-glass-tint.tsnew file mode 100644index 0000000..07ce100--- /dev/null+++ b/tests/render/shadow-glass-tint.ts@@ -0,0 +1,27 @@+// A shadow ray through tinted glass: a point light (1000 cd) 2 m above an albedo-0.5 Lambert plane, a grey glass pane+// (colour 0.5, ior 1.5, 5 cm) half way. Each of the pane's two surfaces keeps the transmission lobe's share+// (1 - 0.04 at normal incidence) times the colour: the plane under it reads 0.5 I / 4 / pi x (0.96 x 0.5)^2.+// The camera looks at the patch from beside the pane, not through it.+import { BoxGeometry, Color, Mesh, MeshPhysicalMaterial, PointLight } from "@threert/scene";+import { camera, lambert, plane, result, sceneWithSky, type TestMeta } from "./lib.ts";++export const CLEAR = (0.5 * 1000) / 4 / Math.PI;+export const THROUGH = CLEAR * (0.96 * 0.5) ** 2;++export const test: TestMeta = {+ id: "shadow/glass-tint", features: ["point-light", "transmission", "shadows"], reference: "analytic", temporal: false,+ metric: { kind: "radiance", region: [0.48, 0.48, 0.52, 0.52], expected: THROUGH, tolerance: 0.02 },+ spp: 256,+ note: "pane 1 x 1 m at y = 1 under a light at y = 2; the camera's ray to the patch passes the pane's edge at z = 1",+};++export default function () {+ const scene = sceneWithSky(0);+ const l = new PointLight(0xffffff, 1000, 0);+ l.radius = 0.001;+ l.position.set(0, 2, 0);+ const pane = new Mesh(new BoxGeometry(1, 0.05, 1), new MeshPhysicalMaterial({ name: "pane", color: new Color().setRGB(0.5, 0.5, 0.5), transmission: 1, ior: 1.5, roughness: 0, metalness: 0 }));+ pane.name = "pane";+ pane.position.set(0, 1, 0);+ return result(scene, camera(scene, [0, 0.6, 3], [0, 0, 0]), [l, pane, plane(20, lambert(0.5))]);+}diff --git a/tests/render/shadow-medium-live-exact.ts b/tests/render/shadow-medium-live-exact.tsnew file mode 100644index 0000000..bee622a--- /dev/null+++ b/tests/render/shadow-medium-live-exact.ts@@ -0,0 +1,7 @@+// shadow/medium in the real-time renderer without `APPROX.mediaShadows`: the offline value.+import def, { test as base } from "./shadow-medium.ts";+import { APPROX, type TestMeta } from "./lib.ts";++export const test: TestMeta = { ...base, id: "shadow/medium-live-exact", metric: { ...base.metric, tolerance: 0.03 }, temporal: true, live: 120, approx: APPROX.all & ~APPROX.mediaShadows };++export default def;diff --git a/tests/render/shadow-medium-live.ts b/tests/render/shadow-medium-live.tsnew file mode 100644index 0000000..1017ee0--- /dev/null+++ b/tests/render/shadow-medium-live.ts@@ -0,0 +1,11 @@+// shadow/medium in the real-time renderer as it ships: only homogeneous media dim its shadow rays+// (`APPROX.mediaShadows`), so the plane under the box reads what it would without the box, e x the offline value.+import def, { CLEAR, test as base } from "./shadow-medium.ts";+import type { TestMeta } from "./lib.ts";++export const test: TestMeta = {+ ...base, id: "shadow/medium-live", metric: { ...base.metric, expected: CLEAR, tolerance: 0.03 }, temporal: true, live: 120,+ note: "the live approximation's value: the light unattenuated",+};++export default def;diff --git a/tests/render/shadow-medium.ts b/tests/render/shadow-medium.tsnew file mode 100644index 0000000..ad4a67f--- /dev/null+++ b/tests/render/shadow-medium.ts@@ -0,0 +1,26 @@+// A shadow ray through a medium that is not homogeneous to the renderer (a volume function): a point light (1000 cd)+// 3 m above an albedo-0.5 Lambert plane, a 1 m thick absorber (extinction 1 / m) between them. The plane under it+// reads 0.5 I / 9 / pi x e^-1. The camera looks at the patch from under the box.+import { PointLight, VolumeMesh } from "@threert/scene";+import { UNIFORM } from "./volume-box-transmittance.ts";+import { camera, lambert, plane, result, sceneWithSky, type TestMeta } from "./lib.ts";++export const CLEAR = (0.5 * 1000) / 9 / Math.PI;++export const test: TestMeta = {+ id: "shadow/medium", features: ["point-light", "volume", "shadows"], reference: "analytic", temporal: false,+ metric: { kind: "radiance", region: [0.48, 0.48, 0.52, 0.52], expected: CLEAR * Math.exp(-1), tolerance: 0.02 },+ spp: 256,+ note: "box 2 x 1 x 2 m, y from 1 to 2, under a light at y = 3; the camera at y = 0.6",+};++export default function () {+ const scene = sceneWithSky(0);+ const l = new PointLight(0xffffff, 1000, 0);+ l.radius = 0.001;+ l.position.set(0, 3, 0);+ const box = new VolumeMesh({ volume: UNIFORM.with({ Density: 1 }), majorant: 1 });+ box.scale.set(2, 1, 2);+ box.position.set(0, 1.5, 0);+ return result(scene, camera(scene, [0, 0.6, 3], [0, 0, 0]), [l, box, plane(20, lambert(0.5))]);+}diff --git a/tests/render/sky-cutout-clear-live-exact.ts b/tests/render/sky-cutout-clear-live-exact.tsnew file mode 100644index 0000000..ed1c270--- /dev/null+++ b/tests/render/sky-cutout-clear-live-exact.ts@@ -0,0 +1,8 @@+// sky/cutout-clear in the real-time renderer without `APPROX.cutoutPaths` (as it ships, the rays a surface sends on+// take the card as opaque, and their share of the sky is lost): the offline value.+import def, { test as base } from "./sky-cutout-clear.ts";+import { APPROX, type TestMeta } from "./lib.ts";++export const test: TestMeta = { ...base, id: "sky/cutout-clear-live-exact", metric: { ...base.metric, tolerance: 0.03 }, temporal: true, live: 120, approx: APPROX.all & ~APPROX.cutoutPaths };++export default def;diff --git a/tests/render/sky-cutout-clear.ts b/tests/render/sky-cutout-clear.tsnew file mode 100644index 0000000..b64ea9e--- /dev/null+++ b/tests/render/sky-cutout-clear.ts@@ -0,0 +1,19 @@+// The sky's light past an alpha-tested card: an albedo-0.5 Lambert plane under a uniform 100-nit sky reads 50, and a+// card over it that is cut out everywhere changes nothing. The sky's light comes by two kinds of ray that share it+// (MIS): the sky's own samples, and the rays the plane sends on.+import { clearCard } from "./shadow-cutout-emitter.ts";+import { camera, lambert, plane, result, sceneWithSky, type TestMeta } from "./lib.ts";++export const test: TestMeta = {+ id: "sky/cutout-clear", features: ["sky", "alpha-test", "lambert"], reference: "analytic", temporal: false,+ metric: { kind: "radiance", region: [0.48, 0.48, 0.52, 0.52], expected: 50, tolerance: 0.02 },+ note: "the card 400 x 400 m at y = 1, the camera at y = 0.6 under it",+};++export default function () {+ const scene = sceneWithSky(100);+ const card = clearCard(400, 400);+ card.rotation.x = -Math.PI / 2;+ card.position.set(0, 1, 0);+ return result(scene, camera(scene, [0, 0.6, 3], [0, 0, 0]), [card, plane(400, lambert(0.5))]);+}diff --git a/tools/test-render.ts b/tools/test-render.tsindex 354562e..bf7b64c 100644--- a/tools/test-render.ts+++ b/tools/test-render.ts@@ -65,7 +65,7 @@ for (const { file, meta } of tests) {const name = file.replace(/\.ts$/, "");const bundle = (await bundleGame(join(dir, file), join(out, `${name}.js`))).out;const hdr = join(out, `${name}.raw`);- proc.stdin!.write(JSON.stringify({ id: ++id, game: bundle, assets, out: join(out, `${name}.png`), hdr, spp: meta.spp ?? 64, denoise: false, live: meta.live, time: meta.time }) + "\n");+ proc.stdin!.write(JSON.stringify({ id: ++id, game: bundle, assets, out: join(out, `${name}.png`), hdr, spp: meta.spp ?? 64, denoise: false, live: meta.live, approx: meta.approx, time: meta.time }) + "\n");const reply = JSON.parse((await lines.next()).value as string);const ms = performance.now() - t;if (!reply.ok) {