Give temporal resolve specular teeth

This commit is contained in:
Meta Vens 2026-05-13 04:46:34 +01:00
commit ea97a2a2d2
6 changed files with 61 additions and 28 deletions

View file

@ -63,10 +63,13 @@ is allowed to quietly solve a bad light story.
## Temporal Diagnostics
The temporal resolver is documented in `docs/tsr-inspired-taa-spec.md`. The live
frame keeps color, metadata, and control history for inspection. Projection
jitter is disabled and final presentation favors current truth over stale
history. Dormant event lanes are not preserved without a producer and pass
contract.
frame keeps color, metadata, and control history. Projection jitter uses a small
Halton sequence, and final presentation blends validated history. SDF object
highlights get a narrow hot-current history path so transient specular spikes
can be damped without relaxing travel, field, or normal validation. Bloom is
attenuated when the resolved scene has damped a much hotter current sample, so
transient fireflies do not keep blooming through the current-frame bloom path.
Dormant event lanes are not preserved without a producer and pass contract.
Debug modes:

View file

@ -241,24 +241,22 @@ Current Gate 3J implementation:
- history/age/weight debug modes remain useful diagnostics, but stale Grid color
history no longer drives the final visible Grid
Current Gate 3L implementation:
Current Gate 3L/3M implementation:
- projection jitter is scaled to zero for the live frame
- visible jitter on Self/planet surfaces means the resolve is not yet hiding the
sample offset well enough, so jitter stays disabled until opaque and Grid
paths both prove stable
- the abandoned unjittered Grid retrace was removed; with jitter disabled, Grid
analytic color reconstructs from the existing current hit instead of solving
the surface twice
Current Gate 3M implementation:
- final presentation no longer blends temporal color history for any surface
- the history, metadata, and control ping-pongs remain for debug views and for
future stochastic-event work
- mode `0` is current-frame color after analytic Grid reconstruction and
tonemapping; modes `2` through `4` show what the diagnostic temporal path
would have sampled, aged, and weighted
- projection jitter uses a small Halton sequence, currently scaled below half a
pixel so the resolve gets sample diversity without visible whole-frame wobble
- current and previous jitter are both uploaded through frame constants; previous
history projection removes the previous jitter before sampling history
- final presentation blends validated temporal color history in mode `0`
- SDF object highlights have a narrow hot-current path: when the current SDF
sample is much brighter than valid reprojected history, color rejection is
relaxed so history can damp transient specular fireflies while travel, field,
normal, coverage, and coverage-continuity validation still apply
- bloom presentation is attenuated when the resolved scene luminance is much
lower than the raw current scene luminance, so current-frame fireflies do not
keep blooming after temporal history has damped the underlying scene color
- modes `2` through `4` show the sampled history, accepted history age, and
history weight
Still missing:

View file

@ -136,6 +136,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
private Vector3 previousCameraPosition;
private Vector2 previousViewCenter;
private Vector2 previousCursorWorld;
private Vector2 previousJitterPixels;
private float previousViewRadius = 0.001f;
private float previousTimeSeconds;
private D3D12HeightFieldBrushConstants heightFieldBrushConstants;
@ -453,6 +454,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
var viewOrigin = new Vector3(frame.View.Center.X, frame.View.Center.Y, 0.0f);
var farDistance = Vector3.Distance(frame.CameraPosition, viewOrigin) + MathF.Max(frame.View.Radius, 0.001f);
var jitterPixels = TemporalJitterPixels(temporalFrameIndex);
if (temporalFrameIndex == 0)
{
previousCameraPosition = frame.CameraPosition;
@ -460,6 +462,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
previousCursorWorld = frame.CursorWorld;
previousViewRadius = frame.View.Radius;
previousTimeSeconds = frame.TimeSeconds;
previousJitterPixels = jitterPixels;
}
CopySceneState(frame.Scene);
@ -475,8 +478,8 @@ public sealed class D3D12Renderer : IAquariumRenderer
previousCameraPosition,
previousViewRadius,
previousViewCenter,
Vector2.Zero,
Vector2.Zero,
jitterPixels,
previousJitterPixels,
RenderDebugMode,
settings.SceneExposure,
settings.BloomIntensity,
@ -563,11 +566,34 @@ public sealed class D3D12Renderer : IAquariumRenderer
previousCursorWorld = frame.CursorWorld;
previousViewRadius = frame.View.Radius;
previousTimeSeconds = frame.TimeSeconds;
previousJitterPixels = jitterPixels;
hasPresentedReadyFrame = true;
temporalFrameIndex++;
frameIndex = (int)swapChain.CurrentBackBufferIndex;
}
private static Vector2 TemporalJitterPixels(int index)
{
const float scale = 0.42f;
return new Vector2(
(Halton(index + 1, 2) - 0.5f) * scale,
(Halton(index + 1, 3) - 0.5f) * scale);
}
private static float Halton(int index, int basis)
{
var result = 0.0f;
var fraction = 1.0f / basis;
while (index > 0)
{
result += fraction * (index % basis);
index /= basis;
fraction /= basis;
}
return result;
}
private bool PipelinesReady =>
heightFieldBasePipelineState is not null
&& heightFieldBrushPipelineState is not null

View file

@ -211,9 +211,9 @@ float3 bloomColorAt(float2 uv)
bloomTexture2.SampleLevel(sourceSampler, uv, 0.0).rgb * 0.24;
}
float3 presentColor(float3 scene, float2 uv)
float3 presentColor(float3 scene, float2 uv, float bloomScale)
{
float3 bloom = bloomColorAt(uv);
float3 bloom = bloomColorAt(uv) * bloomScale;
float3 exposedScene = scene * max(exposure, 0.001);
return aces(exposedScene + bloom * bloomIntensity + luminance(bloom) * bloomVeilIntensity);
}
@ -330,6 +330,10 @@ ResolveOut D3D12ResolvePS(VertexOut input)
float3 clampedHistory = clamp(previous.rgb, neighborhoodMin, neighborhoodMax);
float colorDelta = length(clampedHistory - currentColor);
float colorWeight = 1.0 - smoothstep(0.18, 1.2, colorDelta);
float currentLuma = luminance(currentColor);
float historyLuma = luminance(clampedHistory);
float hotSdfCurrent = currentFieldId >= FIELD_ID_SDF_OBJECT_BASE ? smoothstep(1.0, 5.0, currentLuma - historyLuma) : 0.0;
colorWeight = max(colorWeight, hotSdfCurrent * 0.82);
float coverageWeight = smoothstep(0.02, 0.55, currentCoverage);
float coverageContinuityWeight = 1.0 - smoothstep(0.10, 0.50, abs(previousCoverage - currentCoverage));
float historyConfidence = smoothstep(0.0, 6.0, previousHistoryAge);
@ -344,7 +348,8 @@ ResolveOut D3D12ResolvePS(VertexOut input)
float combinedHistoryWeight = historyWeight;
float combinedHistoryAge = historyAge;
float3 resolved = lerp(currentColor, historyColor, combinedHistoryWeight);
float3 finalColor = presentColor(resolved, input.uv);
float bloomStability = saturate((luminance(resolved) + 0.25) / max(luminance(currentColor) + 0.25, 0.0001));
float3 finalColor = presentColor(resolved, input.uv, bloomStability);
if (renderDebugMode > 0.5 && renderDebugMode < 1.5)
{
finalColor = aces(rawCurrentColor * max(exposure, 0.001));

View file

@ -93,3 +93,4 @@
{"timestamp":"2026-05-13T04:19:17+01:00","topic":"self-void-core-fresnel","lesson":"Self's core surface should not fight multiple core band materials or pulse its sphere radius. Keep the core radius stable, retain one gold lattice band, and shade the core as a black void with a simple golden Fresnel rim outside the shared PBR path while the surrounding rails/gates continue to use PBR.","files":["src/Aquarium.Epiphany/Shaders/D3D12SelfBody.hlsl","docs/epiphany-agent-sdf-visual-language.md","state/memory.json","state/evidence.jsonl"],"source":"user visual correction asking for a void core edge-lit with gold"}
{"timestamp":"2026-05-13T04:26:58+01:00","topic":"self-band-rails-gate-emission","lesson":"Self's orrery rails should be thicker readable PBR bands, not hairline emitters that create fireflies. Reserve bloom-driving emission for gate nodes and the custom void-core Fresnel rim; rail and core-band visibility should come from material contrast and geometry thickness.","files":["src/Aquarium.Epiphany/Shaders/D3D12SelfBody.hlsl","docs/epiphany-agent-sdf-visual-language.md","state/memory.json","state/evidence.jsonl"],"source":"user final visual tuning request"}
{"timestamp":"2026-05-13T04:32:09+01:00","topic":"self-compact-triple-band-gates","lesson":"Self gate material should mark compact lattice nodes, not every pairwise rail crossing. Pairwise gate fields stretch along shallow rail intersections and produce flat material slabs that overtake the rings. Require all three angular bands to agree for gate distance so shallow overlaps remain rail material.","files":["src/Aquarium.Epiphany/Shaders/D3D12SelfBody.hlsl","docs/epiphany-agent-sdf-visual-language.md","state/memory.json","state/evidence.jsonl"],"source":"user screenshot showed flat gate-colored slabs at shallow ring intersections"}
{"timestamp":"2026-05-13T04:41:09+01:00","topic":"temporal-jitter-specular-fireflies","lesson":"Projection jitter was disabled because an earlier implementation made the whole frame visibly wobble. Re-enable it as a small sub-half-pixel Halton sequence with previous-jitter tracking, give the resolver a narrow SDF hot-current path so validated history can damp transient specular fireflies without relaxing travel/field/normal/coverage validation, and attenuate bloom when resolved scene luminance is lower than the raw current spike so current-frame bloom does not bypass TAA.","files":["src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Engine/Render/Shaders/D3D12Post.hlsl","docs/hlsl-renderer.md","docs/tsr-inspired-taa-spec.md","state/memory.json","state/evidence.jsonl"],"source":"user asked to give TAA teeth for Self rail highlights"}

View file

@ -72,7 +72,7 @@
"Specular IBL uses the Studio2 PMREM cubemap baked at 512px per face: bake HDR latlong radiance into roughness-indexed cubemap mips, load it as a D3D12 TextureCube, and sample it by reflection direction plus roughness LOD. Convert Aquarium's Z-up world directions to cubemap Y-up directions before sampling: (x, z, y). Grid mirror reflection samples mip 0 directly; body material reflections use roughness LOD. Keep this as material reflection response, not a replacement for diegetic body light authority.",
"Diffuse IBL uses a separate Studio2 irradiance cubemap, not blurred GGX PMREM. Bake it by cosine-weighted hemisphere convolution storing irradiance integral Li*cos(theta) dOmega, then shade non-metal bodies with Fresnel-gated diffuse share times baseColor/PI times irradiance.",
"HDR/PBR presentation follows research/rendering/hdr-pbr-presentation.md: scene-linear lighting, explicit exposure, pre-tonemap bloom/veil, then display transform.",
"Current temporal diagnostics are for inspection. With projection jitter disabled, final presentation should not blindly trust temporal color history until a real temporal contract earns authority. Do not preserve dormant full-frame event/history lanes without an active producer and consumer contract."
"Current temporal resolve uses a small subpixel Halton jitter, validated color/metadata/control history, a narrow SDF hot-current path that lets valid history damp transient specular fireflies without relaxing travel/field/normal/coverage validation, and bloom attenuation when resolved scene luminance is lower than the raw current spike. Do not preserve dormant full-frame event/history lanes without an active producer and consumer contract."
],
"text_and_ui": [
"Overlay text uses DirectWrite/Direct2D after scene rendering. It is crisp final-pixel UI for debug surfaces, terminals, inspectors, and splash/status text.",