ao.module
This package holds more than this page lists. See all of its files in its world.
README.md
ao
Ambient occlusion: the contact darkening of indirect light in corners, creases
and where objects meet, and, with indirect, the light the occluding surfaces
send back in its place (screen-space bounced light: a white floor beside a red
wall turns red near it).
local ao = require("@builtin::systems.ambientOcclusion.ao")
ao.set({ intensity = 0.9, radius = 1.5, quality = "high" })
ao.set({ traced = true }) -- trace the hemisphere while the scene's ray tracing is on
ao.set({ indirect = true }) -- gather the light the occluders send; a number is a strength (1 physical, 0 off)
ao.get() --> the settings in force, with the walk, rays and resolution their quality picks
ao.qualityLevels() --> { low = { slices, steps, rays, scale }, ... }
ao.active() --> is the occlusion pass running
ao.stats() --> the estimator the last frame ran, its grid, rays per frame, dispatches
ao.clear() --> off; every setting kept for the next set()
set takes any subset, and omitted fields keep their current value. Every set
turns occlusion on with the settings it leaves in force; an intensity of 0
releases the render pass rather than running it at zero strength. A quality
outside low | medium | high | ultra is an error rather than a silent fallback,
and leaves every setting where it was.
Occlusion reaches the indirect term of PBR shading (zero_pbr_shade) only:
ambient, irradiance and environment reflection. Direct light, emissive surfaces and
transparents keep the light they carry, so a sunlit wall reads the same with
occlusion on and off. The light indirect gathers reaches the same diffuse
indirect term, in place of the share of the surroundings' light the occlusion
took away, so it adds the colour of what is near a surface without adding light
the scene did not send.
A quality change that crosses the resolution the occlusion is computed at
swaps the pass (qualityLevels() reports it as scale); every other setting
reaches the running pass the next frame.
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 is in the package readme:
guides { path = "systems/ambientOcclusion" }.