diff --git a/src/Aquarium.Engine/Render/Shaders/D3D12FractalSplatRender.hlsl b/src/Aquarium.Engine/Render/Shaders/D3D12FractalSplatRender.hlsl index 00ccb46..5804fb9 100644 --- a/src/Aquarium.Engine/Render/Shaders/D3D12FractalSplatRender.hlsl +++ b/src/Aquarium.Engine/Render/Shaders/D3D12FractalSplatRender.hlsl @@ -217,16 +217,19 @@ SceneOut ResolveFractalSplat(FractalSplatVertexOut input, bool renderTransparent float opacity = transparentField ? saturate(edgeCoverage * edgeCoverage * (0.18 + reservoirConfidence * 0.32)) : saturate(edgeCoverage * (0.78 + reservoirConfidence * 0.22)); + float reservoirUpdatedFrame = min( + sdfResident ? sdf.validation.y : frameIndex, + min( + pbrResident ? pbr.validation.y : frameIndex, + radiosityResident ? radiosity.validation.y : frameIndex)); + float reservoirSampleAge = max(frameIndex - reservoirUpdatedFrame, 0.0); + float domainValidity = reservoirConfidence > 0.0 ? 1.0 : 0.0; SceneOut output; output.colorTravel = float4(litColor * opacity, min(input.travel - surfaceZ * input.worldRadius, farDistance + 1.0)); output.metadata = float4(FIELD_ID_FRACTAL_SPLAT_BASE, normal); output.control = float4(opacity, reservoirConfidence, transparentField ? splat.materialConfidence.z / 10.0 : saturate((sdfResident ? sdf.centerRadius.w : splat.centerRadius.w) * 40.0), 0.0); - output.reservoirGuide = float4( - sdfResident ? saturate(sdf.validation.x) : 0.0, - pbrResident ? saturate(pbr.validation.x) : 0.0, - radiosityResident ? saturate(radiosity.validation.x) : 0.0, - reservoirConfidence); + output.reservoirGuide = float4(reservoirConfidence, reservoirSampleAge, domainValidity, 0.0); output.depth = saturate(input.travel / max(farDistance, 0.0001)); return output; } diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 86f5ccb..fd874d1 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -206,3 +206,4 @@ {"timestamp":"2026-05-21T11:35:00+01:00","topic":"view-conditioned-reservoir-priority","lesson":"The first camera-conditioned reservoir pressure input is live. AquariumFractalReservoirField.PriorityFocus carries focus XY, radius, and strength from client/domain planning into D3D12 root constants. D3D12FractalReservoirCompute keeps full-refresh row sweeps direct, but under budget it samples four stochastic candidate row indices and prefers candidates near the focus while retaining exploration noise. Zyphos derives the focus from the selected spatial-domain camera target, and tools/Aquarium.Fractal.Receipt exposes --priority-focus; the local GTX 1070 smoke with 65,536 flame splats, 4,096 steady splat updates, 4,096 reservoir updates/pass, and focus 0,0,0.35,0.85 ran at 0.158 ms/frame / 6,331 FPS equivalent. The focus constants are four scalar cbuffer values, not a float4, so root constant offsets 9-12 remain unambiguous.","files":["src/Aquarium.Engine.Contracts/Render/AquariumRenderPlan.cs","src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Engine/Render/Shaders/D3D12FractalReservoirCompute.hlsl","src/Aquarium.Zyphos/ZyphosFractalTerrain.cs","src/Aquarium.Zyphos/ZyphosSceneBuilder.cs","tools/Aquarium.Fractal.Receipt/Program.cs","tests/Aquarium.Engine.Fractal.Tests/FractalReservoirFieldContractTests.cs","tests/Aquarium.Engine.Fractal.Tests/ZyphosFractalTerrainTests.cs","state/map.yaml","state/memory.json"],"source":"continued after global flame parity showed the real challenge is maintaining smooth images under movement and zoom by spending work on underrepresented visible regions"} {"timestamp":"2026-05-21T11:45:00+01:00","topic":"residual-to-focus-analyzer","lesson":"Visual parity now produces a tested reservoir-pressure suggestion. FractalHistogramResidualFocus estimates focus XY/radius/strength from positive reference-minus-candidate histogram residuals; matching histograms return zero focus. tools/Aquarium.Fractal.Receipt reports SuggestedPriorityFocus for each visual parity view. A GTX 1070 smoke receipt with 65,536 flame splats and 50k CPU reference samples in -2..2 scored 67.07% and suggested focus 0.544,-0.284,1.824,0.988, proving the diagnostic can emit a concrete next-frame pressure window instead of only a score.","files":["src/Aquarium.Engine.Fractal/Grammar/FractalHistogramResidualFocus.cs","tests/Aquarium.Engine.Fractal.Tests/FractalHistogramResidualFocusTests.cs","tools/Aquarium.Fractal.Receipt/Program.cs","state/map.yaml","state/memory.json"],"source":"continued after adding PriorityFocus so parity residuals could become actionable cache pressure instead of human-only visual diagnosis"} {"timestamp":"2026-05-21T11:55:00+01:00","topic":"adaptive-focus-receipt-loop","lesson":"The receipt harness can now close the first residual feedback loop over the same GPU-resident resources. --adaptive-focus requires warmup and readback, runs the warmup epoch, builds visual parity, applies the first view's suggested priority focus to subsequent measured frames, then reports the adaptive focus in the JSON/console receipt. On the local GTX 1070 mixed flame smoke, the previous non-adaptive setup scored 67.07%; adaptive focus suggested 0.516,-0.302 radius 1.794 strength 1 and measured 70.89% at 0.160 ms/frame. This is not final runtime architecture because it uses a blocking readback between epochs, but it proves feedback improves the cache target before building the delayed/GPU-side path.","files":["tools/Aquarium.Fractal.Receipt/Program.cs","state/map.yaml","state/memory.json"],"source":"continued from residual-to-focus analyzer into a measurable adaptive reservoir control loop"} +{"timestamp":"2026-05-21T12:05:00+01:00","topic":"fractal-splat-taa-guide-schema","lesson":"D3D12FractalSplatRender now writes the shared reservoir/TAA guide schema instead of leaking backend layer validation into resolver fields. The guide is x combined reservoir confidence, y sample age in frames from the oldest resident Form/Appearance/Transport row update, z domain validity, w invalidation code. This matches D3D12Post.hlsl expectations and docs/temporal-spatial-evidence-reservoir.md; the previous x/y/z = SDF/PBR/radiosity validation mapping made the resolver interpret PBR validation as sample age and radiosity validation as domain validity.","files":["src/Aquarium.Engine/Render/Shaders/D3D12FractalSplatRender.hlsl","state/map.yaml","state/memory.json"],"source":"continued TAA/reservoir integration after noticing the live guide buffer violated its own documented schema"} diff --git a/state/map.yaml b/state/map.yaml index eb20f0d..40cf252 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -153,6 +153,7 @@ renderer_state: - D3D12FractalReservoirCompute has an explicit flame 2D program mode for the proven FLAM3-style subset. FractalGpuProgramCompiler lowers flame rows into packed affine/variation program rows, and tools/Aquarium.Fractal.Receipt can run them with `--program-flame`. Flame mode now keeps 32-byte AquariumPackedFractalFlameState rows in a GPU UAV so touched splats advance persistent chaos-game state instead of replaying from the origin. Local GTX 1070 JWildfire selftest receipt after 8 full-population acquisition frames: 2,000,000 resident splats, 2,000,000 flame states, 2,000,000 first-slice Form/Appearance/Transport reservoirs each, steady 50,000 splat updates/frame, 15,000 reservoir updates/pass/frame, depth 8, 1.011 ms/frame, 988.8 FPS equivalent, 84.85% CPU-slice distribution parity, checksum 0xC633FADC3BD7E5BE. - Fractal reservoir update selection now accepts a four-scalar PriorityFocus window: focus XY, radius, and strength. Under budget, D3D12FractalReservoirCompute samples a few stochastic candidate rows and prefers rows near the focus while preserving random exploration; full-refresh passes still map directly over every row. Zyphos derives the focus from the selected camera/domain target so zoomed domains can pressure reservoir work toward the visible region instead of treating every resident splat as equally urgent. The receipt harness exposes the same pressure through `--priority-focus` for focused GPU tests. - The live GPU splat packet now carries a Form encoding tag in the existing material/confidence lane without changing the 80-byte stride. Flame-mode compute writes Density encoding; the visible fractal splat renderer uses two explicit graphics pipeline states over the same GPU-resident buffers: opaque signed-distance surface splats depth-test/write through D3D12FractalSurfaceSplatPS, while density/extinction splats run through D3D12FractalTransparentSplatPS with depth disabled and additive color-only blending. This is not full volume ray integration, but it makes depth/blend ownership explicit without adding a parallel transparent reservoir or buffer. + - Fractal splat render now writes the documented reservoir/TAA guide schema: x = combined reservoir confidence, y = sample age in frames, z = domain validity, w = invalidation code. Form/Appearance/Transport validation stays internal to the splat shader and no longer masquerades as guide-buffer age/validity. - The first visual parity receipt compares GPU flame splat XY histograms against the CPU flame oracle. With 250,000 GPU readback splats and 1,000,000 CPU reference samples in 128x128 bounds -8,-8,8,8, the mixed flame fixture scores 84.05% distribution parity at frame 1, 84.10% at frame 5, 84.20% at frame 20, and 84.24% after the 60-frame/10-warmup receipt, with cosine similarity around 0.9955. This is a stable sampler score, not proof of learned convergence; visual-error feedback is still future work. - View-conditioned visual parity now scores named camera windows instead of trusting one global histogram. For the depth-16 flame receipt, global -8..8 scores 97.09%, mid -1..1 scores 91.93%, close -0.5..0.5 scores 88.97%, and micro -0.25..0.25 scores 82.05% with 2,656 starved reference bins and 17.95% underrepresented mass. This is the current hard loss: the reservoir is not yet spending work based on camera-conditioned underrepresentation. - FractalHistogramResidualFocus is the first pure residual-to-priority seam: given reference and candidate histograms, it estimates a focus center/radius/strength from underrepresented probability mass. tools/Aquarium.Fractal.Receipt now reports this suggested focus for each visual parity view, turning parity failure into a concrete reservoir pressure input instead of a contact-sheet shrug. diff --git a/state/memory.json b/state/memory.json index 1da91e1..d93d985 100644 --- a/state/memory.json +++ b/state/memory.json @@ -112,6 +112,7 @@ "Use `scripts/fractal-flame-receipt.ps1` for the local CPU flame receipt. The default mixed linear/spherical/bubble fixture uses 8192 samples, 64 burn-in, 64x64 bounds -8,-8,8,8, seed 0x0BADC0DE, and checksum 0xAEB1C81B. Use `scripts/fractal-flame-reference-render.ps1` with a local `flam3-render` executable to produce external PPM image receipts under artifacts/fractal-flame-reference; Aquarium does not vendor Apophysis or FLAM3.", "FractalGpuProgramCompiler can lower the proven FLAM3-style flame subset into GPU program rows for D3D12FractalReservoirCompute's explicit flame 2D program mode. Flame mode owns a 32-byte AquariumPackedFractalFlameState UAV row per resident splat; touched rows advance persistent chaos-game state instead of replaying from the origin. The cache has two phases: full-population acquisition, then budgeted stochastic maintenance. On 2026-05-21 the GTX 1070 ran JWildfire FARender selftest.flame with 2,000,000 splats, 2,000,000 flame states, three 2,000,000-row first-slice Form/Appearance/Transport reservoir layers, 8 full acquisition frames, steady 50,000 splat updates/frame, 15,000 reservoir updates/pass/frame, depth 8, at 1.011 ms/frame / 988.8 FPS equivalent, 84.85% CPU-slice distribution parity, checksum 0xC633FADC3BD7E5BE. Without acquisition, the same steady budget scored only 32.64%; do not confuse a cold persistent cache with a bad sampler.", "The live GPU splat packet carries a Form encoding tag in an existing material/confidence lane so flame-mode compute can mark splats as Density without changing the 80-byte hot stride. D3D12FractalSplatRender now compiles separate surface and transparent graphics pipeline states over the same GPU-resident buffers: signed-distance surface claims depth-test/write as opaque geometry, while density/extinction claims use a depth-disabled additive color-only pass. This is a field-aware debug/consumption path, not full volume ray integration; do not add a second transparent reservoir or buffer unless a measured resolve need beats the shared packet invariant.", + "Fractal splat reservoir guide output must obey the shared TAA guide schema: x confidence, y sample age, z domain validity, w invalidation code. Do not pack Form/Appearance/Transport validation into guide x/y/z; those are backend layer diagnostics, not resolver semantics.", "The first visual parity metric compares GPU flame splat XY histograms against the local CPU flame oracle. With 250,000 GPU readback splats, 1,000,000 CPU reference samples, 128x128 bounds -8,-8,8,8, and the mixed FLAM3-style fixture, distribution score is 84.05% at frame 1, 84.10% at frame 5, 84.20% at frame 20, and 84.24% after the 60-frame/10-warmup receipt; cosine similarity stays about 0.9955. This is high distribution similarity but not learned convergence: the current reservoir path initializes splats and stochastically replaces them, without visual-error feedback or ReSTIR/MIS target correction yet.", "Global flame parity is not enough. View-conditioned parity now scores named viewport bounds and reports GPU/reference hits, starved reference bins, and underrepresented mass. First depth-16 GTX 1070 receipt with 250k GPU readback splats vs 1M CPU samples: global -8..8 scores 97.09%, mid -1..1 scores 91.93%, close -0.5..0.5 scores 88.97%, micro -0.25..0.25 scores 82.05% with 2,656 starved bins and 17.95% underrepresented mass. This proves the current reservoir is fast but not view-adaptive; next work needs camera-conditioned target weights and underrepresented-region feedback.", "FractalHistogramResidualFocus converts visual parity residuals into a tested focus window: underrepresented reference mass determines center, radius, and strength. tools/Aquarium.Fractal.Receipt prints the suggested focus per visual parity view so a bad contact sheet now yields a concrete reservoir-pressure input for the next adaptive loop.",