diff --git a/docs/hlsl-renderer.md b/docs/hlsl-renderer.md index d7f8e24..d1247eb 100644 --- a/docs/hlsl-renderer.md +++ b/docs/hlsl-renderer.md @@ -191,6 +191,10 @@ background Grid accumulation. Grid retention is also pulled back from `0.975` to Gate 3H makes Grid temporal coverage line support rather than broad overlay alpha, so history age/weight cannot survive as smoke across low-alpha field tint. Grid retention is pulled back again to `0.90`. +Gate 3I reconstructs analytic Grid overlay color in the resolve pass for Grid +pixels. Raw scene debug mode can still show stochastic hit/miss noise; final +resolve uses the analytic current estimate plus validated history instead of +averaging binary coverage like a tiny broken casino. Temporal debug modes are available in the running window: `F1` cycles modes and number keys `0` through `4` select them directly. Mode `0` is final resolve, diff --git a/docs/tsr-inspired-taa-spec.md b/docs/tsr-inspired-taa-spec.md index 0a36b33..24d916b 100644 --- a/docs/tsr-inspired-taa-spec.md +++ b/docs/tsr-inspired-taa-spec.md @@ -228,6 +228,15 @@ Current Gate 3H implementation: - Grid max history weight is reduced again to `0.90` with a lower fresh-history scale for crisper line response +Current Gate 3I implementation: + +- Grid resolve reconstructs the analytic Grid overlay at the current world hit + and uses premultiplied overlay color as the current color estimate +- the scene pass may still use stochastic coverage, but the temporal resolver + no longer treats the current binary hit/miss sample as the true radiance +- debug mode `1` can remain noisy because it shows the raw stochastic scene; + mode `0` should now use the analytic Grid estimate plus validated history + This is intentionally still a surface/stochastic coverage contract. It prepares the resolver for volumetrics without lying that a single hit depth describes a whole participating medium. diff --git a/src/Aquarium.Engine/Render/Shaders/Aquarium.hlsl b/src/Aquarium.Engine/Render/Shaders/Aquarium.hlsl index cb26739..c768b19 100644 --- a/src/Aquarium.Engine/Render/Shaders/Aquarium.hlsl +++ b/src/Aquarium.Engine/Render/Shaders/Aquarium.hlsl @@ -1399,6 +1399,15 @@ ResolveOut AquariumResolvePS(VertexOut input) float currentReactive = saturate(currentControl.x); float currentCoverage = saturate(currentControl.y); float currentMediumOpacity = saturate(currentControl.z); + bool currentIsGrid = abs(currentFieldId - FIELD_ID_GRID) < 0.25; + + if (currentIsGrid && currentTravel <= farDistance) + { + float3 currentRay = rayDirectionForPixel(pixel, jitterPixels, cameraPosition, gridCenter); + float3 worldPosition = cameraPosition + currentRay * currentTravel; + float4 gridOverlay = shadeGridOverlay(worldPosition); + currentColor = gridOverlay.rgb * saturate(gridOverlay.a) + float3(0.001, 0.003, 0.004); + } float historyWeight = 0.0; float historyAge = 0.0; diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 88493e8..d07181a 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -29,3 +29,4 @@ {"area":"renderer/taa","lesson":"TAA Gate 3F gives stochastic Grid coverage a high-retention temporal blend. Coverage and reactive strength must not reduce Grid history authority because low coverage is exactly where temporal accumulation is required; Grid now validates with travel, field, normal, coverage continuity, medium continuity, and age while using a higher max history weight than opaque surfaces.","files":["docs/tsr-inspired-taa-spec.md","docs/hlsl-renderer.md","src/Aquarium.Engine/Render/Shaders/Aquarium.hlsl","state/memory.json","state/scratch.md"],"verification":["dotnet build Aquarium.Engine.slnx",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4"],"ts":"2026-05-08"} {"area":"renderer/taa","lesson":"TAA Gate 3G fixes foreground glow leaking into background Grid history. Identity/control buffers are now point-loaded and field ids use exact equality, while Grid history color uses nearest identity-aligned sampling instead of bilinear color sampling. Grid max history weight was also reduced from 0.975 to 0.94 to keep linework less over-smoothed.","files":["docs/tsr-inspired-taa-spec.md","docs/hlsl-renderer.md","src/Aquarium.Engine/Render/Shaders/Aquarium.hlsl","state/memory.json","state/scratch.md"],"verification":["dotnet build Aquarium.Engine.slnx",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4"],"ts":"2026-05-08"} {"area":"renderer/taa","lesson":"TAA Gate 3H fixes Grid history smoke by separating temporal support from broad overlay alpha. Grid control coverage now stores line/contour/field-line support, not field tint alpha; current support gates Grid history, broad tint no longer keeps age alive across the surface, and Grid retention is reduced to 0.90 for crisper response.","files":["docs/tsr-inspired-taa-spec.md","docs/hlsl-renderer.md","src/Aquarium.Engine/Render/Shaders/Aquarium.hlsl","state/memory.json","state/scratch.md"],"verification":["dotnet build Aquarium.Engine.slnx",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4"],"ts":"2026-05-08"} +{"area":"renderer/taa","lesson":"TAA Gate 3I stops using raw stochastic Grid hit/miss color as the current radiance truth. For Grid pixels the resolve reconstructs the analytic overlay at the current world hit and uses premultiplied overlay color as the current estimate; history then stabilizes the estimate instead of trying to recover alpha from binary noise alone.","files":["docs/tsr-inspired-taa-spec.md","docs/hlsl-renderer.md","src/Aquarium.Engine/Render/Shaders/Aquarium.hlsl","state/memory.json","state/scratch.md"],"verification":["dotnet build Aquarium.Engine.slnx",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4"],"ts":"2026-05-08"} diff --git a/state/memory.json b/state/memory.json index bf83c4e..3ca11b6 100644 --- a/state/memory.json +++ b/state/memory.json @@ -58,6 +58,7 @@ "Stochastic Grid TAA needs high-retention history and must not reduce history weight just because current coverage is low. Low coverage is exactly where temporal accumulation has to do the work; coverage belongs in continuity validation, not as an authority penalty.", "TAA identity/control buffers must be point-loaded, not linearly sampled. Field ids are identities, not colors; interpolating them at silhouettes lets foreground solids contaminate background Grid history. Grid history color should use identity-aligned nearest sampling to avoid bright foreground bleed.", "Grid temporal coverage must mean current line/contour/field-line support, not broad overlay alpha. Broad low-alpha tint can render, but it must not keep history age alive across the Grid surface or stale stochastic hits billow into smoke.", + "Grid TAA must not use the raw stochastic hit/miss scene color as the current radiance truth. The resolve should reconstruct analytic Grid overlay color at the current world hit and use premultiplied color as the current estimate, then use history for stability rather than reconstructing alpha from binary noise alone.", "Temporal debug views are live keys: F1 cycles, 0 final, 1 raw current scene, 2 reprojected history, 3 history age, 4 history weight. Use these before guessing whether TAA is sampling, validating, or presenting the wrong signal.", "Bruneton-style atmospheric scattering is the later sky/planet solution, not the first Grid fog pass. Use LUTs, explicit texture mappings, and unit-tested physical terms when Aquarium reaches ground-to-space atmosphere.", "GigaVoxels-style ray-guided sparse bricks are only for large sparse field/world storage. Do not turn early fog into a monolithic persistent volume cache." diff --git a/state/scratch.md b/state/scratch.md index 9753f44..f72e347 100644 --- a/state/scratch.md +++ b/state/scratch.md @@ -85,3 +85,7 @@ prototype integrated along the camera ray before surface composition. - Temporal Gate 3H: Grid temporal coverage is line support only, not broad overlay alpha. Current support gates Grid history so old stochastic hits do not survive as fine smoke across the surface. +- Temporal Gate 3I: Grid resolve reconstructs analytic overlay color at the + current world hit and uses premultiplied color as the current estimate. Raw + scene debug mode may still be noisy; final no longer treats stochastic + hit/miss color as ground truth.