Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit3bb1da2647

README.md

lensFx

The settings behind the LensFx component, and the way to drive the lens from a script — a photo mode that dirties the glass, a cutscene that opens the flare up, a quality slider that drops the ghost count.

local lensFx = require("@builtin::systems.lensFx.lensFx")

lensFx.set({ flareIntensity = 1.0, grainIntensity = 0.03 })
lensFx.tick(dt)     -- advance the clock the grain is drawn against
lensFx.get()        -- a copy of the settings in force
lensFx.active()     -- whether the passes are running
lensFx.clear()      -- flare and grain off, settings kept

set takes any subset of the fields; whatever is omitted keeps its current value. With both flareIntensity and grainIntensity at 0 the render feature is released rather than running three passes that change nothing, and clear is the named way to say the same thing.

tick is separate from set for a reason. Grain is a fresh field every frame, so it needs the frame's own time — and a setting that has not changed is not re-pushed, so time cannot ride along inside set. Drive the module directly and you own tick; use the component and it does this for you. Calling tick while the feature is released is a no-op.

The clock wraps rather than growing without bound: the grain hash loses precision on a large argument, and every value in the cycle is as good as any other.

The module packs the settings into the lens_fx_params buffer the passes read, so a change lands on the next frame without recompiling anything.