Screen Space Ambient Occlusion (SSAO)
The Screen Space Ambient Occlusion override is a real-time, full-screen lighting effect available in the High Definition Render Pipeline (HDRP). This effect approximates ambient occlusion in the current field of view. It approximates the intensity and position of ambient light on a GameObject’s surface, based on the light in the Scene and the environment around the GameObject. To achieve this, it darkens creases, holes, intersections, and surfaces that are close to one another. In real life, these areas tend to block out, or occlude, ambient light, and so appear darker.
For information on how to use a Texture to specify ambient occlusion caused by details present in a GameObject's Material but not on it's surface geometry, see Ambient Occlusion.
HDRP implements ray-traced ambient occlusion on top of this override. This means that the properties visible in the Inspector change depending on whether you enable ray tracing.
Enable Screen Space Ambient Occlusion
To use this feature in your Scene, you must first enable it for your project and then enable it for your Cameras. To enable features in your project, you use the HDRP Asset and to enable features for your Cameras, you use Frame Settings. You can enable features either for all Cameras, using the Default Frame Settings, or for specific Cameras, by overriding each Camera's individual Frame Settings.
- To enable SSAO in your HDRP Asset go to Lighting > Screen Space Ambient Occlusion.
- To enable SSAO in your Frame Settings go to Edit > Project Settings > Graphics > HDRP Global Settings > Frame Settings (Default Values) > Camera > Lighting > Screen Space Ambient Occlusion.
Use Screen Space Ambient Occlusion
Screen Space Ambient Occlusion uses the Volume framework, so to enable and modify Screen Space Ambient Occlusion properties, you must add an Screen Space Ambient Occlusion override to a Volume in your Scene. To add Ambient Occlusion to a Volume:
- In the Scene or Hierarchy view, select a GameObject that contains a Volume component to view it in the Inspector.
- In the Inspector, navigate to Add Override > Lighting and click on Ambient Occlusion. HDRP now applies Ambient Occlusion to any Camera this Volume affects.
API
To access and control this override at runtime, use the Volume scripting API. Because of how the Volume system works, you edit properties in a different way to standard Unity components. There are also other nuances to be aware of too, such as each property has an overrideState. This indicates to the Volume system whether to use the property value you set, or use the default value stored in the Volume Profile. For information on how to use the API correctly, see Volume scripting API.
Limitations
Screen-space ambient occlusion
A screen-space effect only processes what's on the screen at a given point. This means that objects outside of the field of view can't visually occlude objects in the view. You can sometimes see this on the edges of the screen. When rendering Reflection Probes screen space ambient occlusion isn't supported.