diff --git a/docs/reservoir-reconstruction-action-plan.md b/docs/reservoir-reconstruction-action-plan.md index 135a9fe..f80f2e5 100644 --- a/docs/reservoir-reconstruction-action-plan.md +++ b/docs/reservoir-reconstruction-action-plan.md @@ -62,6 +62,9 @@ old occluded tubes leak through nearby missed tube samples. - Debug modes 13-15 now inspect the compute-owned reservoir result rather than old current-frame guide textures: rejection/invalidation state, evidence age/confidence, and explicit motion support. +- Explicit-motion candidates now track represented sample count separately from + history age in the motion lane. TubeField history authority can ramp from + accumulated evidence instead of treating age alone as trust. ## Authority Map @@ -90,7 +93,7 @@ old occluded tubes leak through nearby missed tube samples. stochastic material/sample jitter misses. 7. Partial: replace raw RGB neighborhood clamp with field/depth-aware clamp. 8. Done: add a current-frame spatial fallback for rejected history. -9. Track represented/accumulated sample count separately from age. +9. Done: track represented/accumulated sample count separately from age. 10. Partial: add TSR-style debug views for current support, occupancy, reprojection, disocclusion, rejection, clamp, unsupported carry, sample count, and final history weight. diff --git a/src/Aquarium.Engine/Render/Shaders/D3D12Post.hlsl b/src/Aquarium.Engine/Render/Shaders/D3D12Post.hlsl index 28e38c6..b6a40f9 100644 --- a/src/Aquarium.Engine/Render/Shaders/D3D12Post.hlsl +++ b/src/Aquarium.Engine/Render/Shaders/D3D12Post.hlsl @@ -511,6 +511,7 @@ FieldReservoirCandidate resolveReservoirHistoryCandidate( float reservoirSampleAge = max(currentCandidate.reservoirGuide.y, 0.0); float reservoirInvalidationCode = 0.0; + float representedSampleCount = max(currentCandidate.motion.w, 0.0); float3 historyColor = currentCandidate.colorTravel.rgb; if (fieldReservoirCandidateRequiresExplicitMotion(currentCandidate) && currentCandidate.motion.w <= 0.5) { @@ -548,6 +549,7 @@ FieldReservoirCandidate resolveReservoirHistoryCandidate( float bestValidationWeight = 0.0; float bestPreviousHistoryAge = 0.0; float bestPreviousReservoirSampleAge = 0.0; + float bestPreviousRepresentedSampleCount = 0.0; float3 bestHistoryColor = currentCandidate.colorTravel.rgb; bool isTubeFieldCandidate = fieldReservoirCandidateRequiresExplicitMotion(currentCandidate); bool needsWideHistorySearch = isTubeFieldCandidate && saturate(currentCandidate.control.x) < 0.45; @@ -588,6 +590,7 @@ FieldReservoirCandidate resolveReservoirHistoryCandidate( bestValidationWeight = validationWeight; bestPreviousHistoryAge = max(previousCandidate.control.w, 0.0); bestPreviousReservoirSampleAge = max(previousCandidate.reservoirGuide.y, 0.0); + bestPreviousRepresentedSampleCount = max(previousCandidate.motion.w, 0.0); bestHistoryColor = clampedHistory; } } @@ -596,11 +599,15 @@ FieldReservoirCandidate resolveReservoirHistoryCandidate( if (bestValidationWeight > 0.0) { - float historyConfidence = smoothstep(0.0, 6.0, bestPreviousHistoryAge); + bool isTubeFieldCandidate = fieldReservoirCandidateRequiresExplicitMotion(currentCandidate); + float representedConfidence = smoothstep(1.0, 12.0, bestPreviousRepresentedSampleCount); + float historyConfidence = max(smoothstep(0.0, 6.0, bestPreviousHistoryAge), representedConfidence); + float maxHistoryWeight = isTubeFieldCandidate ? 0.90 : 0.82; historyColor = bestHistoryColor; - historyWeight = 0.82 * lerp(0.35, 1.0, historyConfidence) * bestValidationWeight; + historyWeight = maxHistoryWeight * lerp(0.35, 1.0, historyConfidence) * bestValidationWeight; historyAge = bestValidationWeight > 0.01 ? min(bestPreviousHistoryAge + 1.0, MAX_HISTORY_AGE) : 0.0; reservoirSampleAge = bestValidationWeight > 0.01 ? min(max(reservoirSampleAge, bestPreviousReservoirSampleAge + 1.0), MAX_HISTORY_AGE) : reservoirSampleAge; + representedSampleCount = bestValidationWeight > 0.01 ? min(max(representedSampleCount, bestPreviousRepresentedSampleCount + 1.0), MAX_HISTORY_AGE) : representedSampleCount; reservoirInvalidationCode = bestValidationWeight > 0.01 ? 0.0 : 1.0; } else @@ -618,6 +625,7 @@ FieldReservoirCandidate resolveReservoirHistoryCandidate( reservoirSampleAge, reservoirCandidateDomainValidity(currentCandidate), reservoirInvalidationCode); + resolved.motion = float4(currentCandidate.motion.xyz, representedSampleCount); return resolved; } @@ -786,7 +794,7 @@ float4 reservoirDebugOrColor(FieldReservoirCandidate candidate) { return float4( saturate(candidate.control.w / MAX_HISTORY_AGE), - saturate(candidate.reservoirGuide.y / MAX_HISTORY_AGE), + saturate(candidate.motion.w / MAX_HISTORY_AGE), saturate(reservoirCandidateConfidence(candidate)), candidate.colorTravel.w); } diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 141aafe..9b869c0 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -282,3 +282,4 @@ {"timestamp":"2026-05-29T12:26:51.2056602Z","type":"decision","status":"ok","note":"TubeField proxy rasterization now only schedules pixels. The pixel shader computes analytic ray intersections against generated tube frustum/cap segments in world space, and reservoir history carries previous candidates across subpixel current-frame misses instead of clearing them. Remaining dense-line grain belongs to shared reservoir reconstruction quality, not TubeField raymarch/proxy ownership."} {"timestamp":"2026-05-29T14:43:32.7202992+01:00","type":"decision","status":"ok","note":"Reservoir reconstruction now follows the TSR-grounded support/rejection cut for TubeField: carried history is latent-only unless current evidence validates it, FieldReservoirCandidate rows include a motion lane, TubeField writes previous UV/travel from rolling-buffer offset motion, physical rolling-column identity prevents age-column cross-validation, TubeField samples without motion cannot use generic camera-only history, and tube validation bypasses raw RGB clamp with a gated low-support history search/spatial fallback."} {"timestamp":"2026-05-29T14:53:05.4052277+01:00","type":"decision","status":"ok","note":"Reservoir debug modes 13-15 now inspect the compute-owned reservoir result: invalidation/rejection state, history/sample age plus confidence, and explicit motion support. Debug output is written from D3D12ReservoirHistoryUpdateCS into the resolved reservoir texture so diagnostics observe the layer that actually owns final TubeField reconstruction."} +{"timestamp":"2026-05-29T14:59:04.4120372+01:00","type":"decision","status":"ok","note":"Explicit-motion reservoir candidates now track represented sample count separately from history age in the motion lane. TubeField history confidence can ramp from accumulated validated evidence, and reservoir debug mode 14 exposes history age, represented count, and confidence."} diff --git a/state/map.yaml b/state/map.yaml index 90f87a2..ccf6326 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -224,7 +224,8 @@ next_actions: raw RGB clamp for tube validation, and uses a gated current-frame spatial fallback/2x2 previous-history search for low-support samples. Reservoir debug modes 13-15 inspect compute-owned rejection/invalidation state, - evidence age/confidence, and explicit motion support. The deleted TubeField-local compute + evidence age/confidence, represented sample count, and explicit motion + support. The deleted TubeField-local compute ReSTIR/tile-bin path is not a live authority, fallback, or hidden mode. Any future temporal/spatial reuse for tubes must extend the shared reservoir organ rather than resurrecting a payload-local reservoir renderer.