Weave reservoir confidence into TAA
This commit is contained in:
parent
c68a0e656e
commit
18bf6aefba
20 changed files with 39 additions and 6 deletions
|
|
@ -137,7 +137,8 @@ Not built yet:
|
|||
- camera/disocclusion/material validation for fractal/SDF reservoirs;
|
||||
- spatial neighbor reuse across screen tiles and cube-sphere neighbor domains;
|
||||
- GRIS-style domain shift mappings for nested `.aquageo` domains;
|
||||
- TAA guide-buffer weaving of reservoir confidence, age, and domain validity;
|
||||
- expanded TAA guide-buffer storage for previous-frame reservoir confidence,
|
||||
sample age, domain validity, and invalidation reason;
|
||||
- SSD/RAM residency queues driven by reservoir contribution estimates.
|
||||
|
||||
## Implementation Roadmap
|
||||
|
|
@ -156,7 +157,9 @@ Not built yet:
|
|||
invalidation reason.
|
||||
7. Weave reservoir confidence and temporal detail into TAA guide buffers so the
|
||||
history filter can distinguish stable reused evidence from fresh stochastic
|
||||
noise.
|
||||
noise. The first pass uses current scene-control.w for reservoir confidence
|
||||
and keeps history-control.w as age; full previous-frame reservoir validity
|
||||
still needs an expanded guide layout.
|
||||
8. Add Mimir-facing candidate adapters only after the fractal path proves the
|
||||
contract: modality features are candidates, not a second reservoir system.
|
||||
9. Port the pure core to HLSL and add CPU/GPU parity fixtures.
|
||||
|
|
|
|||
|
|
@ -344,7 +344,9 @@ Tasks:
|
|||
- [ ] Add spatial reuse validation across screen tiles and cube-sphere neighbor
|
||||
domains.
|
||||
- [ ] Feed reservoir confidence, selected target, candidate count, sample age,
|
||||
and invalidation reason into TAA guide/history buffers.
|
||||
and invalidation reason into TAA guide/history buffers. Current
|
||||
scene-control.w now carries current reservoir confidence into resolve; full
|
||||
previous-frame reservoir guide storage remains open.
|
||||
- [ ] Add confidence decay and stale uncertainty growth.
|
||||
- [ ] Add fake contribution probe.
|
||||
- [ ] Add convergence telemetry.
|
||||
|
|
@ -364,7 +366,8 @@ Tests:
|
|||
- fixed camera path converges within tolerance;
|
||||
- [x] temporal reuse rejects mismatched domain ancestry;
|
||||
- [x] spatial reuse rejects invalid local-frame shifts;
|
||||
- TAA history confidence drops when reservoir validity changes;
|
||||
- [x] TAA history confidence is modulated by current reservoir confidence;
|
||||
- TAA history confidence drops when previous-frame reservoir validity changes;
|
||||
- update cost respects budget.
|
||||
|
||||
Exit gate:
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
new(9, "SdfObject Identity"),
|
||||
new(10, "SdfObject Steps"),
|
||||
new(11, "Client Fractal Domains"),
|
||||
new(12, "Reservoir/TAA Guide"),
|
||||
];
|
||||
private static readonly DebugUi.DebugUiOption[] SynthPresetOptions = AquaSynth.Dsl.BuiltInScripts.ReferenceScripts()
|
||||
.Select((preset, index) => new DebugUi.DebugUiOption(index, $"{preset.Family}/{preset.Name}"))
|
||||
|
|
|
|||
|
|
@ -330,6 +330,7 @@ ResolveOut D3D12ResolvePS(VertexOut input)
|
|||
float currentCoverage = saturate(currentControl.x);
|
||||
float currentStepRatio = saturate(currentControl.y);
|
||||
float currentTemporalDetail = saturate(currentControl.z);
|
||||
float currentReservoirConfidence = currentControl.w > 0.0 ? saturate(currentControl.w) : 1.0;
|
||||
|
||||
float historyWeight = 0.0;
|
||||
float historyAge = 0.0;
|
||||
|
|
@ -377,8 +378,9 @@ ResolveOut D3D12ResolvePS(VertexOut input)
|
|||
float coverageContinuityWeight = 1.0 - smoothstep(0.10, 0.50, abs(previousCoverage - currentCoverage));
|
||||
float temporalDetailWeight = 1.0 - smoothstep(0.08, 0.45, abs(previousTemporalDetail - currentTemporalDetail));
|
||||
temporalDetailWeight = max(temporalDetailWeight, 1.0 - smoothstep(0.02, 0.12, max(previousTemporalDetail, currentTemporalDetail)));
|
||||
float reservoirConfidenceWeight = lerp(0.45, 1.0, currentReservoirConfidence);
|
||||
float historyConfidence = smoothstep(0.0, 6.0, previousHistoryAge);
|
||||
float validationWeight = travelWeight * colorWeight * fieldWeight * normalWeight * coverageWeight * coverageContinuityWeight * temporalDetailWeight;
|
||||
float validationWeight = travelWeight * colorWeight * fieldWeight * normalWeight * coverageWeight * coverageContinuityWeight * temporalDetailWeight * reservoirConfidenceWeight;
|
||||
|
||||
historyColor = clampedHistory;
|
||||
historyWeight = 0.82 * lerp(0.35, 1.0, historyConfidence) * validationWeight;
|
||||
|
|
@ -433,6 +435,10 @@ ResolveOut D3D12ResolvePS(VertexOut input)
|
|||
{
|
||||
finalColor = currentStepRatio.xxx;
|
||||
}
|
||||
else if (renderDebugMode >= 11.5 && renderDebugMode < 12.5)
|
||||
{
|
||||
finalColor = float3(currentReservoirConfidence, currentTemporalDetail, combinedHistoryWeight);
|
||||
}
|
||||
ResolveOut output;
|
||||
output.finalColor = float4(finalColor, 1.0);
|
||||
output.historyColor = float4(resolved, currentTravel);
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ struct SdfSurface
|
|||
float roughness;
|
||||
float3 emission;
|
||||
float temporalDetail;
|
||||
float reservoirConfidence;
|
||||
};
|
||||
|
||||
void cameraBasis(float3 camera, float3 target, out float3 forward, out float3 right, out float3 up)
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ bool traceSdf(float3 origin, float3 direction, int sdfIndex, out float travel, o
|
|||
surface.roughness = 0.0;
|
||||
surface.emission = 0.0;
|
||||
surface.temporalDetail = 0.0;
|
||||
surface.reservoirConfidence = 1.0;
|
||||
float previousTravel = travel;
|
||||
float previousDistance = sdfDistance(origin + direction * travel, sdfIndex);
|
||||
float maxStep = max(sdfObject.centerRadius.w * SDF_TRACE_MAX_STEP_RADIUS_SCALE, SDF_TRACE_MIN_STEP);
|
||||
|
|
@ -128,7 +129,11 @@ SceneOut D3D12SdfProxyPS(SdfObjectProxyVertexOut input)
|
|||
SceneOut output;
|
||||
output.colorTravel = float4(shadeSdf(uv, travel, p, normal, sdfIndex, surface), min(travel, farDistance + 1.0));
|
||||
output.metadata = float4(fieldId, normal);
|
||||
output.control = float4(1.0, stepCount / (float)SDF_TRACE_STEPS, saturate(surface.temporalDetail), 0.0);
|
||||
output.control = float4(
|
||||
1.0,
|
||||
stepCount / (float)SDF_TRACE_STEPS,
|
||||
saturate(surface.temporalDetail),
|
||||
saturate(surface.reservoirConfidence));
|
||||
output.depth = saturate(travel / max(farDistance, 0.001));
|
||||
return output;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ SdfSurface sdfSurface(float3 p, int sdfIndex)
|
|||
surface.roughness = 0.56;
|
||||
surface.emission = primitiveEmissionRadiance(sdfFieldId(sdfIndex));
|
||||
surface.temporalDetail = 0.0;
|
||||
surface.reservoirConfidence = 1.0;
|
||||
return surface;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ SdfSurface sdfSurface(float3 p, int sdfIndex)
|
|||
surface.roughness = isCalyx > 0.5 ? 0.46 : 0.22;
|
||||
surface.emission = surface.baseColor * (isCalyx > 0.5 ? 0.05 : 0.56);
|
||||
surface.temporalDetail = 0.0;
|
||||
surface.reservoirConfidence = 1.0;
|
||||
return surface;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ SdfSurface sdfSurface(float3 p, int sdfIndex)
|
|||
surface.roughness = 0.28;
|
||||
surface.emission = primitiveEmissionRadiance(sdfFieldId(sdfIndex)) + surface.baseColor * 0.06;
|
||||
surface.temporalDetail = 0.0;
|
||||
surface.reservoirConfidence = 1.0;
|
||||
return surface;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ SdfSurface sdfSurface(float3 p, int sdfIndex)
|
|||
surface.roughness = 0.44;
|
||||
surface.emission = primitiveEmissionRadiance(sdfFieldId(sdfIndex)) + surface.baseColor * 0.04;
|
||||
surface.temporalDetail = 0.0;
|
||||
surface.reservoirConfidence = 1.0;
|
||||
return surface;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ SdfSurface sdfSurface(float3 p, int sdfIndex)
|
|||
surface.roughness = 0.50;
|
||||
surface.emission = primitiveEmissionRadiance(sdfFieldId(sdfIndex)) + surface.baseColor * 0.035;
|
||||
surface.temporalDetail = 0.0;
|
||||
surface.reservoirConfidence = 1.0;
|
||||
return surface;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -169,6 +169,7 @@ SdfSurface sdfSurface(float3 p, int sdfIndex)
|
|||
+ sparkColor * (isSpark * 1.35 + isTendril * 0.85)
|
||||
+ shadowColor * isShadow * 0.015;
|
||||
surface.temporalDetail = 0.0;
|
||||
surface.reservoirConfidence = 1.0;
|
||||
return surface;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -364,6 +364,7 @@ SdfSurface sdfSurface(float3 p, int sdfIndex)
|
|||
+ gold * seamMask * 0.090
|
||||
+ emberColor * emberMask * (3.2 + heartbeat * 1.1 + domain.pressure * 0.8);
|
||||
surface.temporalDetail = 0.0;
|
||||
surface.reservoirConfidence = 1.0;
|
||||
return surface;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -152,6 +152,7 @@ SdfSurface sdfSurface(float3 p, int sdfIndex)
|
|||
+ stripeColor * isStripe * (0.92 + sdfObject.state.y * 0.16)
|
||||
+ gateColor * isGate * (0.42 + sdfObject.state.y * 0.12);
|
||||
surface.temporalDetail = 0.0;
|
||||
surface.reservoirConfidence = 1.0;
|
||||
return surface;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -185,6 +185,7 @@ SdfSurface sdfSurface(float3 p, int sdfIndex)
|
|||
+ riskColor * riskMask * (0.36 + risk * 0.95)
|
||||
+ riskColor * fractureMask * (0.18 + risk * 0.58);
|
||||
surface.temporalDetail = 0.0;
|
||||
surface.reservoirConfidence = 1.0;
|
||||
return surface;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -281,6 +281,7 @@ SdfSurface sdfSurface(float3 p, int sdfIndex)
|
|||
surface.roughness = lerp(0.34, 0.84, land);
|
||||
surface.emission = 0.0;
|
||||
surface.temporalDetail = saturate(authoredMaterial * 3.0);
|
||||
surface.reservoirConfidence = saturate(0.42 + authoredMaterial * 2.2 + leafCluster * 0.25 + pebbleCluster * 0.20);
|
||||
return surface;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ SdfSurface sdfSurface(float3 p, int sdfIndex)
|
|||
surface.roughness = 0.72;
|
||||
surface.emission = surface.baseColor * lerp(3.8, 7.5, hot);
|
||||
surface.temporalDetail = 0.0;
|
||||
surface.reservoirConfidence = 1.0;
|
||||
return surface;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ SdfSurface sdfSurface(float3 p, int sdfIndex)
|
|||
surface.roughness = 0.92;
|
||||
surface.emission = 0.0;
|
||||
surface.temporalDetail = 0.0;
|
||||
surface.reservoirConfidence = 1.0;
|
||||
return surface;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -161,3 +161,4 @@
|
|||
{"timestamp":"2026-05-19T17:35:00+01:00","topic":"restir-reservoir-core","lesson":"The previous stable-key temporal smoother was not ReSTIR. Aquarium now treats `ResampledImportanceReservoir<TSample>` as the RIS/ReSTIR math authority: selected sample, target value, weight sum, represented candidate count, merge, and contribution weight. `TemporalSpatialEvidenceReservoir` is a stable resolved-track layer, while fractal contribution scoring should become a candidate generator feeding reservoir resampling with temporal/spatial/domain validation and TAA guide-buffer integration.","files":["src/Aquarium.Engine.Fractal/Temporal/ResampledImportanceCandidate.cs","src/Aquarium.Engine.Fractal/Temporal/ResampledImportanceReservoir.cs","tests/Aquarium.Engine.Fractal.Tests/ResampledImportanceReservoirTests.cs","docs/temporal-spatial-evidence-reservoir.md","research/rendering/fractal-brush-implementation-roadmap.md","state/map.yaml","state/memory.json"],"source":"user corrected the architecture toward NVIDIA ReSTIR/GRIS rather than invented spatiotemporal reservoir sampling"}
|
||||
{"timestamp":"2026-05-19T18:03:00+01:00","topic":"fractal-contribution-candidates","lesson":"FractalContributionCache now frames scheduled update nodes as weighted `ResampledImportanceReservoir<FractalContributionCandidate>` candidates and exposes a per-frame reservoir snapshot for debug/tests. This is the handoff from heuristic LOD scoring into reservoir evidence; temporal/spatial reuse and domain shift validation still need to be built explicitly before calling the fractal path ReSTIR-complete.","files":["src/Aquarium.Engine.Fractal/Lod/FractalContributionCandidate.cs","src/Aquarium.Engine.Fractal/Lod/FractalContributionCache.cs","tests/Aquarium.Engine.Fractal.Tests/FractalContributionCacheTests.cs","docs/temporal-spatial-evidence-reservoir.md","research/rendering/fractal-brush-implementation-roadmap.md","state/memory.json"],"source":"continued Perfect Machine work after adding the ReSTIR-style reservoir core"}
|
||||
{"timestamp":"2026-05-19T18:24:00+01:00","topic":"fractal-probe-reservoir-samples","lesson":"Fractal SDF/detail reservoir candidates now have a typed probe sample: domain key, node key, local center, bound radius, target contribution, source PDF, material delta, and payload handle. `FractalProbeReuseValidator` rejects unknown domains, sibling-domain reuse, invalid bounds, and excessive local shift. This starts the GRIS-style domain-shift boundary; renderer inputs for camera motion, disocclusion, material compatibility, and visibility still need to be wired before reuse is complete.","files":["src/Aquarium.Engine.Fractal/Lod/FractalProbeSample.cs","tests/Aquarium.Engine.Fractal.Tests/FractalProbeSampleTests.cs","docs/temporal-spatial-evidence-reservoir.md","research/rendering/fractal-brush-implementation-roadmap.md"],"source":"continued Perfect Machine work after connecting fractal contribution updates to reservoir candidates"}
|
||||
{"timestamp":"2026-05-19T18:46:00+01:00","topic":"taa-reservoir-guide-lane","lesson":"SDF surfaces now publish `reservoirConfidence`; the SDF proxy writes it to current scene-control.w, and D3D12Post folds that value into history validation with debug mode 12 showing reservoir confidence, temporal detail, and history weight. This is the first cache/reservoir signal woven into TAA buffers. History-control.w still owns history age, so previous-frame reservoir confidence/sample age/invalidation reason require an expanded guide layout before full ReSTIR-style TAA integration.","files":["src/Aquarium.Engine/Render/Shaders/D3D12SdfCommon.hlsli","src/Aquarium.Engine/Render/Shaders/D3D12SdfProxy.hlsli","src/Aquarium.Engine/Render/Shaders/D3D12Post.hlsl","src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Zyphos/Shaders/D3D12ZyphosPlanet.hlsl"],"source":"user explicitly asked to weave the cache into TAA buffers"}
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@
|
|||
"Zyphos passes cube-tile domain metadata through height brush packets and binds those packets into the SDF pass. The planet shader may use authored brush packets for post-hit material/detail evaluation; traced geometry must wait for selected-cut/resident packet policy so SDF distance loops do not evaluate every brush at every step.",
|
||||
"Zyphos traced planet geometry may sample only a hard-budgeted top-influence subset of authored fractal brush packets in `sdfDistance`; the current proven budget is four brushes after sorting selected packets by abs(amplitude)*max(radius). A 12-brush distance loop was tested and rejected because it pushed the live frame to about 33 ms; the four-brush loop returns the live view to about 16.4 ms while full packet richness remains available to post-hit material/detail.",
|
||||
"Temporal resolve has a cache-facing detail lane: SdfSurface.temporalDetail writes through scene-control.z into history-control.z, and D3D12Post reduces history confidence when current and previous temporal detail disagree. Use this lane for stochastic fractal/cache stability signals, not as geometry authority.",
|
||||
"Temporal resolve now has a first reservoir guide lane: SdfSurface.reservoirConfidence writes through current scene-control.w and D3D12Post multiplies history validation by that current confidence. History-control.w still owns history age, so previous-frame reservoir validity/sample age/invalidation reason need an expanded guide layout before this can be called full ReSTIR-style TAA integration.",
|
||||
"FractalContributionCache is the live cache loop: each frame builds a resource plan from current summaries and cached states, stochastically observes only budgeted update nodes, stores mean/variance/confidence/sample age through FractalContributionEstimator, frames scheduled updates as weighted ResampledImportanceReservoir candidates, and lets backend packet compilation stay cached by selected-cut key. It is a candidate source, not the whole temporal/spatial reuse pass. Do not replace this with a static plan cache that stops learning after the first camera bucket.",
|
||||
"FractalProbeSample is the typed reservoir sample shape for fractal SDF/detail reuse: domain key, node key, local center, bound radius, target contribution, source PDF, material delta, and payload handle. Reuse must pass domain lineage and local-shift validation now, and later camera motion, disocclusion, material compatibility, and visibility validation before it is allowed into temporal/spatial reuse.",
|
||||
"Zyphos camera distance limits belong to the selected spatial domain, not one global planetary clamp. Leaf/pebble domains must be able to zoom below whole-body distances, and the parent star must be a visible SDF body when it is also the primary light source.",
|
||||
|
|
|
|||
Loading…
Reference in a new issue