Prevent foreground bleed into Grid history
This commit is contained in:
parent
f23f6a4ca8
commit
afc52abf7e
6 changed files with 58 additions and 9 deletions
|
|
@ -184,6 +184,10 @@ field, travel, normal, coverage, reactive, and age checks.
|
|||
Gate 3F gives that stochastic Grid path a higher-retention history blend and no
|
||||
coverage/reactive penalty, because low coverage is the signal that needs
|
||||
temporal accumulation rather than the signal that should lose history.
|
||||
Gate 3G point-loads identity/control history and nearest-loads Grid history
|
||||
color, preventing bright foreground silhouettes from bilinearly bleeding into
|
||||
background Grid accumulation. Grid retention is also pulled back from `0.975` to
|
||||
`0.94` to keep lines less anesthetized.
|
||||
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -207,6 +207,16 @@ Current Gate 3F implementation:
|
|||
- debug mode `2` should now show a smoother history signal than raw scene mode
|
||||
`1` when the Grid is stable
|
||||
|
||||
Current Gate 3G implementation:
|
||||
|
||||
- identity/control buffers are point-loaded, not linearly sampled
|
||||
- field id equality is exact after point-loading, so Grid/Self/planet boundaries
|
||||
hard-reject mismatched history
|
||||
- Grid history color is sampled with the same nearest pixel used for metadata so
|
||||
bright foreground silhouettes do not bilinearly bleed into background Grid
|
||||
history
|
||||
- Grid max history weight is reduced from the too-soft `0.975` to `0.94`
|
||||
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -1316,6 +1316,36 @@ float3 sampleCurrentScene(float2 uv)
|
|||
return currentSceneTexture.SampleLevel(gridSampler, uv, 0.0).rgb;
|
||||
}
|
||||
|
||||
int2 pixelFromUv(float2 uv)
|
||||
{
|
||||
return clamp((int2)floor(uv * resolution), int2(0, 0), (int2)resolution - int2(1, 1));
|
||||
}
|
||||
|
||||
float4 sampleCurrentMetadata(float2 uv)
|
||||
{
|
||||
return currentSceneMetadataTexture.Load(int3(pixelFromUv(uv), 0));
|
||||
}
|
||||
|
||||
float4 sampleCurrentControl(float2 uv)
|
||||
{
|
||||
return currentSceneControlTexture.Load(int3(pixelFromUv(uv), 0));
|
||||
}
|
||||
|
||||
float4 sampleNearestHistoryColor(float2 uv)
|
||||
{
|
||||
return historyTexture.Load(int3(pixelFromUv(uv), 0));
|
||||
}
|
||||
|
||||
float4 sampleNearestHistoryMetadata(float2 uv)
|
||||
{
|
||||
return historyMetadataTexture.Load(int3(pixelFromUv(uv), 0));
|
||||
}
|
||||
|
||||
float4 sampleNearestHistoryControl(float2 uv)
|
||||
{
|
||||
return historyControlTexture.Load(int3(pixelFromUv(uv), 0));
|
||||
}
|
||||
|
||||
void currentNeighborhood(float2 uv, out float3 neighborhoodMin, out float3 neighborhoodMax)
|
||||
{
|
||||
float2 texel = 1.0 / resolution;
|
||||
|
|
@ -1350,8 +1380,8 @@ ResolveOut AquariumResolvePS(VertexOut input)
|
|||
float4 current = currentSceneTexture.SampleLevel(gridSampler, input.uv, 0.0);
|
||||
float currentTravel = current.a;
|
||||
float3 currentColor = current.rgb;
|
||||
float4 currentMetadata = currentSceneMetadataTexture.SampleLevel(gridSampler, input.uv, 0.0);
|
||||
float4 currentControl = currentSceneControlTexture.SampleLevel(gridSampler, input.uv, 0.0);
|
||||
float4 currentMetadata = sampleCurrentMetadata(input.uv);
|
||||
float4 currentControl = sampleCurrentControl(input.uv);
|
||||
float currentFieldId = currentMetadata.x;
|
||||
float3 currentNormal = currentMetadata.yzw;
|
||||
float currentReactive = saturate(currentControl.x);
|
||||
|
|
@ -1370,11 +1400,12 @@ ResolveOut AquariumResolvePS(VertexOut input)
|
|||
|
||||
if (all(previousUv >= 0.0) && all(previousUv <= 1.0))
|
||||
{
|
||||
float4 previous = historyTexture.SampleLevel(gridSampler, previousUv, 0.0);
|
||||
float4 previousMetadata = historyMetadataTexture.SampleLevel(gridSampler, previousUv, 0.0);
|
||||
float4 previousControl = historyControlTexture.SampleLevel(gridSampler, previousUv, 0.0);
|
||||
float previousTravel = previous.a;
|
||||
float4 previousMetadata = sampleNearestHistoryMetadata(previousUv);
|
||||
float previousFieldId = previousMetadata.x;
|
||||
bool isGridField = abs(currentFieldId - FIELD_ID_GRID) < 0.25;
|
||||
float4 previous = isGridField ? sampleNearestHistoryColor(previousUv) : historyTexture.SampleLevel(gridSampler, previousUv, 0.0);
|
||||
float4 previousControl = sampleNearestHistoryControl(previousUv);
|
||||
float previousTravel = previous.a;
|
||||
float3 previousNormal = previousMetadata.yzw;
|
||||
float previousCoverage = saturate(previousControl.y);
|
||||
float previousMediumOpacity = saturate(previousControl.z);
|
||||
|
|
@ -1383,8 +1414,7 @@ ResolveOut AquariumResolvePS(VertexOut input)
|
|||
float travelDelta = abs(previousTravel - expectedPreviousTravel);
|
||||
float travelTolerance = max(0.045, expectedPreviousTravel * 0.018);
|
||||
float travelWeight = 1.0 - smoothstep(travelTolerance, travelTolerance * 4.0, travelDelta);
|
||||
float fieldWeight = abs(previousFieldId - currentFieldId) < 0.25 ? 1.0 : 0.0;
|
||||
bool isGridField = abs(currentFieldId - FIELD_ID_GRID) < 0.25;
|
||||
float fieldWeight = abs(previousFieldId - currentFieldId) < 0.001 ? 1.0 : 0.0;
|
||||
float normalWeight = 0.0;
|
||||
if (dot(previousNormal, previousNormal) > 0.01 && dot(currentNormal, currentNormal) > 0.01)
|
||||
{
|
||||
|
|
@ -1405,7 +1435,7 @@ ResolveOut AquariumResolvePS(VertexOut input)
|
|||
float surfaceValidationWeight = travelWeight * colorWeight * fieldWeight * normalWeight * reactiveWeight * coverageWeight * coverageContinuityWeight * mediumContinuityWeight;
|
||||
float gridValidationWeight = travelWeight * fieldWeight * normalWeight * coverageContinuityWeight * mediumContinuityWeight;
|
||||
float validationWeight = isGridField ? gridValidationWeight : surfaceValidationWeight;
|
||||
float maxHistoryWeight = isGridField ? 0.975 : 0.82;
|
||||
float maxHistoryWeight = isGridField ? 0.94 : 0.82;
|
||||
float freshHistoryScale = isGridField ? 0.72 : 0.35;
|
||||
|
||||
historyColor = clampedHistory;
|
||||
|
|
|
|||
|
|
@ -27,3 +27,4 @@
|
|||
{"area":"renderer/debug","lesson":"Temporal debugging must be visible in the running window, not hidden behind relaunch-only command flags. F1 cycles render debug modes and 0-4 select final, raw current scene, reprojected history, history age, and history weight, making it possible to prove whether the presented frame is resolved and whether history is alive.","files":["docs/tsr-inspired-taa-spec.md","docs/hlsl-renderer.md","src/Aquarium.Engine/AquariumHost.cs","src/Aquarium.Engine.Contracts/Input/InputState.cs","src/Aquarium.Engine/Platform/Win32Window.cs","src/Aquarium.Engine/Render/D3D11Renderer.cs","src/Aquarium.Engine/Render/DirectWriteOverlay.cs","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":"dev-loop/reload","lesson":"dev-watch must not only classify source changes; it must also verify the recorded script-owned process is alive. If the visible/headless PID recorded by dev-reload is gone or no longer belongs to the recorded slot, the watcher relaunches from a fresh slot. The watch fingerprint also includes scripts/*.ps1 so script changes match the documented restart-owned contract.","files":["scripts/dev-watch.ps1","README.md","state/memory.json","state/scratch.md"],"verification":["dotnet build Aquarium.Engine.slnx",".\\scripts\\dev-watch.ps1 -Headless -Once -IntervalMilliseconds 10 -DebounceMilliseconds 10 -RetainSlots 4"],"ts":"2026-05-08"}
|
||||
{"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"}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@
|
|||
"TAA travel validation must compare previous history travel to the reprojected previous-world point's distance from the previous camera. Comparing previous travel directly to current travel falsely rejects stable history during camera motion.",
|
||||
"Stochastic Grid TAA must not use opaque-surface neighborhood color clamp or current-frame color-delta rejection. A dither miss makes the current color look like background; Grid history should validate through field/travel/normal/coverage/reactive/age instead.",
|
||||
"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.",
|
||||
"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."
|
||||
|
|
|
|||
|
|
@ -79,3 +79,6 @@ prototype integrated along the camera ray before surface composition.
|
|||
- Temporal Gate 3F: Grid stochastic coverage now uses high-retention history
|
||||
without coverage/reactive authority penalties. Coverage remains a continuity
|
||||
signal, not a reason to throw away the accumulation low-alpha lines require.
|
||||
- Temporal Gate 3G: identity/control buffers are point-loaded and Grid history
|
||||
color uses nearest identity-aligned sampling. This prevents foreground glow
|
||||
from bilinearly bleeding into background Grid history at silhouettes.
|
||||
|
|
|
|||
Loading…
Reference in a new issue