Log inGet started
Package

svgf.denoiser

Newest version

This package holds more than this page lists. See all of its files in its world.

README.md

svgf

Spatiotemporal variance-guided filtering (Schied et al. 2017) of a noisy image, as a denoiser: the passes follow blade-render's WGSL implementation (MIT), with ReLAX's per-pixel history length and fast-history clamp, and a spatial reach that follows each pixel's history length.

Across frames

Each texel finds where its surface stood on the frame before through the frame's own motion (@scene.motion: the camera's, every moving entity's and every animated pose's), read at the nearest surface of the 3x3 around its pixel so a moving silhouette carries its own motion. Of the four history texels there, it takes each that held a surface facing the same way (normalAgreement) at the same view distance (depthTolerance, as it stands now or where the camera of the frame before would see this point standing still), and blends this frame's sample into the estimate they carry, evenly over the frames it holds, up to historyFrames. A newly uncovered texel, a cut, or a surface that moved off its pixel carries nothing and starts from this frame's sample.

A fast estimate of the luminance averages the last fastFrames. Where the long estimate stands further from it than clampSigmas standard errors of the fast estimate's noise (the noise the estimate held before this frame), the light changed: the long estimate takes the fast one's luminance and holds no more frames than it, so a light that moves or switches shows within about fastFrames frames and nothing trails behind it.

The moments of each texel's luminance give its noise (the variance of its samples); a texel holding under four frames takes the variance of the 3x3 of this frame's samples on its surface.

A source that knows where its light moved can say so (opts.confidence, the signal's alpha: 1 where the light held still, 0 where the source moved it). A texel whose alpha is below 1 takes the fast estimate's light by that share and holds that share fewer frames, so the history follows the source's own statement of a change without waiting for the noise band to be left.

A sample far brighter than the 3x3 around it (a ray that met a small bright source) is held to the neighbours' mean plus fireflySigmas of their standard deviations before it enters the history, with a quarter of the mean as a floor on the allowance.

Across pixels

iterations à-trous passes follow, 1, 2, 4, ... texels apart, over the 3x3 texels at each step. A neighbour weighs in by a small Gaussian, by its normal's agreement with the centre's (normalPower), by how far it stands off the two surfaces' planes as a share of the view distance (planeTolerance), and by how far its luminance stands from the centre's in units of the larger of their noises (luminanceSigmas). A rejected neighbour's weight stays on the centre, so a pass conserves the light of the image, and the variance of the sum is carried to the next pass. A texel takes every pass while its estimate holds one frame and settledIterations once it holds the whole history, so the smoothing is strongest where the history is short. A source that states how open each texel is (opts.openness, the blue channel of a texture of the signal's size: 1 in the open, less against geometry it cannot see through) keeps the wide steps off the texels against contact: such a texel takes the share contactPasses of the passes its history asks for.

Costs

Per owner, three history targets (two images each, per view) and two scratch targets, all rgba16f at the signal's size, and 1 + iterations dispatches. iterations follows the device's quality level (4, 3, 2).

Parameters

namedefaultwhat it is
historyFrames32The most frames an estimate averages, counted in sixtieths of a second: a slower frame counts as the sixtieths it covers, up to 8.
fastFrames4The frames the fast estimate averages, counted the same way.
clampSigmas3Standard errors of the fast estimate the long one may stand from it; 0 holds it to the surface tests alone.
iterations4À-trous passes a young estimate takes (3 at medium, 2 at low).
fireflySigmas3Standard deviations of the 3x3 a texel's luminance may stand above its neighbours' mean before it is held there; 0 takes every sample.
contactPasses0.5Share of the à-trous passes a texel against contact takes, when the source states how open each texel is; 1 takes them all.
settledIterations1À-trous passes a settled estimate takes.
luminanceSigmas4Noise deviations two texels' luminance may differ by before the passes stop between them.
planeTolerance0.002Share of the view distance two surfaces may stand off each other's planes.
normalPower8Cosine power of the normal weight.
depthTolerance0.05Share of the view distance a history surface may stand from this one.
normalAgreement0.9Least cosine between a history surface's normal and this one's.