diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 31fca0d7..3c2964da 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -2468,6 +2468,55 @@ too bright against offline and 2.6 to 2.7 times a tenth of a second on, a denois included: that is before reconstruction, and was not looked into. The recordings and their measures were made outside the repository. Not checked on Vulkan, nor in a browser. +**Which of a reflection's two histories counts is not the frame's samples' to say (2026-12-02).** The entry above +measured what the picture changes by while the camera moves; this one, the light it holds. The same two recordings +(the street at night, the hall of machines; an M4 at half resolution), each frame's display-linear luminance over the +offline render's of the same instant: the street 1.00 standing still, 0.97 mid-strafe, 1.02 as the camera stops from +8 m/s; the hall 0.90, 0.85 and 0.87. The hall loses light while the camera moves through it. + +Where it goes. The hall's frames taken apart, linear sums against the offline render's, without what the camera ray +sees directly (its lamps are hundreds of times the frame's mean, and white on the display either way). The kernel's +samples hold the same share of the offline light moving or still (0.90 to 0.99). The histories hold all of the +samples' light standing still and 4 to 10 % less in a move. Most of that is the specular signal: 0.86 of the offline +one standing still, 0.73 mid-strafe, 0.84 at the stop, 0.76 along the camera's own path, and with no specular history +at all in a move 0.92, 0.89 and 0.83: the history held less light than the samples it was made of. It is not the +upscaler: its output against its input, 8 × 8 block means compressed as a display compresses them, is within 2 % in +every one of those frames, with or without the clamp of a moving pixel's history. + +Why. In a move `stemporal` reads a reflection's history in two places, where the surface point was and where the +reflected image was, and each counted by what the roughness says of its place times exp(-e²), e its distance from the +mean of this frame's nine samples around in bands of their deviation. One path a pixel is heavy-tailed: nine samples +of a reflection that comes by rare bright ones are mostly dark, so of two histories the darker lay nearer them and +won, frame after frame. + +- The two count by the roughness alone, the reflection's being a history that was found at its place on surfaces of + this normal and roughness; the nine samples' statistics are read only where a history is held to them (animated + shading). The hall's specular signal mid-strafe 0.73 → 0.87, at the stop 0.84 → 0.95, a tenth of a second on 0.86 → + 0.92, along its path 0.76 → 0.82; standing still and mid-turn as it was (0.86, 0.82: without parallax there is one + history). The frame's light mid-strafe 0.85 → 0.89, mid-orbit 0.86 → 0.90, at the stop 0.87 → 0.95 and a tenth of a + second on 0.86 → 0.92; how unevenly that ratio lies over forty tiles of the frame, 15 to 26 % less in those; ΔE + against offline 4.94 → 4.82, 4.98 → 4.94, 5.67 → 5.64, 5.28 → 5.20 (eight seconds along the path 4.04 → 4.10). +- What it costs: the hall's change from a frame to the next over the six frames after the stop, 1.97 → 2.04 (after the + strafe 2.27 → 2.21). +- Nothing else measured moved. The street's recording: its change from frame to frame, its detail and its ΔE the + same at every moment. `bench-object-ghosting`: its sixteen readings (the thrown lamp's trail a tenth of a second + after its flight 84 → 74 pixels). + `bench-ghosting --quick --check`: its five within 0.02. `bench-temporal`: the water and the lighting edit to the + last digit (a still camera has one history), the street's dolly 1.99 / 2.04 / 2.00 / 1.59 → 2.01 / 2.06 / 1.96 / + 1.58. `bench-window`'s turn and orbit over the city against offline: twenty rows the same to 0.01. Twelve clips + against offline: eleven within 0.01, a turntable of jewellery ΔE 2.34 → 2.37; frame time 0.0 to 0.7 % more. Unit + suite 292, render suite 273. + +Also found, and left as it is. The street's walk passes potted bushes and a hedge that read 0.65 to 0.79 of the +offline render's light, and still do after the camera has stood there for eight seconds: not motion, and not a +history. It is the live kernel's `A_CUTOUT_EMITTERS` (docs/RUNTIME.md "How live differs from offline": cutouts are +opaque to emitters' shadow rays, so leaves shade each other as whole cards). With that bit off they read 0.97 and +0.99, for 18 % more of the frame at the street's first view and 24 % over the walk (15.5 → 18.3 and 16.7 → 20.6 ms). +The firefly cut on a young diffuse history takes 4 to 5 % of the hall's diffuse light as the camera stops (0.85 → +0.89 without it) and 1 to 2 % elsewhere. The specular signal mid-turn (0.82 for 0.86 standing still, 0.89 with no +history) is not explained. The recordings and their measures were made outside the repository. Not checked on +Vulkan, nor in a browser. + **The live passes from one place (2026-11-14, after it).** A buffer and a pass more (the locks' carry, above) took seven edits that had to agree: the declaration in live.wgsl, the bind group layout's entries, the pass list, the buffers' sizes and order, the bind group's entries, the dispatch grid (in two copies), and the merged layout's table. diff --git a/renderer/shaders/live.wgsl b/renderer/shaders/live.wgsl index 8e603452..34d59e70 100644 --- a/renderer/shaders/live.wgsl +++ b/renderer/shaders/live.wgsl @@ -979,8 +979,8 @@ const SPEC_VIRT_ROUGH: f32 = 0.6; const SPEC_VIRT_FROM: f32 = 0.3; // What the surface's history counts for on a mirror, where it is right only if nothing in the reflection differs. const SPEC_SURFACE_MIRROR: f32 = 0.1; -// The neighbourhood's band, in its deviations, and as a share of the level (the samples' mean where it chooses between -// two histories, the history's own where it clamps one). +// The neighbourhood's band a history is clamped into on animated shading, in the samples' deviations, and as a share +// of the history's own level. const SPEC_GAMMA: f32 = 1.25; const SPEC_REL: f32 = 0.1; // The chart level below which a pixel counts as lit by rare samples (a dark neighbourhood is then no evidence against @@ -990,7 +990,7 @@ const SPEC_STEADY: f32 = 0.45; // How far a history may have slid against what it shows (previous traced pixels, summed over its frames) on a // surface of roughness 0, and how much further by roughness squared (the lobe's width: a blurred image hides a // slide); the share of the parallax that counts on a mirror, where the reflection's own place is known; and the -// share of the bound lifted where the reflection's history is found there and agrees with this frame. +// share of the bound lifted where the history is the one found at the reflection's place. const SPEC_SLIDE: f32 = 4.0; const SPEC_SLIDE_ROUGH: f32 = 32.0; const SPEC_PAR_MIRROR: f32 = 0.25; @@ -1040,11 +1040,19 @@ fn spec_chart_pack(level: f32, e: f32, rms: f32, dither: f32) -> f32 { // distance t lies at t + d along the view ray. Both places are read when they differ: where the surface point was // (`prev_pixel`, moving objects by their motion), and where that point behind the surface was (for a surface // that moved: carried by twice its move along its normal, the law of reflection for an image of what stands -// still). Which to believe is this frame's samples' to say: each history is held against the mean and deviation -// of the nine samples around, in YCoCg (a box along luma, Karis 2014, slide 33; a statistical one in place of his -// minimum and maximum, as Schied et al. 2018 § 2 report of Patney et al. 2016), and counts by exp(-e^2), e its -// distance in bands, times what the roughness says before any sample does (the reflection's place on a mirror, -// the surface's from SPEC_VIRT_ROUGH). +// still). Which to believe this frame's samples cannot say: both count, by what the roughness says of each place +// (the reflection's on a mirror, the surface's from SPEC_VIRT_ROUGH), the reflection's being a history that was +// found there, on surfaces of this normal and roughness (`spec_history`). Until 2026-12-02 each also counted by +// exp(-e^2), e its distance from the mean of the nine samples around in bands of their deviation. One path a +// pixel is heavy-tailed: nine samples of a reflection that comes by rare bright ones are mostly dark, so of two +// histories the darker lay nearer them and won, frame after frame, for as long as the camera moved past. The +// hall of machines' specular signal against its offline render (linear, the whole frame; an M4 at half +// resolution): mid-strafe 0.73, as the camera stops from 8 m/s 0.84, a tenth of a second on 0.86, along its own +// path 0.76, for 0.87, 0.95, 0.92 and 0.82 without that count (0.86 standing still either way), and the frame's +// light at the stop 0.87 of the offline frame's for 0.95. Nothing else measured moved: bench-object-ghosting's +// sixteen readings (the thrown lamp's trail a tenth of a second after its flight 84 pixels for 74), +// bench-ghosting's five within 0.02, bench-temporal's water and edit to the last digit (a still camera has one +// history). // - How long it may be: the frame's bound; the bound of a history resampled in motion (`moving_frames`); and a bound // by the parallax, the distance between the two places a frame: a history n frames long has slid n times that // against one of them, and may by SPEC_SLIDE pixels and more the wider the lobe. The parallax is none in a turn @@ -1052,7 +1060,7 @@ fn spec_chart_pack(level: f32, e: f32, rms: f32, dither: f32) -> f32 { // distance the parallax of a far reflection is taken (the most it can be), and rough surfaces are bound too (a // lamp's highlight on wet stones slides with the view as a mirror's image does, only blurred: without that, the // street 0.1 s after a stop read an excess dE of 1.78 for 1.33). On a mirror only a share of it counts, and -// little of it where the reflection's history was found in its place and agrees with this frame. While the +// little of it where the history is the one found in the reflection's place. While the // lighting changes, a bound by roughness: shortest where a reflection is sharp enough to show a lag and the // filter already reaches (SPEC_GLOSS), longer on a mirror, which has the temporal mean alone against its noise, // and the frame's bound alone on rough surfaces, whose reflection is too blurred to show one. Their histories @@ -1160,8 +1168,8 @@ fn stemporal(@builtin(global_invocation_id) gid: vec3) { } } } - // This frame's samples around: needed to choose between two histories, and to hold one to them on animated - // shading. (Any other pixel reads none.) + // (The two histories: by the roughness alone. This frame's samples around are read only to hold a history to + // them on animated shading, below.) // The light that drifts for the diffuse history drifts for a rough reflection of it too: the same factor, from // SPEC_GLOSS on (a sharp reflection is of one thing, and has its own short bound). if (live && drifted > 0.0) { @@ -1175,9 +1183,17 @@ fn stemporal(@builtin(global_invocation_id) gid: vec3) { let two = hv.w > 0.0; let held = anim && (h.w > 0.0 || two); var clamped = 0.0; // the share of the history the clamp took - var found = 0.0; // how far the reflection's history was found, and agrees with this frame + var found = 0.0; // how far the history is the one found at the reflection's place var risen = 0.0; // the share by which the clamp raised the history - if (two || held) { + if (two) { + // (What the roughness says of each place; the reflection's history is one that was found there, `spec_history`.) + let of_surface = smoothstep(SPEC_VIRT_FROM, SPEC_VIRT_ROUGH, rough); + let ws = select(0.0, mix(SPEC_SURFACE_MIRROR, 1.0, smoothstep(0.0, SPEC_VIRT_FROM, rough)), h.w > 0.0); + let wv = 1.0 - of_surface; + h = (h * ws + hv * wv) / max(ws + wv, 1.0e-6); + found = wv / max(ws + wv, 1.0e-6); + } + if (held && h.w > 0.0) { var s1 = vec3(0.0); var s2 = vec3(0.0); var sn = 0.0; @@ -1193,37 +1209,22 @@ fn stemporal(@builtin(global_invocation_id) gid: vec3) { let mean = s1 / sn; let dev = sqrt(max(s2 / sn - mean * mean, vec3(0.0))); let dark = CHART_DARK / max(exposure_scale(), 1.0e-8); - if (two) { - // Each history's distance from the samples' mean, in bands, and what the roughness says of each. - let band = SPEC_GAMMA * dev + SPEC_REL * mean.x + dark; - let ds = abs(ycocg(h.rgb) - mean) / band; - let dv = abs(ycocg(hv.rgb) - mean) / band; - let es = min(max(max(ds.x, ds.y), ds.z), 3.0); - let ev = min(max(max(dv.x, dv.y), dv.z), 3.0); - let of_surface = smoothstep(SPEC_VIRT_FROM, SPEC_VIRT_ROUGH, rough); - let ws = select(0.0, mix(SPEC_SURFACE_MIRROR, 1.0, smoothstep(0.0, SPEC_VIRT_FROM, rough)) * exp(-es * es), h.w > 0.0); - let wv = (1.0 - of_surface) * exp(-ev * ev); - h = (h * ws + hv * wv) / max(ws + wv, 1.0e-6); - found = wv / max(ws + wv, 1.0e-6) * exp(-ev * ev); - } - if (held && h.w > 0.0) { - let hy = ycocg(h.rgb); - // (Steadily lit: by the level, and by a history long enough for its level to mean it. While the lighting - // changes, by the level here or of a pooled pixel beside it, the rim of a passing reflection being lit - // as its middle is, and from a history half as long.) - let steady = smoothstep(SPEC_RARE, SPEC_STEADY, select(chart.x, around_level, live)) * chart_mature(select(0.5, 1.0, live) * h.w); - let rare = (1.0 - steady) * SPEC_ANIM_RARE; - // (Chroma to twice the luma: a saturated colour's Co is.) - let band = SPEC_GAMMA * dev + (SPEC_REL + rare) * max(hy.x, 0.0) * vec3(1.0, 2.0, 2.0) + dark; - let hc = clamp(hy, mean - band, mean + band); - let took = abs(hc - hy); - clamped = clamp(max(max(took.x, took.y), took.z) / (max(hy.x, mean.x) + dark), 0.0, 1.0); - // (Raised: all nine samples are above the history at once. That is no rare sample but a light that - // has come, a reflection passing: the level is told so below, or when it has passed, the nine dark - // samples would count for nothing against it: a thrown light's reflection stayed along its path.) - if (live && hc.x > hy.x) { risen = clamped; } - h = vec4(max(ycocg_rgb(hc), vec3(0.0)), h.w); - } + let hy = ycocg(h.rgb); + // (Steadily lit: by the level, and by a history long enough for its level to mean it. While the lighting + // changes, by the level here or of a pooled pixel beside it, the rim of a passing reflection being lit + // as its middle is, and from a history half as long.) + let steady = smoothstep(SPEC_RARE, SPEC_STEADY, select(chart.x, around_level, live)) * chart_mature(select(0.5, 1.0, live) * h.w); + let rare = (1.0 - steady) * SPEC_ANIM_RARE; + // (Chroma to twice the luma: a saturated colour's Co is.) + let band = SPEC_GAMMA * dev + (SPEC_REL + rare) * max(hy.x, 0.0) * vec3(1.0, 2.0, 2.0) + dark; + let hc = clamp(hy, mean - band, mean + band); + let took = abs(hc - hy); + clamped = clamp(max(max(took.x, took.y), took.z) / (max(hy.x, mean.x) + dark), 0.0, 1.0); + // (Raised: all nine samples are above the history at once. That is no rare sample but a light that + // has come, a reflection passing: the level is told so below, or when it has passed, the nine dark + // samples would count for nothing against it: a thrown light's reflection stayed along its path.) + if (live && hc.x > hy.x) { risen = clamped; } + h = vec4(max(ycocg_rgb(hc), vec3(0.0)), h.w); } // The chart: this frame's share against the history (one channel: the mean of the three), its residual from the // level, and, while the lighting changes, what the pooled average takes of the history. @@ -1238,8 +1239,8 @@ fn stemporal(@builtin(global_invocation_id) gid: vec3) { if (par > 0.0) { // (The share of the parallax that counts: SPEC_PAR_MIRROR on a mirror, all of it from NEAR_MIRROR, none // from SPEC_VIRT_ROUGH, where the reflection stays with its surface.) - // Less where the reflection's history was found where it should be and agrees with this frame's samples: - // the bound is for a place that is not known. + // Less where the history is the one found at the reflection's place: the bound is for a place that is not + // known. let counts = mix(SPEC_PAR_MIRROR, 1.0, smoothstep(0.0, NEAR_MIRROR, rough)) * (1.0 - SPEC_FOUND * found); cap = min(cap, 1.0 + (SPEC_SLIDE + SPEC_SLIDE_ROUGH * rough * rough) / max(par * counts, 1.0e-6)); }