Builtin Library
README.md
temporalAntiAliasing
Runtime control of the scene's temporal antialiasing.
local temporalAntiAliasing = require("@builtin::systems.antiAliasing.temporalAntiAliasing")
temporalAntiAliasing.enable({ historyWeight = 0.9, sharpness = 0.2 })
temporalAntiAliasing.get()
temporalAntiAliasing.active()
temporalAntiAliasing.disable()
enable creates the pass if it is not running and applies the settings; any
field left out keeps its current value. disable releases the pass and returns
the projection to sampling pixel centres, keeping the settings so a later
enable brings back the same tuning.
For antialiasing that persists with the scene, add the TemporalAntiAliasing
component instead — it drives this module from fields you can edit in the
inspector.
Settings
| field | effect |
|---|---|
historyWeight | How much of the accumulated result to keep each frame. Higher resolves more detail and settles smoother, at the cost of taking longer to let go of what a surface used to look like. Clamped short of 1, where the accumulation would stop taking in the frame being drawn. |
neighbourhoodClamp | How far outside the neighbourhood's own colour spread an accumulated sample may sit before it is pulled back in. Lower rejects more, trading some of the settling for a result that follows change faster. |
sharpness | How much of the edge lost to averaging over sub-pixel samples is added back. 0 leaves the accumulation as it is. |
motionRejection | How much fast motion shortens the memory. A reprojection over a long distance is the most likely to have crossed onto another surface, so weighting the current frame up there is what stops a moving object trailing behind itself. |
Choosing between this and edge antialiasing
Both are in this package and they correct different things.
antiAliasing (FXAA) works from the finished frame alone. It finds each edge and
shifts that pixel's sample across it, which fixes the staircase in a still image
at a fixed cost, and knows nothing about time — so a highlight that flashes on
and off between frames still flashes.
This one accumulates real samples, so it corrects what no single frame can see:
the crawling and flickering that only exist in motion, and sub-pixel detail no
one sample lands on. It needs the scene's velocity to do it, and pays for it with
a small amount of softening, which sharpness puts back.
Running both is reasonable — FXAA cleans up the edges within a frame while the accumulation handles what happens between them.