Skip to content

denoiser-ffx: Gi1Denoiser, a port of AMD GI-1.0's image-space GI denoiser - #33

Merged
DennisSmolek merged 7 commits into
mainfrom
gi1-denoiser
Nov 26, 2026
Merged

DennisSmolek merged 7 commits into
mainfrom
gi1-denoiser

Conversation

@DennisSmolek

@DennisSmolek DennisSmolek commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Ports AMD GI-1.0's image-space GI denoiser (Capsaicin v1.3, commit 914b915, MIT) into denoiser-ffx as Gi1Denoiser, beside the FidelityFX ports. Dennis decided on 2026-11-19 that it goes here "like the other fidelity work". pmndrs/gi's radiance cache (a multi-cache GI system built from GI-1.2) is its first user.

Draft. Reworked after an independent review; a second review follows. Not for release until Dennis's list in pmndrs/gi is done (gi DECISIONS 2026-11-19).

What's in it

  • The passes: ReprojectGI (gi1.comp:3997-4103), FilterGI run twice (4105-4154), and helpers from gi_denoiser.hlsl, dispatched as in gi1.cpp:2881-2926.
    • Host code: packages/denoiser-ffx/src/gi1.ts. WGSL: src/shaders/gi1.ts.
    • It implements TemporalDenoiser<Gi1Inputs> (DiffuseInputs plus optional changedRegions).
  • Credit: AMD's notice is in the shader file and the package NOTICE, and the package README has a row for it.
  • Differences from Capsaicin, listed in docs/specs/temporal.md § "GI-1.0 port":
    • Storage: RGBA16F colour history as in Capsaicin, with every half store rounded to nearest (rgba16float stores truncate on some GPUs). Delta and blur mask share one r32uint. The guides are read in place. The denoiser keeps its own previous depth/normal only when the caller doesn't supply them.
    • Memory: 48 B/px, 60 with its own previous depth/normal copies. That is 398 MB at 4K (Capsaicin: about 29 B/px, 240 MB).
    • NaN/Inf: handled with bit tests rather than relying on saturate(NaN) = 0. RemoveNaNs runs on the history's mean, so irradiance is no longer capped at 1e4 / count.
    • Positions are rebuilt relative to the current camera, and the sky is also detected by far-plane depth.
    • History clamp (default on), historyClamp: 'neighbourhood' | 'none':
      • A short history (4 samples plus its luminance variance) runs beside Capsaicin's. The long history's mean is clipped to the short mean ± 2 standard errors in YCoCg; the input's 3x3 spatial σ is also used while the history is younger than 4 samples.
      • Capsaicin's delta still sees the unclipped history.
      • 'none' is Capsaicin's history, which takes 45–160 frames to follow a lighting change.
    • Soft change reset (default on), changeReset + inputs.changedRegions: inside changed regions (or everywhere, for 'everything') the history keeps at most 3 samples with Capsaicin's 4-sample cap, for 8 frames. Only resetHistory() drops the history.
  • Interface additions to denoiser-core:
    • optional FrameGuides.previousDepth / previousNormal;
    • an optional TemporalDenoiser.encode(encoder, …), which records into the caller's encoder (one frame per instance per submit).
  • Checks: examples/ffx-denoiser/gi1.html:
    • constant field, noisy field, blur mask, reprojection, NaN/Inf injection;
    • ghosting with a 5% and a 2% criterion, optionally with 8 px tile noise interpolated like the probes (jitter on or off).
    • run-headless.mjs runs on Windows.

Numbers (RTX 3060 Laptop, defaults)

  • Constant field: unchanged within 0.07% per pixel, still and moving, including inside the blur mask.
  • NaN/Inf injected every frame: output finite and exact.
  • Reprojection after a known camera move: 0.28% mean error.
  • Ghosting, noise-free: back to the pre-move counts within 16 frames (5%) and 25 frames (2%). Without the clamp: 3,130 pixels over 5% at frame 64, against 145 before the move.
  • Ghosting with tile noise: about 20x less trail than Capsaicin's history, but still fails narrowly (jitter on: 166 against 123 over 5% at frame 64).
  • In pmndrs/gi (branch rc4-3), frame-to-frame change of the denoised term, still camera, jitter on, clamp vs no clamp:
    • two-room: 0.090% vs 0.086%;
    • Sponza: 0.65% vs 0.59%;
    • Cornell with jitter off: 0.43% vs 0.24%.
  • A real scene change (two-room's lamp moves), 64 frames after the move:
    • the denoised error is 1.06x the raw input's (Capsaicin's history: 2.1x);
    • frame-to-frame change over the first 8 frames is 0.7% against the raw input's 6.5%, so the history is kept.

Not verified yet

Timing, the Intel UHD and Apple GPUs since the rework, and a by-eye check. The repo has no unit-test setup, so the CPU maths is covered by the GPU checks only.

… denoiser (Capsaicin v1.3)

ReprojectGI, FilterGI x2 and gi_denoiser.hlsl ported from Capsaicin 914b915
(gi1.comp:3997-4154, gi1.cpp:2881-2926), AMD's notice kept. Core: optional
FrameGuides.previousDepth/previousNormal and TemporalDenoiser.encode().
Test bed: examples/ffx-denoiser/gi1.html (constant, noisy, blur mask,
reprojection, ghosting checks); run-headless.mjs runs on Windows too.
…, README, spec section (GI-1.0 port: passes, deviations, interface additions, check results)
… 'neighbourhood' | 'none'), changed-region history reset (changeReset, Gi1Inputs.changedRegions); test bed options
…ting check); temporal.md and README document the clamp and change reset with measured numbers
…ax of spatial and temporal sigma, delta on the unclipped history), soft change reset over changeFrames, rgba16float history with nearest-half stores, delta and mask packed, guides read in place, own previous copies only when the caller has none, NaN/Inf bit guards; bed: tile noise, 2% ghosting gate, NaN injection
…ly, box = 2 standard errors of the short mean (spatial sigma only while young), default historyClip 2; temporal.md, README; bed fixes
@DennisSmolek
DennisSmolek marked this pull request as ready for review November 23, 2026 14:49
DennisSmolek added a commit to pmndrs/gi that referenced this pull request Nov 26, 2026
…the main merge

publish-workflow.test.ts pinned ci.yml's steps without the sibling fetch step rc-into-main added, so PR #41 failed on Ubuntu (the describe skips on Windows). The step stays until Gi1Denoiser is published in denoiser on npm (pmndrs/denoiser#33).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DennisSmolek
DennisSmolek merged commit b47f1d5 into main Nov 26, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant