Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit65083fe8f2

README.md

dn_temporal

The temporal accumulation body both denoise_temporal variants run. A signal stored as rgba8 and one stored as rgba16f differ only in the format the result is written in, so the pass itself is written once here and included by each variant.

What it does

Finds where the pixel's surface was in the previous frame from @scene.motion, reads the estimate the previous frame left there, and mixes this frame's sample into it. Over a run of frames the standing average carries far more samples than any one frame casts, which is what lets the feature feeding it trace fewer rays.

Whether the previous frame's estimate belongs to this pixel is decided from the guide texture, which records for every pixel the world position of the surface it shaded and how many frames its estimate has been running. A reprojected tap is admitted when the position it recorded lies on the plane of the surface being shaded now, so a camera sliding along a wall keeps its history while the wall being uncovered by a moving object does not. The four bilinear taps are admitted one at a time and the weights renormalised, so an edge does not drag one surface's estimate onto another.

clampSigma bounds what the geometry test cannot see: a history outside the range this frame's own neighbourhood spans is pulled to the edge of it, which is how a light that moved stops showing where it was. A pixel's sample count stops at historyFrames and the blend weight is one over it, so nothing survives in the accumulation beyond that many frames whatever the tests decide.

dn_history and dn_guide are the pair the accumulation is carried across frames in, at a size of their own; dn_dst and dn_guide_out are the answer for the render target being drawn, at the resolution it is drawn at. Positions travel between the two as a fraction of the frame, so a capture or a camera rendering into a texture at another resolution reads the accumulation at the point it is looking at. dn_persist is what carries the answer back into the accumulation, for the one camera it belongs to.

Bindings the including variant declares

namekindwhat it is
dn_srctexture2dthis frame's noisy signal
dn_historytexture2dthe previous frame's accumulation
dn_guidetexture2dthe previous frame's guide — (world position, age)
scene_depthtexture_depthdepth, for world position and for the sky test
scene_normaltexture2dthe surface plane the geometry test is against
scene_motiontexture2dwhere each pixel's surface was last frame
frame_cambuffer (read, vec4)the drawn camera, for reconstructing world position
dn_temporal_settingsbuffer (read, vec4)(historyValid, planeTolerance, historyFrames, clampSigma)
dn_dststorage2dthe resolved estimate for the render target being drawn
dn_guide_outstorage2d (rgba16f)the guide that goes with it