denoiser.interface
- .metadata223 B
- README.md3.5 KB
- contract.module
- interface.yaml2.5 KB
This package holds more than this page lists. See all of its files in its world.
README.md
denoiser
Filters a noisy image a render pass wrote into a quieter image of the same
size. A type that lists denoiser under interfaces: in its type.yaml
guarantees that denoise adds the passes that filter signal to the frame being
drawn and answers the guid of the filtered image, and that each owner's
filtering keeps its own state. A render feature that shades from a few
stochastic samples (a probe field read per pixel, a traced reflection or
occlusion term) takes a denoiser as a setting
(Field.interfaceRef("denoiser", ...)) and calls whatever asset the setting
names through the interface, so a different denoiser is a different asset
named in that setting.
-- inside a render feature's render(ctx)
local denoiser = ctx.settings.denoiser
local clean = denoiser:as("denoiser"):denoise("myFeature", ctx, noisy.guid, {
phase = "afterLighting", order = 20,
})
local next = 20 + denoiser:as("denoiser"):orders("myFeature")
Implementing it
# myFilter.assetType/type.yaml
interfaces: [denoiser]
-- myFilter.assetType/behavior.luau
local M = {}
M.ref = {
denoise = function(self, owner, ctx, signal, opts) ... return filtered.guid end,
orders = function(self, owner, values) return 2 end,
restart = function(self, owner) ... end,
free = function(self, owner) ... end,
}
return M
The base inputs
ownernames the filtering. Two features filtering in one frame pass two owners and share nothing.signalis linear colour in rgb, at the frame's resolution or a whole fraction of it (a signal read at half resolution), whichopts.scalestates (frame pixels on a side per texel, 1 by default). Each of its texels stands for the frame pixel at its centre, the pixel whose depth, normal and motion describe it.opts.phaseandopts.orderplace the passes: they takeordersconsecutive orders fromopts.order.opts.valuesare values for the parameters the asset declares (asset.schema).opts.guidesnames the channels the surfaces are read from. The scene's own are the default.
A type's own extras travel in opts beside these, are always optional, and
never change a base input's meaning.
Optional inputs
A source that knows more about its signal states it in opts; a denoiser that
reads none of them filters the signal alone.
opts.confidence = truesays the signal's alpha holds, per texel, how much of that texel's light has held still since the frame before: 1 where all of it has, less as the source moved more of it. The texels where it is below 1 carry a shorter history.opts.opennessis the guid of a texture of the signal's size whose blue channel holds how open each texel's surface is: 1 in the open, less against geometry the source cannot see through (a crease, a contact). The texels where it is below 1 take a narrower spatial filter.
Required behaviour
denoiseanswers a guid that holds, by the order after its last pass, the filtered image at the size ofsignal, in rgb.- A signal that holds the same value everywhere on a surface comes back as that value there.
- Where the surface under a pixel changed since the frame before (a newly uncovered background, a cut), what the earlier frames held there is not carried onto it.
ordersstates how many ordersdenoisetakes with the same values.restartmakes the nextdenoisestart from that frame's own image;freefrees what the owner held, and a laterdenoisestarts again.