AmbientOcclusion.component
This package holds more than this page lists. See all of its files in its world.
README.md
AmbientOcclusion
The scene's contact shading, as a component. Add it to an entity and the
indirect light in corners, creases and the places where objects meet darkens the
way it does in life, and reflections that look into them dim. With indirect,
the surfaces doing the occluding send their own light back in its place, so
colour bleeds from a wall onto the floor beside it. Direct light, emissive
surfaces and transparents keep the light they carry.
local id = entity.spawn("ambient_occlusion").id
entity(id).component.add("AmbientOcclusion", {
intensity = 0.9,
radius = 1.5,
quality = "auto",
})
Every field is live — editing one in the inspector moves the shading on the next
frame, and the values persist with the scene. Setting intensity to 0 turns
occlusion off while keeping the rest authored; removing the last one in the scene
clears it.
| field | effect |
|---|---|
intensity | How far the darkening goes, in [0, 1]. 0 is off. |
radius | World-space reach of the occlusion. |
power | Contrast curve on the visibility term. Above 1 deepens the dark end. |
thickness | World-space thickness assumed for an occluder. |
bias | How far a neighbour must rise above the surface before it counts as an occluder, in [0, 1]. |
quality | auto (the default: the device's quality tier picks the level) | low | medium | high | ultra. Every level below ultra computes occlusion on a half-resolution grid. |
traced | Trace the hemisphere against the scene acceleration structure while the scene's ray tracing is on; a frame drawn without it takes the screen-space estimate. |
indirect | The light the surfaces closing each hemisphere send it (bounced light, colour bleeding, screen-space GI): 0 off (the default), 1 physical. A white floor beside a red wall turns red near the wall, and a moving object takes the colour of what it passes. Only surfaces on screen and within radius send light, so a room's walls tint its floor across the room at a radius the size of the room; a strong indirect reads smoothest at ultra, the one full-resolution level. The ScreenSpaceGI component drives this same field: a scene uses one of the two. |
A quality outside that set is reported as a warning and the last good setting stays live, so a typo in the inspector does not stop the component.
Code that changes occlusion at runtime can drive the same settings through
@builtin::systems.ambientOcclusion.ao.