antiAliasing.package
- ..
- README.md5.2 KB
- bindings.yaml819 B
- shader.wgsl28.3 KB
This package holds more than this page lists. See all of its files in its world.
README.md
taa_resolve
Carries one frame's accumulation forward into the next: the temporal resolve
(temporal_resolve) at render scale 1. Finds where each pixel's surface was
last frame, reads what that frame decided there through a Catmull-Rom spline,
and folds this frame's estimate into it (the 3x3 samples weighted by where the
render's sub-pixel offset landed each against the pixel's centre) as one sample
among the renders the pixel's history holds — so a silhouette gains a gradient
and a specular highlight stops flashing as it crosses the sample point.
The history is only usable where it still describes the same surface. Velocity is taken from the nearest pixel of the 3x3 neighbourhood; a reprojection off the frame starts over; a pixel where the previous render held a surface well in front of the one there now starts over; and what survives is clipped into the neighbourhood's own colour statistics in YCoCg along the line from the mean — which is what stops a newly-uncovered pixel from trusting the history of whatever was covering it.
Bindings
| name | kind |
|---|---|
scene_color | texture2d |
scene_depth | texture_depth |
scene_motion | texture2d |
taa_history | texture2d |
taa_depth_history | texture2d |
taa_temporal_history | texture2d |
taa_lean_history | texture2d (uint) |
frame_cam | buffer |
taa_params | buffer |
taa_state | buffer |
taa_out | storage2d (rgba16f) |
taa_depth_out | storage2d (r32f) |
taa_temporal_out | storage2d (rgba16f) |
taa_lean_out | storage2d (r32uint) |
taa_params carries the tuning (historyWeight, neighbourhoodClamp,
motionRejection, stillSamples, the length of the jitter sequence and the
sequence's offsets, up to eight), packed by
@builtin::systems.antiAliasing.temporalAntiAliasing. taa_state is the
history target's state buffer, written by the engine before each render of a
view: x whether taa_history holds that view's previous result, y how many
renders in a row have carried it, zw the render's sub-pixel offset in pixels.
frame_cam is the camera drawing the view (@frame.camera): its inverse
view-projection and position, which turn a depth sample into a distance.
taa_depth_out records each pixel's distance from the camera, and
taa_depth_history is the previous render's. taa_temporal_out records, per
pixel, how many renders its history holds (x), how far its estimates' luma
has strayed from the history over the last passes through the jitter sequence
(the reach, y), how many renders in a row it has stood still (z) and three
counts packed into one whole number (w): how many renders ago its 3x3 last
held an edge the jitter can move (a spread over 2 % of its farthest distance in
depth, or a line one pixel wide in luma: three samples in a row that each stand
30 % out from the two beside them), for how many renders in a row the estimate
has stood on one side of the history (negative below it), and the side the
estimate last differed from its phase's by 8 %. taa_lean_out records one word
per pixel: the estimates it saw at each even phase of the last pass through the
jitter sequence, four 8-bit codes logarithmic in the estimate's luma.
taa_temporal_history and taa_lean_history are the previous render's.
On a still pixel at a silhouette the history stands unclipped while the estimate stays within the reach: a thin edge that leaves the 3x3 samples on some renders of the jitter sequence is averaged rather than clipped toward whichever side the samples fell. The history is the mean of the estimates, so within every pass the jitter puts estimates on both sides of it; a change of the picture (a light switched off or on) puts every estimate on one side of it. Once the estimates have stood on one side of the history for a whole pass, it is clipped like any other. Every render teaches the reach, so one that has let go below the jitter's swing is learnt again within a pass.
A still picture gives the same estimate at the same phase of every pass, wherever
that estimate stands in the pixel's swing. The pixel keeps the estimate of each
even phase of the last pass. An estimate that differs from its phase's by more
than half of the larger of the two and half the pixel's history is a change of
the picture on the render it happens on, and so is one that differs by more than
8 % of that on two remembered phases in a row to the same side. A thin lit line whose swing spans light and
dark follows a light switched off, or dimmed by a part of its level, within a
few renders and holds steady under the jitter. A step between two areas stands out
from one side, and its pixels, with those of a hard texture edge's staircase, are
clipped as every other pixel's are. The memory is kept for a pixel
moving at most 0.1 px a render, and follows jitter sequences of up to eight
offsets: the phase of a render is the offset of the sequence nearest its own,
read from taa_params. Half the pixel's history stands in for the level of a
dark phase of a line, which the noise of the lighting moves by a larger share
than a bright phase's. The counts packed into taa_temporal judge passes of up
to 14 renders.