Builtin Library
README.md
ao
Screen-space ambient occlusion — the contact darkening in corners, creases and where objects meet.
local ao = require("@builtin::systems.ambientOcclusion.ao")
ao.set({ technique = "gtao", intensity = 0.9, radius = 1.5, quality = "high" })
ao.get() --> the settings in force
ao.techniques() --> { ssao = "...", hbao = "...", gtao = "..." }
ao.qualityLevels() --> { low = { slices, steps, scale }, ... }
ao.active() --> is the occlusion pass running
ao.clear() --> off, settings kept for the next set()
set takes any subset — omitted fields keep their current value. An intensity
of 0 releases the render pass rather than running it at zero strength. A
technique outside ssao | hbao | gtao, or a quality outside
low | medium | high | ultra, is an error rather than a silent fallback, and
the last good setting stays live.
Changing technique swaps the pass for the new one, as does a quality change
that crosses the resolution the occlusion is computed at — qualityLevels()
reports that as scale. The three techniques are themselves scaled to agree on
a right-angle corner, so switching changes how the estimate is made rather than
how dark the scene gets.
For occlusion a scene should simply have, author the AmbientOcclusion
component instead — same settings, persists with the scene, edits live in the
inspector. This module is for code that changes it at runtime: a quality slider,
a cutscene.
The full description of the knobs, the three techniques and how the passes work
is in the package readme: guides { path = "systems/ambientOcclusion" }.