Add live temporal debug views
This commit is contained in:
parent
2dd6da3bac
commit
d13784328f
11 changed files with 153 additions and 7 deletions
|
|
@ -182,6 +182,12 @@ Gate 3E gives stochastic Grid history its own validation path: it bypasses
|
|||
opaque-surface neighborhood color clamp/color-delta rejection while still using
|
||||
field, travel, normal, coverage, reactive, and age checks.
|
||||
|
||||
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,
|
||||
`1` is raw current scene, `2` is the reprojected history sample, `3` is history
|
||||
age, and `4` is history weight. The startup mode can still be set with
|
||||
`--render-debug` or `AQUARIUM_RENDER_DEBUG_MODE`.
|
||||
|
||||
It deliberately does not pretend to solve general non-rigid field velocity,
|
||||
volumetric history, or history resurrection yet.
|
||||
|
||||
|
|
|
|||
|
|
@ -214,3 +214,13 @@ Still missing:
|
|||
- flicker analysis for high-frequency linework and stochastic coverage
|
||||
- history resurrection for reappearing stable details
|
||||
- debug visualizations for rejection, clamp, velocity, travel, and history age
|
||||
|
||||
Current debug view controls:
|
||||
|
||||
- `F1` cycles temporal debug modes in the running window
|
||||
- `0` final resolved color
|
||||
- `1` raw current scene color
|
||||
- `2` reprojected history color used by the resolver
|
||||
- `3` accepted history age
|
||||
- `4` history weight
|
||||
- `--render-debug` and `AQUARIUM_RENDER_DEBUG_MODE` set the startup mode
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace Aquarium.Engine.Input;
|
|||
public sealed class InputState
|
||||
{
|
||||
private readonly HashSet<KeyCode> downKeys = [];
|
||||
private readonly HashSet<KeyCode> pressedKeys = [];
|
||||
|
||||
public Vector2 MousePosition { get; private set; }
|
||||
|
||||
|
|
@ -18,10 +19,13 @@ public sealed class InputState
|
|||
|
||||
public bool IsKeyDown(KeyCode key) => downKeys.Contains(key);
|
||||
|
||||
public bool IsKeyPressed(KeyCode key) => pressedKeys.Contains(key);
|
||||
|
||||
public void BeginFrame()
|
||||
{
|
||||
MouseDelta = Vector2.Zero;
|
||||
WheelDelta = 0.0f;
|
||||
pressedKeys.Clear();
|
||||
}
|
||||
|
||||
public void SetMousePosition(Vector2 position)
|
||||
|
|
@ -52,6 +56,11 @@ public sealed class InputState
|
|||
{
|
||||
if (isDown)
|
||||
{
|
||||
if (!downKeys.Contains(key))
|
||||
{
|
||||
pressedKeys.Add(key);
|
||||
}
|
||||
|
||||
downKeys.Add(key);
|
||||
}
|
||||
else
|
||||
|
|
@ -73,4 +82,10 @@ public enum KeyCode
|
|||
A,
|
||||
S,
|
||||
D,
|
||||
Digit0,
|
||||
Digit1,
|
||||
Digit2,
|
||||
Digit3,
|
||||
Digit4,
|
||||
RenderDebugCycle,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ public static class AquariumHost
|
|||
window.ClientWidth,
|
||||
window.ClientHeight,
|
||||
ParseShaderPath(args),
|
||||
ParseRenderDebugMode(args),
|
||||
body => window.PaintSplash("Aquarium", body));
|
||||
|
||||
var frameClock = Stopwatch.StartNew();
|
||||
|
|
@ -43,6 +44,7 @@ public static class AquariumHost
|
|||
lastFrame = now;
|
||||
|
||||
runtimeLoader.Update(deltaSeconds, input);
|
||||
ApplyRendererDebugInput(renderer, input);
|
||||
renderer.Render(runtimeLoader.Runtime.Frame);
|
||||
|
||||
if (runtime.Options.Headless && ++frames >= 2)
|
||||
|
|
@ -114,4 +116,50 @@ public static class AquariumHost
|
|||
|
||||
return Environment.GetEnvironmentVariable("AQUARIUM_LIVE_RELOAD_POINTER");
|
||||
}
|
||||
|
||||
private static int ParseRenderDebugMode(IReadOnlyCollection<string> args)
|
||||
{
|
||||
var values = args.ToArray();
|
||||
for (var index = 0; index < values.Length - 1; index++)
|
||||
{
|
||||
if (string.Equals(values[index], "--render-debug", StringComparison.OrdinalIgnoreCase)
|
||||
&& int.TryParse(values[index + 1], out var mode))
|
||||
{
|
||||
return mode;
|
||||
}
|
||||
}
|
||||
|
||||
return int.TryParse(Environment.GetEnvironmentVariable("AQUARIUM_RENDER_DEBUG_MODE"), out var environmentMode)
|
||||
? environmentMode
|
||||
: 0;
|
||||
}
|
||||
|
||||
private static void ApplyRendererDebugInput(D3D11Renderer renderer, InputState input)
|
||||
{
|
||||
if (input.IsKeyPressed(KeyCode.RenderDebugCycle))
|
||||
{
|
||||
renderer.CycleRenderDebugMode();
|
||||
}
|
||||
|
||||
if (input.IsKeyPressed(KeyCode.Digit0))
|
||||
{
|
||||
renderer.RenderDebugMode = 0;
|
||||
}
|
||||
else if (input.IsKeyPressed(KeyCode.Digit1))
|
||||
{
|
||||
renderer.RenderDebugMode = 1;
|
||||
}
|
||||
else if (input.IsKeyPressed(KeyCode.Digit2))
|
||||
{
|
||||
renderer.RenderDebugMode = 2;
|
||||
}
|
||||
else if (input.IsKeyPressed(KeyCode.Digit3))
|
||||
{
|
||||
renderer.RenderDebugMode = 3;
|
||||
}
|
||||
else if (input.IsKeyPressed(KeyCode.Digit4))
|
||||
{
|
||||
renderer.RenderDebugMode = 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,12 @@ public sealed class Win32Window : IDisposable
|
|||
private const int VK_A = 0x41;
|
||||
private const int VK_S = 0x53;
|
||||
private const int VK_D = 0x44;
|
||||
private const int VK_0 = 0x30;
|
||||
private const int VK_1 = 0x31;
|
||||
private const int VK_2 = 0x32;
|
||||
private const int VK_3 = 0x33;
|
||||
private const int VK_4 = 0x34;
|
||||
private const int VK_F1 = 0x70;
|
||||
private const int WHEEL_DELTA = 120;
|
||||
|
||||
private readonly WndProc windowProcedure;
|
||||
|
|
@ -613,6 +619,24 @@ public sealed class Win32Window : IDisposable
|
|||
case VK_D:
|
||||
input.SetKey(KeyCode.D, isDown);
|
||||
break;
|
||||
case VK_0:
|
||||
input.SetKey(KeyCode.Digit0, isDown);
|
||||
break;
|
||||
case VK_1:
|
||||
input.SetKey(KeyCode.Digit1, isDown);
|
||||
break;
|
||||
case VK_2:
|
||||
input.SetKey(KeyCode.Digit2, isDown);
|
||||
break;
|
||||
case VK_3:
|
||||
input.SetKey(KeyCode.Digit3, isDown);
|
||||
break;
|
||||
case VK_4:
|
||||
input.SetKey(KeyCode.Digit4, isDown);
|
||||
break;
|
||||
case VK_F1:
|
||||
input.SetKey(KeyCode.RenderDebugCycle, isDown);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -88,10 +88,11 @@ public sealed class D3D11Renderer : IDisposable
|
|||
private float previousGridRadius;
|
||||
private float previousTimeSeconds;
|
||||
|
||||
public D3D11Renderer(IntPtr windowHandle, int width, int height, string? shaderPath = null, Action<string>? startupProgress = null)
|
||||
public D3D11Renderer(IntPtr windowHandle, int width, int height, string? shaderPath = null, int renderDebugMode = 0, Action<string>? startupProgress = null)
|
||||
{
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
RenderDebugMode = Math.Clamp(renderDebugMode, 0, 4);
|
||||
this.shaderPath = shaderPath ?? Path.Combine(AppContext.BaseDirectory, ShaderRelativePath);
|
||||
startupProgress?.Invoke("Creating D3D11 device and swapchain");
|
||||
|
||||
|
|
@ -245,7 +246,8 @@ public sealed class D3D11Renderer : IDisposable
|
|||
(float2)previousGridCenter,
|
||||
(float2)jitter,
|
||||
(float2)previousJitter,
|
||||
new float2(0.0f, 0.0f));
|
||||
RenderDebugMode,
|
||||
0.0f);
|
||||
|
||||
BuildFroxelPrimitiveTable(frame);
|
||||
context.UpdateSubresource(in constants, frameConstantBuffer);
|
||||
|
|
@ -254,7 +256,7 @@ public sealed class D3D11Renderer : IDisposable
|
|||
RenderScene();
|
||||
ResolveTemporal();
|
||||
context.Flush();
|
||||
overlay.Render(frame);
|
||||
overlay.Render(frame, RenderDebugMode);
|
||||
swapChain.Present(1, PresentFlags.None);
|
||||
|
||||
previousCameraPosition = frame.CameraPosition;
|
||||
|
|
@ -264,6 +266,13 @@ public sealed class D3D11Renderer : IDisposable
|
|||
frameIndex++;
|
||||
}
|
||||
|
||||
public int RenderDebugMode { get; set; }
|
||||
|
||||
public void CycleRenderDebugMode()
|
||||
{
|
||||
RenderDebugMode = (RenderDebugMode + 1) % 5;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
overlay.Dispose();
|
||||
|
|
@ -708,7 +717,8 @@ public sealed class D3D11Renderer : IDisposable
|
|||
float2 PreviousGridCenter,
|
||||
float2 JitterPixels,
|
||||
float2 PreviousJitterPixels,
|
||||
float2 Pad0);
|
||||
float RenderDebugMode,
|
||||
float Pad0);
|
||||
|
||||
private readonly record struct FroxelCell(int X, int Y, int Z);
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ internal sealed class DirectWriteOverlay : IDisposable
|
|||
smallFormat = CreateTextFormat("Ubuntu Sans", 11.0f, FontWeight.Regular);
|
||||
}
|
||||
|
||||
public void Render(AquariumFrame frame)
|
||||
public void Render(AquariumFrame frame, int renderDebugMode)
|
||||
{
|
||||
renderTarget.BeginDraw();
|
||||
DrawHeader(
|
||||
|
|
@ -73,6 +73,15 @@ internal sealed class DirectWriteOverlay : IDisposable
|
|||
new Rect(18, 38, Math.Min(width - 18, 420), 62),
|
||||
quietTextBrush,
|
||||
DrawTextOptions.Clip);
|
||||
if (renderDebugMode > 0)
|
||||
{
|
||||
renderTarget.DrawText(
|
||||
$"render debug {renderDebugMode} F1 cycle 0-4 select",
|
||||
smallFormat,
|
||||
new Rect(18, 56, Math.Min(width - 18, 420), 80),
|
||||
quietTextBrush,
|
||||
DrawTextOptions.Clip);
|
||||
}
|
||||
renderTarget.DrawText(
|
||||
"crisp text belongs after tonemapping",
|
||||
smallFormat,
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ cbuffer AquariumFrame : register(b0)
|
|||
float2 previousGridCenter;
|
||||
float2 jitterPixels;
|
||||
float2 previousJitterPixels;
|
||||
float2 _pad0;
|
||||
float renderDebugMode;
|
||||
float _pad0;
|
||||
};
|
||||
|
||||
Texture2D<float4> gridHeightTexture : register(t0);
|
||||
|
|
@ -1410,8 +1411,26 @@ ResolveOut AquariumResolvePS(VertexOut input)
|
|||
}
|
||||
|
||||
float3 resolved = lerp(currentColor, historyColor, historyWeight);
|
||||
float3 finalColor = aces(resolved);
|
||||
if (renderDebugMode > 0.5 && renderDebugMode < 1.5)
|
||||
{
|
||||
finalColor = aces(currentColor);
|
||||
}
|
||||
else if (renderDebugMode >= 1.5 && renderDebugMode < 2.5)
|
||||
{
|
||||
finalColor = aces(historyColor);
|
||||
}
|
||||
else if (renderDebugMode >= 2.5 && renderDebugMode < 3.5)
|
||||
{
|
||||
finalColor = historyAge / MAX_HISTORY_AGE;
|
||||
}
|
||||
else if (renderDebugMode >= 3.5 && renderDebugMode < 4.5)
|
||||
{
|
||||
finalColor = historyWeight.xxx;
|
||||
}
|
||||
|
||||
ResolveOut output;
|
||||
output.finalColor = float4(aces(resolved), 1.0);
|
||||
output.finalColor = float4(finalColor, 1.0);
|
||||
output.historyColor = float4(resolved, currentTravel);
|
||||
output.historyMetadata = currentMetadata;
|
||||
output.historyControl = float4(currentControl.xyz, historyAge);
|
||||
|
|
|
|||
|
|
@ -24,3 +24,4 @@
|
|||
{"area":"renderer/taa","lesson":"TAA Gate 3C stores accepted history age in temporal-control history w. The resolver grows age only when validation passes, resets it on failure, and ramps history authority with age so a newly reprojected sample can contribute without immediately carrying full stable-history weight.","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 3D fixes travel validation under camera motion. Previous history travel must be compared to the reprojected previous-world position's distance from the previous camera, not to current-frame travel; otherwise stable history is falsely rejected whenever camera motion changes ray distance.","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 3E fixes stochastic Grid accumulation. Opaque-surface neighborhood clamping and current-frame color-delta rejection collapse Grid history on dither-miss frames because the current sample looks like background; Grid history now bypasses those color checks and validates through field, travel, normal, coverage, reactive, and age terms.","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/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"}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@
|
|||
"TAA Gate 3C stores accepted history age in temporal-control history w. Validation grows age, failed validation resets it, and history authority ramps with age so fresh history can contribute without instantly gaining full trust.",
|
||||
"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.",
|
||||
"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."
|
||||
],
|
||||
|
|
|
|||
|
|
@ -69,3 +69,6 @@ prototype integrated along the camera ray before surface composition.
|
|||
- Temporal Gate 3E: stochastic Grid history bypasses opaque-surface color clamp
|
||||
and color-delta rejection. A current dither miss is not evidence that the
|
||||
true Grid color is background.
|
||||
- Temporal debug keys: F1 cycles, 0 final, 1 raw current scene, 2 reprojected
|
||||
history, 3 history age, 4 history weight. Use these to prove whether the
|
||||
presented frame is resolved and whether history is alive.
|
||||
|
|
|
|||
Loading…
Reference in a new issue