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
Radiance cache: held to numbers; five faults (#98)
Yujia1a25d1fc240c
diff --git a/docs/ROADMAP.md b/docs/ROADMAP.mdindex dc6474a..bb861cf 100644--- a/docs/ROADMAP.md+++ b/docs/ROADMAP.md@@ -2449,6 +2449,40 @@ with the decision: its tolerance 5 % -> 3 %). render-identity changes the eighttinting glass or media, in noise; bench-window's shots as main's (Kabukichō's flicker 0.68-0.72 over three seeds inboth builds). The cost of exact glass shadows is the walk over the glass, which this leaves as it is.+**The radiance cache held to numbers (2026-11-16, after it).** A live test of one bounce off a lit floor read+0.21 for 0.25: the first number anyone had asked of the cache. Read against how the other caches of its kind are+built (SHaRC, GI-1.0, Lumen, NRC), five faults:++- A lookup that found no voxel read black past a view's first 30 frames (a shortcut, taken for speed, that was in+ no list): 16 % of that bounce at 160 x 90, 2 % at 1280 x 720, 0.2 % of a Bistro frame. Every training sample is+ now added two and four levels coarser as well, and a cold lookup reads those; with none it traces, always. The+ shortcut is gone: with the coarser levels it cost time (Bistro 9.05 ms with it, 8.87 without).+- A floor on a face of the voxel grid (y = 0) had its hits rounded to either side, two keys sharing its samples:+ the key is taken just in front of the surface.+- Where a path ended on a cold voxel its light samples kept their MIS share alone, 18 % of a uniform sky: they+ stand alone there (`nee_alone`). A view's first frame read 4.0 for 7.05.+- The lookup's reflectance had no coat: a surface that reflects by its coat alone reflected nothing.+- A surface seen in a reflection took the sky's samples afresh against the white-lobe ones the cache had left+ out, which do not add up on a glossy surface (a white metal ground in a mirror: 0.80 of a uniform sky, now 1.00).+ The sky's light there is the cache's.++Measured and not taken: ending a path in the cache only past a segment of a voxel or so, as the others do. It makes+a slit narrower than a voxel right (`cache/slit-live`: 14 % bright without) and cost Bistro's trace 15 to 22 %:+the pixels that go on hold their SIMD groups. Tracing an absent voxel and inserting it: 7 %, for what the coarser+levels do for 1. A table four times the size: what the trace gains (0.13 ms) the cache's own pass spends. Taking a+reflection hit's lights as light samples alone, which is the estimator without a bias: fireflies on Kabukichō's+wet street (flicker + 22 %); they keep their weights.++Against main: the trace Bistro 8.50 / 8.55 ms held still and 4.48 / 4.58 along its camera path, lamp-rooms 3.69 /+3.75, the fire scene 1.88 / 1.92; guarded, Kabukichō 16.53 / 16.22 and Tokyo 5.85 / 5.50 by day, 4.79 / 4.74 at+night (a surface in a reflection sends the sky no shadow ray). bench-window: Bistro ΔE 1.82 -> 1.81, lamp-rooms+0.63 / p99 1.99 -> 0.63 / 1.85, in motion 0.80 -> 0.74, settled after a turn 0.67 -> 0.73 (the one shot that is+worse: 0.6 % more light where it was 1.3 % bright already); Kabukichō, Tokyo at night and at 14:00 as main's.+render-identity: the live tests that read the cache change, offline ones by a float's last place at most (the+sky's light sample became a function). Next for the cache: its training as a pass of its own, as SHaRC's is+(training that does not thin out with the resolution, deeper paths, a smaller kernel), and with it the table's+size; a pass for the few pixels that go on, which is what the segment test waits for.+## 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 aa1f106..3862b87 100644--- a/docs/RUNTIME.md+++ b/docs/RUNTIME.md@@ -1371,6 +1371,19 @@ cache's voxels, and later segments meet homogeneous media alone; depth of fieldparticles are lit from the cache's voxels; past a camera hit's own decisions the sampler is a hash, not Sobol(variance only).+The radiance cache is held to numbers by the `cache/*` tests (a bounce off a lit floor, the same off a coated one+and with the floor on a voxel face, two bounces in a view's first frame, a lit ground seen in a mirror, a furnace+box, a corner): within 2 % of the offline or analytic value. A lookup whose voxel has too few samples reads the+levels beside it, then the ones two and four levels coarser, which every training sample is added to as well; with+none of them it traces its light there. Two limits are known and held by tests so that they are seen to move:++- `cache/slit-live`: light in a gap narrower than a voxel reads 14 % bright. A path ends in the cache however short+ its last segment; other caches of this kind go on tracing below about a voxel and a half (SHaRC), which is right+ here and cost Bistro's trace 15 to 22 % in this kernel.+- The cache holds no directions: it takes a mirror for a diffuse reflector of what falls on it (the ground before a+ sunlit mirror wall 5 % bright), and a surface seen in a reflection takes the sky's light from it, unshadowed+ below a voxel's size.+## What the kernel trustsThe kernel follows indices it reads from buffers and loops over counts it is given; it checks none of them (adiff --git a/renderer/shaders/pathtrace.wgsl b/renderer/shaders/pathtrace.wgslindex 47835bd..36ef9fb 100644--- a/renderer/shaders/pathtrace.wgsl+++ b/renderer/shaders/pathtrace.wgsl@@ -1145,6 +1145,15 @@ const MIRROR_ROUGHNESS: f32 = 0.3;// Whether a cutout let the last shadow ray through (the shadow rays' functions clear it, `trace` sets it).var<private> shadow_hole: bool = false;+// Set around a `direct_light` that no BSDF ray follows (where a path ends without the cache): its light samples+// take the whole of their light. Weighed against a BSDF ray that is never traced they kept their MIS share alone:+// of a uniform sky on a Lambert surface, ln 17 / 16 = 18 %.+var<private> nee_alone: bool = false;++// `direct_light` without the sky: a surface seen in a reflection lights itself from the lights, the sky's light+// there is the radiance cache's.+var<private> lights_only: bool = false;+// Alpha-cutout test for candidate hits on masked triangles (mesh UVs, footprint of a camera ray at distance t). `inst`:// the model instance a pool triangle belongs to (its scale shifts the texel density, as in `inst_attr`), or NO_INST.fn alpha_pass(ti: u32, inst: u32, u: f32, v: f32, t: f32) -> bool {@@ -1467,6 +1476,7 @@ fn pdf_bsdf(s: Surface, lb: Lobes, v: vec3<f32>, l: vec3<f32>) -> f32 {// (Until 2026-11-15 the weight was the plain heuristic: under a card cut out everywhere a uniform sky lit a Lambert// plane with 18 % of its light.)fn light_mis(pdf_l: f32, s: Surface, lb: Lobes, v: vec3<f32>, l: vec3<f32>) -> f32 {+ if (nee_alone) { return 1.0; }let pb = pdf_bsdf(s, lb, v, l);let w = power_heuristic(pdf_l, pb);if (!approx(A_CUTOUT_PATHS) || !has(F_MASKED) || !shadow_hole) { return w; }@@ -1630,14 +1640,18 @@ fn sky_mis(d: vec3<f32>, pdf: f32) -> vec3<f32> {}var c = env_radiance(d) * wgt;if (has(F_AERIAL) && pdf <= 0.0) { c = aerial_light(d); }- // BSDF rays that fall inside a directional light's cone see its disk (MIS vs cone sampling).- if (pdf > 0.0) {- for (var i = 0u; i < P.counts2.x; i++) {- let li = light_at(i);- if (dot(d, -li.dir.xyz) >= li.dir.w) {- let omega = 2.0 * PI * (1.0 - li.dir.w);- c += (li.color.rgb / omega) * power_heuristic(pdf, 1.0 / omega);- }+ if (pdf > 0.0) { c += sun_disks(d, pdf); }+ return c;+}++// The directional lights' disks a BSDF ray (pdf `pdf`) falls in, MIS-weighted against their cones' sampling.+fn sun_disks(d: vec3<f32>, pdf: f32) -> vec3<f32> {+ var c = vec3<f32>(0.0);+ for (var i = 0u; i < P.counts2.x; i++) {+ let li = light_at(i);+ if (dot(d, -li.dir.xyz) >= li.dir.w) {+ let omega = 2.0 * PI * (1.0 - li.dir.w);+ c += (li.color.rgb / omega) * power_heuristic(pdf, 1.0 / omega);}}return c;@@ -2097,6 +2111,23 @@ fn hg_phase(g: f32, c: f32) -> f32 {return sum;}+// Whether the sky is light-sampled.+fn env_sampled() -> bool { return P.counts2.y != 0u && (P.env.x > 0.5 || luminance(P.sky_color.rgb) > 0.0); }++// The sky's light sample at a surface (`o`: its shadow rays' origin): one direction by the map, MIS against the BSDF.+fn env_light(s: Surface, lb: Lobes, v: vec3<f32>, o: vec3<f32>) -> vec3<f32> {+ let l = sample_env(rng_dim(D_ENV));+ let f = eval_bsdf(s, lb, v, l);+ if (any(f > vec3<f32>(0.0))) {+ let pdf_e = env_pdf(l);+ if (pdf_e > 0.0) {+ let vis = sky_tr(o, l, rng_dim(D_ENV_VIS));+ if (any(vis > vec3<f32>(0.0))) { return env_radiance(l) * f * light_mis(pdf_e, s, lb, v, l) / pdf_e * tr3(vis); }+ }+ }+ return vec3<f32>(0.0);+}+fn direct_light(s: Surface, lb: Lobes, v: vec3<f32>) -> vec3<f32> {var sum = vec3<f32>(0.0);dl_spec = vec3<f32>(0.0);@@ -2176,23 +2207,13 @@ fn direct_light(s: Surface, lb: Lobes, v: vec3<f32>) -> vec3<f32> {}}// Environment- var env_on = P.counts2.y != 0u && (P.env.x > 0.5 || luminance(P.sky_color.rgb) > 0.0);- @if(light_pick) env_on = take_env && has_env;+ var env_on = env_sampled() && !lights_only;+ @if(light_pick) env_on = take_env && has_env && !lights_only;if (env_on) {- let l = sample_env(rng_dim(D_ENV));- let f = eval_bsdf(s, lb, v, l);- if (any(f > vec3<f32>(0.0))) {- let pdf_e = env_pdf(l);- if (pdf_e > 0.0) {- let vis = sky_tr(o, l, rng_dim(D_ENV_VIS));- if (any(vis > vec3<f32>(0.0))) {- let frac = split_frac;- let wgt = light_mis(pdf_e, s, lb, v, l);- sum += env_radiance(l) * f * wgt / pdf_e * tr3(vis);- dl_spec += env_radiance(l) * f * wgt / pdf_e * tr3(vis) * frac;- }- }- }+ // (`split_frac` is the sky sample's where its BSDF was not 0; where it was, e is 0.)+ let e = env_light(s, lb, v, o);+ sum += e;+ dl_spec += e * split_frac;}@if(light_pick) if (pick_w > 1.0) {sum = sum_sun + (sum - sum_sun) * pick_w;@@ -2813,7 +2834,11 @@ fn sphere_hit(x: vec3<f32>, l: vec3<f32>, hit: Hit) -> vec3<f32> {if (s.card) { return e; }let c = cache_get(s, false);var irr = c.rgb;- if (!cache_on() || c.w < CACHE_WARM) { irr = direct_light(s, white_lobes(), -l); }+ if (!cache_on() || c.w < CACHE_WARM) {+ nee_alone = true;+ irr = direct_light(s, white_lobes(), -l);+ nee_alone = false;+ }return e + cache_reflectance(lobes(s, max(dot(s.n, -l), 1e-4))) * irr;}@@ -2937,6 +2962,7 @@ const CACHE_SIZE: u32 = 262144u; // entries, a power of two (gpu.rs CACHE_SIconst CACHE_PROBE: u32 = 8u; // linear probing windowconst CACHE_ANGLE: f32 = 0.02; // voxel size / distance to the cameraconst CACHE_MIN_VOXEL: f32 = 0.0625; // m+const CACHE_FACE: f32 = 0.0625; // a surface's key is taken this far (in voxels) in front of itconst CACHE_WARM: f32 = 4.0; // samples before lookups trust an entryconst CACHE_TRAIN_MASK: u32 = 7u; // 1 in 8 tiles of 8x4 pixels (one SIMD group: the others really skip) per frameconst CACHE_FRAME_CAP: u32 = 255u; // samples per entry per frame (fixed-point headroom)@@ -2946,7 +2972,8 @@ const CACHE_EVICT: f32 = 120.0; // frames without samples before an entry i// cache_keys[i]: checksum of the voxel key (0 = free). cache_acc[8i ..]: this frame's sums (fixed point) of the total// r, g, b, of its indirect part r, g, b, and the sample count. cache_val[2i] = (irradiance / π, history samples),-// cache_val[2i + 1] = (its indirect part: all but the voxel's own direct light, frames since the last sample).+// cache_val[2i + 1] = (its indirect part: all but the lights' samples there, the sky's light in it; frames since the+// last sample).// (Declared with the trace's outputs, group 1, above `resolve_bound`.)fn cache_on() -> bool { return LIVE && P.cache.x > 0.5; }@@ -2956,10 +2983,12 @@ fn cache_key(p: vec3<f32>, ng: vec3<f32>) -> vec2<u32> {return cache_key_at(p, ng, 0.0);}-// The key `step` levels coarser (negative: finer) than p's own.+// The key `step` levels coarser (negative: finer) than p's own. The voxel is the one just in front of the surface+// (CACHE_FACE): a floor at y = 0 lies on a face of every level's voxels, and the rounding of its hits put them on+// either side, two keys sharing its samples (a floor's bounce 16 % dark at 160 x 90 for 11 % a little higher up).fn cache_key_at(p: vec3<f32>, ng: vec3<f32>, step: f32) -> vec2<u32> {let lvl = floor(log2(max(length(p - P.cam_pos.xyz) * CACHE_ANGLE, CACHE_MIN_VOXEL))) + step;- let q = bitcast<vec3<u32>>(vec3<i32>(floor(p * exp2(-lvl))));+ let q = bitcast<vec3<u32>>(vec3<i32>(floor(p * exp2(-lvl) + ng * CACHE_FACE)));let a = abs(ng);let axis = select(select(2u, 1u, a.y >= a.z), 0u, a.x >= a.y && a.x >= a.z);let neg = select(select(ng.z, ng.y, axis == 1u), ng.x, axis == 0u) < 0.0;@@ -2996,6 +3025,18 @@ fn cache_get(s: Surface, indirect: bool) -> vec4<f32> {let e = cache_entry(cache_key_at(s.p, s.ng, select(-1.0, 1.0, k == 0u)), indirect);if (e.w > best.w) { best = e; }}+ // Still cold: the coarser levels every training sample is added to beside its own (`cache_train`). A voxel with+ // 16 or 256 times the area is seldom without samples where the own one is: far from the camera's paths, at low+ // resolutions. (Without them such a lookup read black past a view's first frames: a floor's bounce 11 % dark+ // at 160 x 90; SHaRC goes on tracing there, GI-1.0 reads a coarser mip.)+ if (best.w < CACHE_WARM) {+ let e = cache_entry(cache_key_at(s.p, s.ng, 2.0), indirect);+ if (e.w > best.w) { best = e; }+ }+ if (best.w < CACHE_WARM) {+ let e = cache_entry(cache_key_at(s.p, s.ng, 4.0), indirect);+ if (e.w > best.w) { best = e; }+ }return best;}@@ -3040,9 +3081,12 @@ fn white_lobes() -> Lobes {}// What a surface reflects of irradiance / π toward the viewer, the lighting taken as uniform over the hemisphere:-// diffuse + directional specular albedo.+// diffuse + directional specular albedo, under the coat's (as `eval_bsdf_k` layers them; without the coat's term a+// coated surface reflected e_coat (1 - the rest) too little).fn cache_reflectance(lb: Lobes) -> vec3<f32> {- return lb.diffuse * (1.0 - lb.e_spec) + lb.e_spec;+ let r = lb.diffuse * (1.0 - lb.e_spec) + lb.e_spec;+ if (has(F_COAT)) { return r * (1.0 - lb.e_coat) + lb.e_coat; }+ return r;}struct Fresh { total: vec3<f32>, direct: vec3<f32> };@@ -3053,6 +3097,7 @@ struct Fresh { total: vec3<f32>, direct: vec3<f32> };// cold pixel's fresh estimate).fn cache_train(s0: Surface, d0: vec3<f32>, cone0: vec2<f32>, depth: u32, insert: bool) -> Fresh {var slot: array<u32, CACHE_DEPTH>;+ var coarse: array<u32, 4>; // each vertex's voxels two and four levels coarser (4 and 16 times the size)// Per vertex: its direct light; that + the emission / sky its ray brought back; what the next vertex reflects.var direct: array<vec3<f32>, CACHE_DEPTH>;var gather: array<vec3<f32>, CACHE_DEPTH>;@@ -3068,8 +3113,14 @@ fn cache_train(s0: Surface, d0: vec3<f32>, cone0: vec2<f32>, depth: u32, insert:cur_depth = 2u + k;let v = -d;slot[k] = cache_find(cache_key(s.p, s.ng), insert);+ coarse[2u * k] = cache_find(cache_key_at(s.p, s.ng, 2.0), insert);+ coarse[2u * k + 1u] = cache_find(cache_key_at(s.p, s.ng, 4.0), insert);+ // `direct`: the lights' samples (not the sky's): what a surface seen in a reflection takes afresh.+ lights_only = true;var g = direct_light(s, wl, v);+ lights_only = false;direct[k] = g;+ if (env_sampled()) { g += env_light(s, wl, v, offset_origin(s.p, s.ng)); }refl[k] = vec3<f32>(0.0);gather[k] = g;n = k + 1u;@@ -3117,7 +3168,9 @@ fn cache_train(s0: Surface, d0: vec3<f32>, cone0: vec2<f32>, depth: u32, insert:if (c.w >= CACHE_WARM) {tail = c.rgb;} else {+ nee_alone = true;tail = direct_light(s2, wl, -l);+ nee_alone = false;}break;}@@ -3135,6 +3188,8 @@ fn cache_train(s0: Surface, d0: vec3<f32>, cone0: vec2<f32>, depth: u32, insert:let tcl = CACHE_TRAIN_CLAMP * P.misc.x;if (lum > tcl) { e *= tcl / lum; }cache_add(slot[j], e, max(e - direct[j], vec3<f32>(0.0)));+ cache_add(coarse[2 * j], e, max(e - direct[j], vec3<f32>(0.0)));+ cache_add(coarse[2 * j + 1], e, max(e - direct[j], vec3<f32>(0.0)));}return Fresh(e, min(direct[0], e));}@@ -3528,9 +3583,11 @@ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {// Live: the path ends in the radiance cache at its first bounce. Surfaces seen in mirror-like reflections// (specular lobe below roughness 0.4, where UE traces reflections) get direct light of their own, as UE's hit// lighting does, and the cache's indirect part; others reflect the cache's total. Rotating tiles train the- // cache. For the first frames after a reset or a camera cut (live/mod.rs COLD_FALLBACK_FRAMES; flag 1 later),- // pixels that find their voxel cold trace a fresh estimate and use it meanwhile, without inserting the voxel:- // the low-sample entries they inserted kept later frames slower until evicted (the crowd's square ~2 ms).+ // cache. A pixel that finds its voxel cold at every level (`cache_get`) traces a fresh estimate and uses it,+ // without inserting the voxel: the low-sample entries such pixels inserted kept later frames slower until+ // evicted (the crowd's square ~2 ms). (Until 2026-11-16 that held for a view's first 30 frames; later a cold+ // voxel was read as it was, black where there was none. With the coarser levels few lookups are cold, and+ // the rule's own test cost more than their traces: Bistro 9.05 ms with it, 8.87 without.)let cfl = u32(P.cache.w);if (cache_on() && depth >= 1u && !(has(F_GLASS) && s.transmission > 0.0)) {let v1 = -d;@@ -3538,7 +3595,6 @@ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {let hit_light = spec_lobe && rough0 < 0.4 && depth == 1u && (cfl & 2u) == 0u;var e = cache_get(s, hit_light);let train = (((gid.x >> 3u) + 3u * (gid.y >> 2u) + pcg(P.size.z)) & CACHE_TRAIN_MASK) == 0u && (cfl & 4u) == 0u;- if ((cfl & 1u) != 0u) { e.w = max(e.w, CACHE_WARM); }if (train || e.w < CACHE_WARM) {// Training tiles trace deep (coherent: whole SIMD groups); scattered cold pixels one vertex.let fresh = cache_train(s, d, vec2<f32>(width, cone_a), select(1u, CACHE_DEPTH, train), train);@@ -3549,7 +3605,16 @@ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {var c = thr * cache_reflectance(lb1) * e.rgb;// Resampled lights, not the exact loop camera hits get (that costs 2x here: mirror pixels are scattered).mirror_path = mirror_path && (cfl & 8u) != 0u;- if (hit_light) { c += thr * direct_light(s, lb1, v1); }+ // (The lights alone: the sky's light is in the cache's indirect part, whole. Its samples taken afresh+ // here against the white-lobe ones the cache left out do not add up on a glossy surface: a white metal+ // ground in a mirror read 0.80 of a uniform sky. The lights' still are: weights of two lobes, right for a+ // Lambert surface and for small lights; as light samples alone they were fireflies on Kabukichō's wet+ // street, flicker + 22 %.)+ if (hit_light) {+ lights_only = true;+ c += thr * direct_light(s, lb1, v1);+ lights_only = false;+ }let lum = luminance(c);if (lum > clamp_v && !straight) { c *= clamp_v / lum; }radiance += c;diff --git a/renderer/src/gpu.rs b/renderer/src/gpu.rsindex 5f6bc36..3fd93a6 100644--- a/renderer/src/gpu.rs+++ b/renderer/src/gpu.rs@@ -3617,7 +3617,7 @@ mod tests {let sun = v(hwrt, KernelSwitches { last_sun: true, ..Default::default() });assert_eq!((sun.matches("radiance += dz;").count(), sun.matches("fn sun_light(").count(), sun.matches("sun_light(s, lobes(").count()), (1, 1, 1));assert!(!plain.contains("sun_light"));- assert_eq!(lit.matches("env_on = take_env && has_env;").count(), 1);+ assert_eq!(lit.matches("env_on = take_env && has_env && !lights_only;").count(), 1);assert_eq!(lit.contains("let steps = 4u;"), hwrt);assert_eq!(v(hwrt, KernelSwitches { cutout_lite: 2, ..Default::default() }) == plain, !hwrt);}diff --git a/renderer/src/live/frame.rs b/renderer/src/live/frame.rsindex d702215..8f9e5a2 100644--- a/renderer/src/live/frame.rs+++ b/renderer/src/live/frame.rs@@ -262,7 +262,6 @@ impl LiveCore {self.update_light_lod();// A camera cut (a jump no camera makes in one frame: 2 m or 30 degrees) is not motion: no blur (UE: bCameraCut).let cut = (self.cam.pos - self.prev_cam.pos).length() > 2.0 || self.cam.fwd.dot(self.prev_cam.fwd) < 0.866;- self.cold_frames = if self.reset || cut { 0 } else { self.cold_frames.saturating_add(1) };// (Objects moved this frame: re-posed triangles or moved instances, e.g. walkers in a shared pose.)let blur = !self.motion_blur_off && self.blur.0 > 0.0 && (moved || self.reposed || self.pose_reposed || self.inst_moved) && !cut;// Camera motion is reprojected exactly (disocclusions are rejected per pixel), so history survives motion;@@ -382,8 +381,7 @@ impl LiveCore {// Light-sampled particles (sparks: Particles emitterArea) move their light every frame: the cache and// the temporal pass keep the short history of a lighting edit while the scene has them.let lit = self.live_lighting();- let cold = if self.cold_frames >= COLD_FALLBACK_FRAMES { 1 } else { 0 };- p.cache = [1.0, CACHE_SAMPLES, if lit { CACHE_FRAMES_LIT } else { CACHE_FRAMES }, (cache_flags() | cold) as f32];+ p.cache = [1.0, CACHE_SAMPLES, if lit { CACHE_FRAMES_LIT } else { CACHE_FRAMES }, cache_flags() as f32];}p.time[0] = shader_time(self.time);p.cam_pos = [cam.pos.x, cam.pos.y, cam.pos.z, cam.tan_half_fov];diff --git a/renderer/src/live/mod.rs b/renderer/src/live/mod.rsindex 95875ca..1654cfd 100644--- a/renderer/src/live/mod.rs+++ b/renderer/src/live/mod.rs@@ -339,8 +339,6 @@ pub struct LiveCore {reposed: bool,/// Dynamic triangles moved in this commit: the light tree's moving subtree is refit once at its end.emitters_moved: bool,- /// Frames since the last reset or camera cut (`COLD_FALLBACK_FRAMES`).- cold_frames: u32,/// Likewise for the deforming meshes of shared poses (`repose_groups`): the span they took (relative to the dynamic/// tail, past its end) and whether this frame re-skinned any.pose_span: Option<(usize, usize)>,@@ -382,14 +380,6 @@ pub struct LiveCore {guard_read: Option<(wgpu::Buffer, Arc<AtomicU32>)>,}-/// THREERT_CACHE_FLAGS: experiment switches of the radiance cache (pathtrace.wgsl `cfl`), 0 = defaults: 1 = no cold-/// fallback (cold voxels read as they are), 2 = no hit lighting (reflection hits use the cache's total), 4 = no-/// training tiles, 8 = the exact light loop at reflection hits. THREERT_CACHE=0 turns the cache off.-/// Frames after a reset or a camera cut during which pixels whose radiance-cache voxel is cold trace a fresh estimate-/// (pathtrace.wgsl, cache flag 1 off). Later the cold voxels left are mostly where bounce rays land off screen,-/// scattered, sparsely trained: their traces cost each SIMD group nearly a whole extra trace (Bistro's path 0.7-1.2-/// ms, the crowd's square 2.3 ms) for ~1 % of the image (bench-crowd ΔE 13.1 -> 13.3).-const COLD_FALLBACK_FRAMES: u32 = 30;/// Ceiling for one live lighting sample, in display units at the current exposure (live.wgsl `sample_clamp`): fireflies/// far above white. 64 until 2026-11-09, when it cut the light of small strong lights that the denoisers now keep: the@@ -404,6 +394,9 @@ fn govern_by_clock() -> bool {*F.get_or_init(|| std::env::var("THREERT_GOVERN_CLOCK").map(|v| v == "1").unwrap_or(cfg!(target_os = "android")))}+/// THREERT_CACHE_FLAGS: experiment switches of the radiance cache (pathtrace.wgsl `cfl`), 0 = defaults: 2 = no hit+/// lighting (reflection hits use the cache's total), 4 = no training tiles, 8 = the exact light loop at reflection+/// hits, 16 = no reflection resolve. THREERT_CACHE=0 turns the cache off.fn cache_flags() -> u32 {static F: std::sync::OnceLock<u32> = std::sync::OnceLock::new();*F.get_or_init(|| std::env::var("THREERT_CACHE_FLAGS").ok().and_then(|v| v.parse().ok()).unwrap_or(0))@@ -547,7 +540,7 @@ impl LiveCore {// brings it, `gpu::loop_guard_of`.)let guard_read = (gpu::loop_guard_of(!g.hwrt).is_some() && targets.kernel.guard.is_some()).then(|| (g.device.create_buffer(&wgpu::BufferDescriptor { label: Some("loop guard read"), size: 4, usage: wgpu::BufferUsages::MAP_READ | wgpu::BufferUsages::COPY_DST, mapped_at_creation: false }), Arc::new(AtomicU32::new(0))));- let mut core = LiveCore { particle_spawns: Default::default(), grid_sources: Default::default(), g, passes, targets, sc, presets: presets.to_path_buf(), assets: assets.to_path_buf(), w, h, seq: 0, aspect: w as f32 / h as f32, cam, prev_cam: cam, frame: 0, history_len: 0.0, reset: true, bloom: ([0.0; 6], [0.0; 6]), vignette: 0.0, post: [0.0; 4], blur: (0.0, 0.0), inflight: Default::default(), gpu_ms: 0.0, gpu_frame: 0, gpu_trace_ms: 0.0, edit_ms: 0.0, instanced_ms: 0.0, edit_split: EditSplit::default(), rebuild_ms: 0.0, fallback: None, fallbacks: 0, bounces: 4, rays: true, view_mode: std::env::var("THREERT_VIEW_MODE").ok().and_then(|v| v.parse().ok()).unwrap_or(0), fixed_dt: None, motion_blur_off: false, triangles, scene_name, time: 0.0, frame_dt: 1.0 / 60.0, last_frame: Instant::now(), post_key: String::new(), render_scale: 1.0, dynamic_res: false, min_scale: MIN_SCALE, display_scale: 1.0, over_budget: (0, 0), born: Instant::now(), governed: Instant::now(), profile, timer, raster, cache, kernel_bg, prev_span: None, reposed: false, emitters_moved: false, cold_frames: 0, pose_span: None, pose_reposed: false, inst_moving: vec![], inst_moved: false, prev_isz: (0, 0), light_tiles: None, lit_changed: 0, spark_lights: false, shown_spp: 1, cpu_skin_ms: 0.0, cpu_upload_ms: 0.0, gpu_blas_ms: 0.0, cpu_wait_ms: 0.0, sky_cover: 0.0, guard_trips: guard_read.as_ref().map(|_| 0), guard_read };+ let mut core = LiveCore { particle_spawns: Default::default(), grid_sources: Default::default(), g, passes, targets, sc, presets: presets.to_path_buf(), assets: assets.to_path_buf(), w, h, seq: 0, aspect: w as f32 / h as f32, cam, prev_cam: cam, frame: 0, history_len: 0.0, reset: true, bloom: ([0.0; 6], [0.0; 6]), vignette: 0.0, post: [0.0; 4], blur: (0.0, 0.0), inflight: Default::default(), gpu_ms: 0.0, gpu_frame: 0, gpu_trace_ms: 0.0, edit_ms: 0.0, instanced_ms: 0.0, edit_split: EditSplit::default(), rebuild_ms: 0.0, fallback: None, fallbacks: 0, bounces: 4, rays: true, view_mode: std::env::var("THREERT_VIEW_MODE").ok().and_then(|v| v.parse().ok()).unwrap_or(0), fixed_dt: None, motion_blur_off: false, triangles, scene_name, time: 0.0, frame_dt: 1.0 / 60.0, last_frame: Instant::now(), post_key: String::new(), render_scale: 1.0, dynamic_res: false, min_scale: MIN_SCALE, display_scale: 1.0, over_budget: (0, 0), born: Instant::now(), governed: Instant::now(), profile, timer, raster, cache, kernel_bg, prev_span: None, reposed: false, emitters_moved: false, pose_span: None, pose_reposed: false, inst_moving: vec![], inst_moved: false, prev_isz: (0, 0), light_tiles: None, lit_changed: 0, spark_lights: false, shown_spp: 1, cpu_skin_ms: 0.0, cpu_upload_ms: 0.0, gpu_blas_ms: 0.0, cpu_wait_ms: 0.0, sky_cover: 0.0, guard_trips: guard_read.as_ref().map(|_| 0), guard_read };core.spark_lights = core.sc.tables.emitter_tris.iter().any(|e| e.nominal);core.sky_cover = core.sc.tables.cloud_cover;core.apply_post(&pp);diff --git a/tests/render/cache-corner-live.ts b/tests/render/cache-corner-live.tsnew file mode 100644index 0000000..c9fc408--- /dev/null+++ b/tests/render/cache-corner-live.ts@@ -0,0 +1,7 @@+// cache/corner in the real-time renderer: a sky-lit corner is within the cache's voxels' reach (0.975 for 0.971).+import def, { test as base } from "./cache-corner.ts";+import type { TestMeta } from "./lib.ts";++export const test: TestMeta = { ...base, id: "cache/corner-live", temporal: true, live: 240 };++export default def;diff --git a/tests/render/cache-corner.ts b/tests/render/cache-corner.tsnew file mode 100644index 0000000..f5f416e--- /dev/null+++ b/tests/render/cache-corner.ts@@ -0,0 +1,22 @@+// Light in a corner: a 100-nit sky over an albedo-0.5 Lambert floor and a 2 m albedo-0.5 Lambert wall standing on+// it, seen close: the strip of the wall 1 to 3 cm above the floor against the strip 30 to 40 cm up. Near the floor+// the wall sees less sky and more floor, and the floor there sees less sky for the wall: 0.971 (the offline+// renderer's value). A radiance cache whose voxels are larger than the strip is from the floor reads there the+// mean over a voxel that reaches out of the corner.+import { BoxGeometry, Mesh } from "@threert/scene";+import { camera, lambert, plane, result, sceneWithSky, type TestMeta } from "./lib.ts";++export const test: TestMeta = {+ id: "cache/corner", features: ["sky", "lambert", "gi"], reference: "converged", temporal: false,+ metric: { kind: "ratio", a: [0.3, 0.78, 0.7, 0.86], b: [0.3, 0.1, 0.7, 0.3], expected: 0.971, tolerance: 0.01 },+ spp: 1024,+ note: "the camera 0.6 m from the wall, 0.2 m up, looking at it 0.2 m up: the image is 0.4 m of wall high",+};++export default function () {+ const scene = sceneWithSky(100);+ const wall = new Mesh(new BoxGeometry(40, 2, 0.1), lambert(0.5, "wall"));+ wall.name = "wall";+ wall.position.set(0, 1, -0.05);+ return result(scene, camera(scene, [0, 0.2, 0.6], [0, 0.2, 0], 36.87), [wall, plane(400, lambert(0.5))]);+}diff --git a/tests/render/cache-mirror-lambert-live.ts b/tests/render/cache-mirror-lambert-live.tsnew file mode 100644index 0000000..a6d469f--- /dev/null+++ b/tests/render/cache-mirror-lambert-live.ts@@ -0,0 +1,14 @@+// cache/mirror-metal-live with a white Lambert ground: the same furnace.+import { BoxGeometry, Color, Mesh, MeshStandardMaterial } from "@threert/scene";+import { test as base } from "./cache-mirror-metal.ts";+import { camera, lambert, plane, result, sceneWithSky, type TestMeta } from "./lib.ts";++export const test: TestMeta = { ...base, id: "cache/mirror-lambert-live", features: ["lambert", "mirror", "energy-conservation"], temporal: true, live: 240 };++export default function () {+ const scene = sceneWithSky(1);+ const wall = new Mesh(new BoxGeometry(8, 4, 0.1), new MeshStandardMaterial({ name: "mirror", color: new Color().setRGB(1, 1, 1), metalness: 1, roughness: 0 }));+ wall.name = "wall";+ wall.position.set(0, 2, -1.05);+ return result(scene, camera(scene, [0, 0.5, 1], [0, 0.3, -1]), [wall, plane(400, lambert(1, "ground"), "ground")], { energyCompensation: 1 });+}diff --git a/tests/render/cache-mirror-metal-live.ts b/tests/render/cache-mirror-metal-live.tsnew file mode 100644index 0000000..1c80377--- /dev/null+++ b/tests/render/cache-mirror-metal-live.ts@@ -0,0 +1,7 @@+// cache/mirror-metal in the real-time renderer.+import def, { test as base } from "./cache-mirror-metal.ts";+import type { TestMeta } from "./lib.ts";++export const test: TestMeta = { ...base, id: "cache/mirror-metal-live", temporal: true, live: 240 };++export default def;diff --git a/tests/render/cache-mirror-metal.ts b/tests/render/cache-mirror-metal.tsnew file mode 100644index 0000000..718b16d--- /dev/null+++ b/tests/render/cache-mirror-metal.ts@@ -0,0 +1,24 @@+// A lit glossy surface seen in a mirror: a white-metal ground (roughness 0.25, energy compensation on) under a+// uniform 1-nit sky, and a mirror wall that shows it. A white furnace: the ground in the mirror reads 1. In the+// real-time renderer a surface seen in a mirror takes the lights' light afresh (sharp shadows in reflections) and+// the rest from the radiance cache, the sky's too. (Until 2026-11-16 the sky's was shared between the two by+// weights that do not add up on a glossy surface: 0.80.)+import { BoxGeometry, Color, Mesh, MeshStandardMaterial } from "@threert/scene";+import { camera, plane, result, sceneWithSky, type TestMeta } from "./lib.ts";++export const test: TestMeta = {+ id: "cache/mirror-metal", features: ["ggx", "metal", "mirror", "energy-conservation"], reference: "analytic", temporal: false,+ metric: { kind: "radiance", region: [0.4, 0.52, 0.6, 0.6], expected: 1, tolerance: 0.03 },+ spp: 256,+ note: "the region is the ground's image in the wall, below the horizon's",+};++const metal = (name: string, roughness: number) => new MeshStandardMaterial({ name, color: new Color().setRGB(1, 1, 1), metalness: 1, roughness });++export default function () {+ const scene = sceneWithSky(1);+ const wall = new Mesh(new BoxGeometry(8, 4, 0.1), metal("mirror", 0));+ wall.name = "wall";+ wall.position.set(0, 2, -1.05);+ return result(scene, camera(scene, [0, 0.5, 1], [0, 0.3, -1]), [wall, plane(400, metal("ground", 0.25), "ground")], { energyCompensation: 1 });+}diff --git a/tests/render/cache-mirror-sun-live.ts b/tests/render/cache-mirror-sun-live.tsnew file mode 100644index 0000000..8221d1d--- /dev/null+++ b/tests/render/cache-mirror-sun-live.ts@@ -0,0 +1,7 @@+// cache/mirror-sun in the real-time renderer.+import def, { test as base } from "./cache-mirror-sun.ts";+import type { TestMeta } from "./lib.ts";++export const test: TestMeta = { ...base, id: "cache/mirror-sun-live", metric: { ...base.metric, tolerance: 0.03 }, temporal: true, live: 240 };++export default def;diff --git a/tests/render/cache-mirror-sun.ts b/tests/render/cache-mirror-sun.tsnew file mode 100644index 0000000..dc43b15--- /dev/null+++ b/tests/render/cache-mirror-sun.ts@@ -0,0 +1,23 @@+// A sunlit surface seen in a mirror: an albedo-0.5 Lambert ground under a sun of 2 pi lux on it (45 degrees up,+// along the mirror, which neither shades nor lights the ground), no sky, and a 2 x 1 m mirror that shows it: 1 nit.+// In the real-time renderer the surface in the mirror takes the sun's light afresh and nothing of it from the+// radiance cache. (The ground measured is 10 m and more from the mirror: the cache, which holds no directions,+// takes a mirror for a diffuse reflector of what falls on it, and close by that lights the ground 5 % more.)+import { BoxGeometry, Color, DirectionalLight, Mesh, MeshStandardMaterial } from "@threert/scene";+import { camera, lambert, plane, result, sceneWithSky, type TestMeta } from "./lib.ts";++export const test: TestMeta = {+ id: "cache/mirror-sun", features: ["directional-light", "lambert", "mirror"], reference: "analytic", temporal: false,+ metric: { kind: "radiance", region: [0.4, 0.36, 0.6, 0.41], expected: 1, tolerance: 0.02 },+ note: "the region is the ground's image in the mirror, 1.5 to 3 degrees under the horizon's",+};++export default function () {+ const scene = sceneWithSky(0);+ const wall = new Mesh(new BoxGeometry(2, 1, 0.1), new MeshStandardMaterial({ name: "mirror", color: new Color().setRGB(1, 1, 1), metalness: 1, roughness: 0 }));+ wall.name = "wall";+ wall.position.set(0, 0.5, -1.05);+ const sun = new DirectionalLight(0xffffff, 2 * Math.SQRT2 * Math.PI);+ sun.position.set(1, 1, 0);+ return result(scene, camera(scene, [0, 0.5, 1], [0, 0.3, -1]), [wall, sun, plane(400, lambert(0.5, "ground"), "ground")], { energyCompensation: 1 });+}diff --git a/tests/render/cache-one-bounce-coat-live.ts b/tests/render/cache-one-bounce-coat-live.tsnew file mode 100644index 0000000..5ab7e64--- /dev/null+++ b/tests/render/cache-one-bounce-coat-live.ts@@ -0,0 +1,7 @@+// cache/one-bounce-coat in the real-time renderer: the radiance cache's light off a coated surface is the coat's too.+import def, { test as base } from "./cache-one-bounce-coat.ts";+import type { TestMeta } from "./lib.ts";++export const test: TestMeta = { ...base, id: "cache/one-bounce-coat-live", metric: { ...base.metric, tolerance: 0.002 }, temporal: true, live: 120 };++export default def;diff --git a/tests/render/cache-one-bounce-coat.ts b/tests/render/cache-one-bounce-coat.tsnew file mode 100644index 0000000..efe4179--- /dev/null+++ b/tests/render/cache-one-bounce-coat.ts@@ -0,0 +1,15 @@+// cache/one-bounce with a floor that reflects by its coat alone: black under a clear coat (roughness 0.5). The slab+// reads the coat's mean albedo under the sky, half of it: 0.0236 of the sky (the offline renderer's value; the coat's+// albedo is tabulated, not closed-form).+import { MeshPhysicalMaterial } from "@threert/scene";+import { test as base, under } from "./cache-one-bounce.ts";+import type { TestMeta } from "./lib.ts";++export const test: TestMeta = {+ ...base, id: "cache/one-bounce-coat", features: [...base.features, "clearcoat"], reference: "converged",+ metric: { ...base.metric, expected: 0.0236, tolerance: 0.001 }, spp: 1024,+};++export const coated = () => new MeshPhysicalMaterial({ name: "coated", color: 0x000000, roughness: 1, specularIntensity: 0, clearcoat: 1, clearcoatRoughness: 0.5 });++export default under(coated());diff --git a/tests/render/cache-one-bounce-face-live.ts b/tests/render/cache-one-bounce-face-live.tsnew file mode 100644index 0000000..ac792a6--- /dev/null+++ b/tests/render/cache-one-bounce-face-live.ts@@ -0,0 +1,8 @@+// cache/one-bounce-live with the scene 3 cm higher: the floor inside the cache's voxels, not on a face of them. The+// same reading: a surface's voxel does not depend on which side of a face its hits are rounded to.+import { test as base, under } from "./cache-one-bounce.ts";+import type { TestMeta } from "./lib.ts";++export const test: TestMeta = { ...base, id: "cache/one-bounce-face-live", temporal: true, live: 120 };++export default under(undefined, 0.03);diff --git a/tests/render/cache-one-bounce-live.ts b/tests/render/cache-one-bounce-live.tsnew file mode 100644index 0000000..8d54b2b--- /dev/null+++ b/tests/render/cache-one-bounce-live.ts@@ -0,0 +1,9 @@+// cache/one-bounce in the real-time renderer, at this suite's 160 x 90, where few of the cache's training samples+// land on any one voxel of the floor: the slab's path ends on a voxel that has none, or none yet, and reads the+// coarser levels there. (Until 2026-11-16 such a path read black past a view's first 30 frames: 0.21.)+import def, { test as base } from "./cache-one-bounce.ts";+import type { TestMeta } from "./lib.ts";++export const test: TestMeta = { ...base, id: "cache/one-bounce-live", temporal: true, live: 120 };++export default def;diff --git a/tests/render/cache-one-bounce.ts b/tests/render/cache-one-bounce.tsnew file mode 100644index 0000000..41c65d5--- /dev/null+++ b/tests/render/cache-one-bounce.ts@@ -0,0 +1,26 @@+// One bounce off a lit floor: a 100-nit sky over an albedo-0.5 Lambert floor (radiance 50) and a 0.1 m albedo-0.5+// slab at 0.5 m, seen from below. Its underside sees only the floor: 0.5 x 50 = 25, a quarter of the sky beside it+// (its own shadow on the floor takes under 1 % of that). In the real-time renderer the slab's light is the radiance+// cache's alone: the path from its underside ends there.+import { BoxGeometry, Mesh, type MeshStandardMaterial } from "@threert/scene";+import { camera, lambert, plane, result, sceneWithSky, type TestMeta } from "./lib.ts";++export const test: TestMeta = {+ id: "cache/one-bounce", features: ["sky", "lambert", "gi", "radiance-cache"], reference: "analytic", temporal: false,+ metric: { kind: "ratio", a: [0.47, 0.47, 0.53, 0.53], b: [0.05, 0.05, 0.2, 0.2], expected: 0.25, tolerance: 0.01 },+ spp: 256,+ note: "the slab's underside against the sky seen beside it",+};++/** `floor`: its material; `up`: the whole scene this much higher (m). */+export const under = (floor: MeshStandardMaterial = lambert(0.5), up = 0) => () => {+ const scene = sceneWithSky(100);+ const slab = new Mesh(new BoxGeometry(0.1, 0.01, 0.1), lambert(0.5, "slab"));+ slab.name = "slab";+ slab.position.set(0, 0.505 + up, 0);+ const ground = plane(400, floor);+ ground.position.y = up;+ return result(scene, camera(scene, [0, 0.1 + up, 0.001], [0, 0.5 + up, 0], 40), [slab, ground]);+};++export default under();diff --git a/tests/render/cache-slit-live.ts b/tests/render/cache-slit-live.tsnew file mode 100644index 0000000..13e537f--- /dev/null+++ b/tests/render/cache-slit-live.ts@@ -0,0 +1,11 @@+// cache/slit in the real-time renderer: a known limit, held here so that it is seen when it moves. The face reads+// 6.8 for 5.97: its path ends on the wall opposite, 2 cm away, in a voxel 6 cm across that holds the mean of light+// which falls off within it. Every other cache of this kind goes on tracing where the last segment is shorter than+// its voxel (SHaRC: 1.7 voxels), and so read 5.98 here; in this kernel that test cost Bistro's trace 15 to 22 %+// (the pixels that go on hold their SIMD groups), and it was not taken (2026-11-16).+import def, { test as base } from "./cache-slit.ts";+import type { TestMeta } from "./lib.ts";++export const test: TestMeta = { ...base, id: "cache/slit-live", metric: { ...base.metric, expected: 6.82, tolerance: 0.04 }, temporal: true, live: 240 };++export default def;diff --git a/tests/render/cache-slit.ts b/tests/render/cache-slit.tsnew file mode 100644index 0000000..825c3cb--- /dev/null+++ b/tests/render/cache-slit.ts@@ -0,0 +1,23 @@+// Light in a slit narrower than a radiance-cache voxel: two albedo-0.5 Lambert walls 2 cm apart and 30 cm deep under+// a 100-nit sky, one wall's face seen from above through the opening, 3 to 5 cm down. The sky's light falls off+// along that face within a centimetre or two, and so does what the wall opposite sends back.+import { BoxGeometry, Mesh } from "@threert/scene";+import { camera, lambert, plane, result, sceneWithSky, type TestMeta } from "./lib.ts";++export const test: TestMeta = {+ id: "cache/slit", features: ["sky", "lambert", "gi"], reference: "converged", temporal: false,+ metric: { kind: "radiance", region: [0.2, 0.455, 0.8, 0.545], expected: 5.97, tolerance: 0.03 },+ spp: 1024,+ note: "the image is 2 degrees high: the face from about 1 to 9 cm down",+};++export default function () {+ const scene = sceneWithSky(100);+ const walls = [-0.11, 0.11].map((x, k) => {+ const m = new Mesh(new BoxGeometry(0.2, 0.3, 2), lambert(0.5, `wall-${k}`));+ m.name = `wall-${k}`;+ m.position.set(x, 0.15, 0);+ return m;+ });+ return result(scene, camera(scene, [-0.008, 0.6, 0], [0.01, 0.26, 0], 2), [...walls, plane(400, lambert(0.5))]);+}diff --git a/tests/render/cache-two-bounce-live-first.ts b/tests/render/cache-two-bounce-live-first.tsnew file mode 100644index 0000000..5347454--- /dev/null+++ b/tests/render/cache-two-bounce-live-first.ts@@ -0,0 +1,9 @@+// cache/two-bounce in the real-time renderer's first frame, when the radiance cache holds nothing yet: every path+// traces its own light to the end, and where it stops its light samples stand alone (pathtrace.wgsl `nee_alone`).+// Weighed as if a BSDF ray followed them, the sky's samples kept 18 % of its light, and the slab read 4.0.+import def, { test as base } from "./cache-two-bounce.ts";+import type { TestMeta } from "./lib.ts";++export const test: TestMeta = { ...base, id: "cache/two-bounce-live-first", metric: { ...base.metric, tolerance: 0.15 }, temporal: true, live: 1 };++export default def;diff --git a/tests/render/cache-two-bounce.ts b/tests/render/cache-two-bounce.tsnew file mode 100644index 0000000..45226c7--- /dev/null+++ b/tests/render/cache-two-bounce.ts@@ -0,0 +1,24 @@+// Light that reaches the camera by two bounces: a 100-nit sky, an albedo-0.5 Lambert floor, a 4 m albedo-0.5 slab+// 1 m over it, and under that a 0.1 m albedo-0.5 slab at 0.5 m seen from above. Its top sees the large slab's+// underside, which the floor lights, which the sky lights (and a rim of sky past the slab's edge). With paths of+// three bounces at most, as a real-time view's first frame traces them: 7.05 nits (the offline renderer's value).+import { BoxGeometry, Mesh } from "@threert/scene";+import { camera, lambert, plane, result, sceneWithSky, type TestMeta } from "./lib.ts";++export const test: TestMeta = {+ id: "cache/two-bounce", features: ["sky", "lambert", "gi"], reference: "converged", temporal: false,+ metric: { kind: "radiance", region: [0.46, 0.44, 0.54, 0.56], expected: 7.05, tolerance: 0.03 },+ spp: 1024,+ note: "maxBounces 3: sky -> floor -> the large slab -> the small one",+};++export default function () {+ const scene = sceneWithSky(100);+ const roof = new Mesh(new BoxGeometry(4, 0.02, 4), lambert(0.5, "roof"));+ roof.name = "roof";+ roof.position.set(0, 1.01, 0);+ const slab = new Mesh(new BoxGeometry(0.1, 0.01, 0.1), lambert(0.5, "slab"));+ slab.name = "slab";+ slab.position.set(0, 0.495, 0);+ return result(scene, camera(scene, [0, 0.9, 0.001], [0, 0.5, 0], 40), [roof, slab, plane(400, lambert(0.5))], { maxBounces: 3 });+}diff --git a/tests/render/sky-cutout-bounce-live-exact.ts b/tests/render/sky-cutout-bounce-live-exact.tsindex 998be46..99644ae 100644--- a/tests/render/sky-cutout-bounce-live-exact.ts+++ b/tests/render/sky-cutout-bounce-live-exact.ts@@ -1,8 +1,7 @@-// sky/cutout-bounce in the real-time renderer without `APPROX.cutoutPaths`: what the live view reads with no card-// at all, 0.21. (That is 16 % under the offline 0.25: the radiance cache's light off the floor, card or not.)+// sky/cutout-bounce in the real-time renderer without `APPROX.cutoutPaths`: the offline value.import def, { test as base } from "./sky-cutout-bounce.ts";import { APPROX, type TestMeta } from "./lib.ts";-export const test: TestMeta = { ...base, id: "sky/cutout-bounce-live-exact", metric: { ...base.metric, expected: 0.21, tolerance: 0.01 }, temporal: true, live: 120, approx: APPROX.all & ~APPROX.cutoutPaths };+export const test: TestMeta = { ...base, id: "sky/cutout-bounce-live-exact", metric: { ...base.metric, tolerance: 0.015 }, temporal: true, live: 120, approx: APPROX.all & ~APPROX.cutoutPaths };export default def;