Add rejection-masked reservoir sequence metrics
This commit is contained in:
parent
0d9b890e2f
commit
0f29ea4ec2
6 changed files with 112 additions and 19 deletions
|
|
@ -533,10 +533,12 @@ Work packet:
|
|||
builds one disposable runtime slot and captures native/baseline sequences
|
||||
across ready-frame counts, debug modes, and work-grid scale.
|
||||
`scripts/measure-reservoir-sequence.ps1` reports per-frame native/baseline
|
||||
disagreement and per-mode frame-to-frame temporal deltas. First smoke run:
|
||||
`reservoir-sequence-20260529-234414-*` at 640x360, final color only, ready
|
||||
frames 2 and 4. It proved the harness works; it is still a probe, not a
|
||||
disocclusion-masked ghosting score.
|
||||
disagreement, per-mode frame-to-frame temporal deltas, and masked rows when
|
||||
rejection-debug captures exist. Smoke runs:
|
||||
`reservoir-sequence-20260529-234414-*` at 640x360, final color only, and
|
||||
`reservoir-sequence-20260529-235031-*` at 320x180 with final plus rejection
|
||||
debug. The latter proved resumable capture and rejection-mask filtering; it
|
||||
is still a probe, not a high-budget-reference ghosting score.
|
||||
11. Current: add temporal leakage/ghosting metrics over motion/disocclusion
|
||||
sequences, then use those metrics to decide where the sampler spends its
|
||||
bounded update budget.
|
||||
|
|
|
|||
|
|
@ -97,6 +97,18 @@ foreach ($mode in $modes) {
|
|||
$arguments += @("--render-debug", $debugMode)
|
||||
}
|
||||
|
||||
if (Test-Path -LiteralPath $outputPath) {
|
||||
Write-Host ("Skipping existing {0} ready={1} debug={2} -> {3}" -f $mode, $readyFrame, $debugMode, $outputPath)
|
||||
$captures.Add([pscustomobject]@{
|
||||
Mode = $mode
|
||||
ReadyFrames = $readyFrame
|
||||
RenderDebugMode = $debugMode
|
||||
Suffix = $suffix
|
||||
Path = $outputPath
|
||||
})
|
||||
continue
|
||||
}
|
||||
|
||||
Write-Host ("Capturing {0} ready={1} debug={2} -> {3}" -f $mode, $readyFrame, $debugMode, $outputPath)
|
||||
$env:AQUARIUM_HEADLESS_READY_FRAMES = [string][Math]::Max(1, $readyFrame)
|
||||
$process = Start-Process -FilePath $exePath -ArgumentList $arguments -NoNewWindow -PassThru -RedirectStandardOutput $stdoutLog -RedirectStandardError $stderrLog
|
||||
|
|
|
|||
|
|
@ -37,21 +37,49 @@ function Measure-ImageDelta {
|
|||
param(
|
||||
[string]$APath,
|
||||
[string]$BPath,
|
||||
[string]$Label
|
||||
[string]$Label,
|
||||
[string]$AMaskPath = "",
|
||||
[string]$BMaskPath = ""
|
||||
)
|
||||
|
||||
$a = [System.Drawing.Bitmap]::new($APath)
|
||||
$b = [System.Drawing.Bitmap]::new($BPath)
|
||||
$aMask = if ([string]::IsNullOrWhiteSpace($AMaskPath)) { $null } else { [System.Drawing.Bitmap]::new($AMaskPath) }
|
||||
$bMask = if ([string]::IsNullOrWhiteSpace($BMaskPath)) { $null } else { [System.Drawing.Bitmap]::new($BMaskPath) }
|
||||
try {
|
||||
if ($a.Width -ne $b.Width -or $a.Height -ne $b.Height) {
|
||||
throw "Capture dimensions differ for $Label."
|
||||
}
|
||||
if ($aMask -ne $null -and ($aMask.Width -ne $a.Width -or $aMask.Height -ne $a.Height)) {
|
||||
throw "A-mask dimensions differ for $Label."
|
||||
}
|
||||
if ($bMask -ne $null -and ($bMask.Width -ne $a.Width -or $bMask.Height -ne $a.Height)) {
|
||||
throw "B-mask dimensions differ for $Label."
|
||||
}
|
||||
|
||||
$changed = 0
|
||||
$measured = 0
|
||||
$sum = 0L
|
||||
$max = 0
|
||||
for ($y = 0; $y -lt $a.Height; $y++) {
|
||||
for ($x = 0; $x -lt $a.Width; $x++) {
|
||||
$maskActive = $true
|
||||
if ($aMask -ne $null -or $bMask -ne $null) {
|
||||
$maskActive = $false
|
||||
if ($aMask -ne $null) {
|
||||
$ma = $aMask.GetPixel($x, $y)
|
||||
$maskActive = $maskActive -or ([Math]::Max([int]$ma.R, [Math]::Max([int]$ma.G, [int]$ma.B)) -gt 12)
|
||||
}
|
||||
if ($bMask -ne $null) {
|
||||
$mb = $bMask.GetPixel($x, $y)
|
||||
$maskActive = $maskActive -or ([Math]::Max([int]$mb.R, [Math]::Max([int]$mb.G, [int]$mb.B)) -gt 12)
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $maskActive) {
|
||||
continue
|
||||
}
|
||||
|
||||
$ca = $a.GetPixel($x, $y)
|
||||
$cb = $b.GetPixel($x, $y)
|
||||
$delta = [Math]::Max(
|
||||
|
|
@ -59,6 +87,7 @@ function Measure-ImageDelta {
|
|||
[Math]::Max(
|
||||
[Math]::Abs([int]$ca.G - [int]$cb.G),
|
||||
[Math]::Abs([int]$ca.B - [int]$cb.B)))
|
||||
$measured++
|
||||
if ($delta -gt 0) {
|
||||
$changed++
|
||||
}
|
||||
|
|
@ -71,18 +100,29 @@ function Measure-ImageDelta {
|
|||
}
|
||||
|
||||
$total = $a.Width * $a.Height
|
||||
$denominator = if ($measured -gt 0) { $measured } else { 1 }
|
||||
[pscustomobject]@{
|
||||
Label = $Label
|
||||
ChangedPixels = $changed
|
||||
MeasuredPixels = $measured
|
||||
TotalPixels = $total
|
||||
ChangedPercent = $changed / $total
|
||||
MeanMaxChannelDelta = $sum / $total
|
||||
ChangedPercent = $changed / $denominator
|
||||
FramePercent = $measured / $total
|
||||
MeanMaxChannelDelta = $sum / $denominator
|
||||
MaxChannelDelta = $max
|
||||
APath = $APath
|
||||
BPath = $BPath
|
||||
AMaskPath = $AMaskPath
|
||||
BMaskPath = $BMaskPath
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if ($aMask -ne $null) {
|
||||
$aMask.Dispose()
|
||||
}
|
||||
if ($bMask -ne $null) {
|
||||
$bMask.Dispose()
|
||||
}
|
||||
$a.Dispose()
|
||||
$b.Dispose()
|
||||
}
|
||||
|
|
@ -90,6 +130,11 @@ function Measure-ImageDelta {
|
|||
|
||||
$captures = Import-Csv -Path $ManifestPath
|
||||
$results = [System.Collections.Generic.List[object]]::new()
|
||||
$byKey = @{}
|
||||
foreach ($capture in $captures) {
|
||||
$key = "{0}|{1}|{2}" -f $capture.Mode, $capture.ReadyFrames, $capture.Suffix
|
||||
$byKey[$key] = $capture
|
||||
}
|
||||
|
||||
$groups = $captures | Group-Object Suffix
|
||||
foreach ($group in $groups) {
|
||||
|
|
@ -105,6 +150,15 @@ foreach ($group in $groups) {
|
|||
$baseline = $baselineFrames | Where-Object { [int]$_.ReadyFrames -eq [int]$native.ReadyFrames } | Select-Object -First 1
|
||||
if ($null -ne $baseline) {
|
||||
$results.Add((Measure-ImageDelta -APath $native.Path -BPath $baseline.Path -Label "$suffix mode-delta f$($native.ReadyFrames)"))
|
||||
if ($suffix -eq "final") {
|
||||
$nativeMaskKey = "native|{0}|rejection" -f $native.ReadyFrames
|
||||
$baselineMaskKey = "baseline|{0}|rejection" -f $native.ReadyFrames
|
||||
if ($byKey.ContainsKey($nativeMaskKey) -or $byKey.ContainsKey($baselineMaskKey)) {
|
||||
$nativeMask = if ($byKey.ContainsKey($nativeMaskKey)) { $byKey[$nativeMaskKey].Path } else { "" }
|
||||
$baselineMask = if ($byKey.ContainsKey($baselineMaskKey)) { $byKey[$baselineMaskKey].Path } else { "" }
|
||||
$results.Add((Measure-ImageDelta -APath $native.Path -BPath $baseline.Path -Label "final masked-mode-delta f$($native.ReadyFrames)" -AMaskPath $nativeMask -BMaskPath $baselineMask))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -113,6 +167,15 @@ foreach ($group in $groups) {
|
|||
$previous = $modeFrames[$index - 1]
|
||||
$current = $modeFrames[$index]
|
||||
$results.Add((Measure-ImageDelta -APath $previous.Path -BPath $current.Path -Label "$suffix temporal-$($current.Mode) f$($previous.ReadyFrames)-f$($current.ReadyFrames)"))
|
||||
if ($suffix -eq "final") {
|
||||
$previousMaskKey = "{0}|{1}|rejection" -f $current.Mode, $previous.ReadyFrames
|
||||
$currentMaskKey = "{0}|{1}|rejection" -f $current.Mode, $current.ReadyFrames
|
||||
if ($byKey.ContainsKey($previousMaskKey) -or $byKey.ContainsKey($currentMaskKey)) {
|
||||
$previousMask = if ($byKey.ContainsKey($previousMaskKey)) { $byKey[$previousMaskKey].Path } else { "" }
|
||||
$currentMask = if ($byKey.ContainsKey($currentMaskKey)) { $byKey[$currentMaskKey].Path } else { "" }
|
||||
$results.Add((Measure-ImageDelta -APath $previous.Path -BPath $current.Path -Label "final masked-temporal-$($current.Mode) f$($previous.ReadyFrames)-f$($current.ReadyFrames)" -AMaskPath $previousMask -BMaskPath $currentMask))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -124,27 +187,29 @@ $lines.Add("# Reservoir Sequence Metrics")
|
|||
$lines.Add("")
|
||||
$lines.Add(("Stamp: ``{0}``" -f $Stamp))
|
||||
$lines.Add("")
|
||||
$lines.Add("| Metric | Changed pixels | Changed % | Mean max-channel delta | Max channel delta |")
|
||||
$lines.Add("| --- | ---: | ---: | ---: | ---: |")
|
||||
$lines.Add("| Metric | Changed pixels | Mask/frame % | Changed % | Mean max-channel delta | Max channel delta |")
|
||||
$lines.Add("| --- | ---: | ---: | ---: | ---: | ---: |")
|
||||
foreach ($result in $results) {
|
||||
$lines.Add(("| {0} | {1} / {2} | {3} | {4} | {5} |" -f
|
||||
$lines.Add(("| {0} | {1} / {2} | {3} | {4} | {5} | {6} |" -f
|
||||
$result.Label,
|
||||
$result.ChangedPixels,
|
||||
$result.TotalPixels,
|
||||
$result.MeasuredPixels,
|
||||
$result.FramePercent.ToString("P4"),
|
||||
$result.ChangedPercent.ToString("P4"),
|
||||
$result.MeanMaxChannelDelta.ToString("N4"),
|
||||
$result.MaxChannelDelta))
|
||||
}
|
||||
$lines.Add("")
|
||||
$lines.Add("These are sequence probes, not a final ghosting score. Mode deltas show native/baseline disagreement at each sampled time. Temporal deltas show frame-to-frame output movement per mode; the next scorer must use disocclusion/rejection masks or a high-budget reference before claiming quality.")
|
||||
$lines.Add("These are sequence probes, not a final ghosting score. Mode deltas show native/baseline disagreement at each sampled time. Temporal deltas show frame-to-frame output movement per mode. When rejection captures are present, masked rows restrict the comparison to pixels marked by either mode's rejection debug output; a high-budget reference is still needed before claiming quality.")
|
||||
Set-Content -LiteralPath $OutputPath -Value $lines -Encoding UTF8
|
||||
|
||||
Write-Host "Reservoir sequence metrics:"
|
||||
foreach ($result in $results) {
|
||||
Write-Host (" {0}: changed {1}/{2} ({3}) meanMax {4} max {5}" -f
|
||||
Write-Host (" {0}: changed {1}/{2} mask/frame {3} changed {4} meanMax {5} max {6}" -f
|
||||
$result.Label,
|
||||
$result.ChangedPixels,
|
||||
$result.TotalPixels,
|
||||
$result.MeasuredPixels,
|
||||
$result.FramePercent.ToString("P4"),
|
||||
$result.ChangedPercent.ToString("P4"),
|
||||
$result.MeanMaxChannelDelta.ToString("N4"),
|
||||
$result.MaxChannelDelta)
|
||||
|
|
|
|||
|
|
@ -299,3 +299,4 @@
|
|||
{"timestamp":"2026-05-29T23:30:00+01:00","topic":"reservoir-baseline-comparison-mode","lesson":"Native-domain versus texel-owned baseline comparison now has an explicit field-reservoir mode switch. Both modes use the same reservoir rows; native mode enables domain validity, support overlap, and producer replay at temporal reuse, while baseline mode keeps texel-owned field/travel/normal/color/confidence validation. First paired captures at artifacts/fensalir-captures/reservoir-compare-20260529-231904-* changed 10.8208% of final-frame pixels, 0.0165% of rejection-debug pixels, and 0.2976% of shift-debug pixels. This proves the switch is live but does not yet measure temporal leakage or ghosting quality.","files":["src/Aquarium.Engine.Contracts/GraphicsSettings.cs","src/Aquarium.Engine.Contracts/AquariumRuntimeContracts.cs","src/Aquarium.Engine/AquariumHost.cs","src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Engine/Render/Shaders/D3D12Post.hlsl","scripts/capture-fensalir-frame.ps1","tests/Aquarium.Engine.Tests/FieldReservoirAbiTests.cs","docs/perfect-fensalir-machine-roadmap.md"],"source":"artifacts/fensalir-captures/reservoir-compare-20260529-231904-*"}
|
||||
{"timestamp":"2026-05-29T23:55:00+01:00","topic":"budgeted-reservoir-work-grid","lesson":"The native-domain reservoir must be a budgeted spatiotemporal sampler, not a native-resolution buffer by another name. GraphicsSettings.FieldReservoirScale now clamps the internal work grid below final presentation scale; scene evidence targets, reservoir candidate/history rows, reservoir resolve, bloom sources, and match-window graph targets use that grid, while the full-resolution surface is reserved for final presentation/reconstruction. The comparison script now repeats native-vs-baseline image deltas, but the next real proof is temporal leakage/ghosting over motion sequences so adaptive update budgets can be spent where they buy visible stability.","files":["src/Aquarium.Engine.Contracts/GraphicsSettings.cs","src/Aquarium.Engine.Contracts/AquariumRuntimeContracts.cs","src/Aquarium.Engine/AquariumHost.cs","src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Fensalir/FensalirRuntime.cs","src/Aquarium.Zyphos/ZyphosRuntime.cs","scripts/capture-fensalir-frame.ps1","scripts/measure-reservoir-mode-comparison.ps1","tests/Aquarium.Engine.Tests/FieldReservoirAbiTests.cs","docs/perfect-fensalir-machine-roadmap.md","state/map.yaml","state/scratch.md"],"source":"user spatiotemporal reservoir upscaling sampler correction"}
|
||||
{"timestamp":"2026-05-30T00:25:00+01:00","topic":"reservoir-sequence-probe","lesson":"Reservoir comparison now has a sequence-level probe instead of only single-frame deltas. scripts/capture-reservoir-mode-sequence.ps1 builds one disposable slot and captures native/baseline frames across ready-frame counts, debug modes, and reservoir work-grid scale; scripts/measure-reservoir-sequence.ps1 reports per-frame mode disagreement plus per-mode frame-to-frame temporal deltas. The first 640x360 final-only smoke sequence at reservoir-sequence-20260529-234414-* proved the harness works, but the metric remains a probe until disocclusion/rejection masks or high-budget references turn it into a real ghosting/leakage score.","files":["scripts/capture-reservoir-mode-sequence.ps1","scripts/measure-reservoir-sequence.ps1","docs/perfect-fensalir-machine-roadmap.md","state/scratch.md"],"source":"artifacts/fensalir-captures/reservoir-sequence-20260529-234414-*"}
|
||||
{"timestamp":"2026-05-30T00:40:00+01:00","topic":"reservoir-rejection-masked-sequence-probe","lesson":"The reservoir sequence harness is now resumable and mask-aware. Existing PNGs are skipped and still recorded into the manifest, which lets interrupted sequence captures continue instead of throwing away completed frames. When rejection-debug captures are present, scripts/measure-reservoir-sequence.ps1 reports masked native/baseline and temporal deltas over the union of rejection-mask pixels. The 320x180 smoke set reservoir-sequence-20260529-235031-* covered about 41% of frame pixels with the rejection mask and produced masked rows, proving the pressure signal works; it is still not a final ghosting score without a high-budget reference or explicit disocclusion mask.","files":["scripts/capture-reservoir-mode-sequence.ps1","scripts/measure-reservoir-sequence.ps1","docs/perfect-fensalir-machine-roadmap.md","state/scratch.md"],"source":"artifacts/fensalir-captures/reservoir-sequence-20260529-235031-*"}
|
||||
|
|
|
|||
|
|
@ -152,9 +152,11 @@ next_actions:
|
|||
full-resolution presentation pass. A sequence probe now captures
|
||||
native/baseline timelines from one disposable slot and measures per-frame
|
||||
mode disagreement plus frame-to-frame temporal deltas; the first smoke set
|
||||
is `reservoir-sequence-20260529-234414-*`. The next cut is upgrading that
|
||||
probe into a disocclusion/rejection-masked leakage/ghosting score plus
|
||||
future exact producer SDF replay.
|
||||
is `reservoir-sequence-20260529-234414-*`. The probe is now resumable and
|
||||
rejection-mask-aware; `reservoir-sequence-20260529-235031-*` proves masked
|
||||
mode/temporal rows over rejection-debug pixels. The next cut is upgrading
|
||||
that probe into a high-budget-reference or explicit-disocclusion
|
||||
leakage/ghosting score plus future exact producer SDF replay.
|
||||
- Build the planetary flow organ in staged cuts: provenance manifest, static
|
||||
relief and reanalysis cube-sphere bake pipeline, stochastic advection
|
||||
contracts, synthetic runtime slice, ERA5/OSCAR baseline learning, then
|
||||
|
|
|
|||
|
|
@ -26,6 +26,16 @@ final color only, ready frames 2 and 4. Native/baseline mode-delta changed
|
|||
78.5581%, temporal-baseline changed 48.9741%. These are probes, not a final
|
||||
ghosting score.
|
||||
|
||||
Masked sequence smoke:
|
||||
`artifacts/fensalir-captures/reservoir-sequence-20260529-235031-*` at 320x180,
|
||||
ready frames 2 and 3, final plus rejection debug. The sequence capture is now
|
||||
resumable: existing PNGs are skipped and still written into the manifest.
|
||||
Rejection-mask rows covered about 41% of frame pixels. Masked native/baseline
|
||||
mode-delta changed 87.4393% at f2 and 94.7517% at f3; masked temporal-native
|
||||
changed 83.2208%, masked temporal-baseline changed 83.4813%. This proves the
|
||||
mask path is live but still needs a high-budget reference or explicit
|
||||
disocclusion mask before it can claim ghosting quality.
|
||||
|
||||
## Hot Lesson
|
||||
|
||||
Area ReSTIR confirms that reuse over an area domain is invalid unless the
|
||||
|
|
@ -57,8 +67,9 @@ cap remain intentionally non-authoritative.
|
|||
|
||||
Follow `docs/perfect-fensalir-machine-roadmap.md` Phase 1:
|
||||
|
||||
1. Turn the temporal sequence probe into a real leakage/ghosting score using
|
||||
disocclusion/rejection masks or a high-budget reference.
|
||||
1. Turn the temporal sequence probe into a real leakage/ghosting score using a
|
||||
high-budget reference and explicit disocclusion masks. Rejection masks are
|
||||
only a first pressure signal.
|
||||
2. Add exact SDF producer replay only when client SDF distance functions have a
|
||||
shared replay include or manifest instead of duplicating shader policy in
|
||||
post.
|
||||
|
|
|
|||
Loading…
Reference in a new issue