Ambient occlusion
Ambient Occlusion (AO) is a rendering technique used to calculate how exposed each point in a 3D scene is to ambient lighting. It simulates soft, localized shadows in crevices, corners, and contact points where geometry meets, preventing objects from looking like they are floating and adding a realistic sense of depth.
Unlike global illumination or direct dynamic shadows, ambient occlusion is an approximation that usually treats light as uniformly coming from all directions. It only dictates how much light is *blocked* (occluded) by nearby geometry.
In the Source and Source 2 engine, ambient occlusion is implemented using various real-time, screen-space methods, cutting-edge hardware ray tracing, or baked directly into textures during map compilation (VRAD).
SSAO
Screen Space Ambient Occlusion (SSAO) works by examining an onscreen pixel, and then comparing its location in a depth buffer to the pixels around it. Pixels which are close together but not coplanar (on the same face) are shaded to simulate soft shadows. To maintain playable framerates, it is not possible to sample every pixel every frame, so random sampling is used, which will inevitably create noise/grain which may be more noticeable with movement. To counter this, the SSAO pass is often blurred to remove such grain.
As with traditional AO, SSAO is completely independent of the normal lighting system. This means that both the performance and appearance of the shader are unaffected by the lights used in a level.
The depth buffer is measured from the camera, and so SSAO is view-dependent - the size and locations of the "shadows" created by SSAO may change as the player moves the camera around. Additionally, the shading may look different along the edges of the screen - this can be combated by rendering additional information outside of the current camera's bounds.
SSAO in Source Engine
The original release of Dota 2 aswell as Source Filmmaker, are the only official Source games that support SSAO. SSAO is also used in Titanfall branch engine branch, specifically Apex Legends (which replaced HBAO+ ambient occlusion in Titanfall & Titanfall 2).
| Games using SSAO |
|---|
Source Filmmaker
Source Filmmaker includes an SSAO option (labelled "Ambient Occlusion"), accessible by right-clicking on the viewport. The default setting is very grainy.
Adding SSAO to Source Engine
You can implement Basic SSAO Shader on
Source SDK Base 2013, using
tutorial by DmitRex. However, as SSAO is a post-processing effect, you can use third-party software (ReShade), or Source Shader Editor to add SSAO. Alternatively, it is possible to use the superior HBAO ambient occlusion, which can be forced through GPU driver control panel (or by using NVIDIA Profile Inspector).
HBAO and HBAO+
Horizon-Based Ambient Occlusion was developed by NVIDIA to significantly evolve standard SSAO. Unlike previous SSAO variants, HBAO uses a physically based algorithm that approximates an integral with depth buffer sampling. This enables HBAO to generate higher-quality SSAO, increasing the number of samples per pixel and the definition, quality, and visibility of AO.
But for performance reasons, HBAO is typically rendered at half-resolution, reducing the number of AO pixels by three-quarters. Unfortunately, rendering HBAO at reduced resolutions causes flickering that’s challenging to hide in all situations.
To overcome these issues, NVIDIA has completely redeveloped and revamped SSAO to create HBAO+, a paradigm shift in the field of SSAO rendering. In comparison to HBAO, HBAO+ doubles the detail level of AO and runs three times faster.
| Games | HBAO types |
|---|---|
| Horizon-Based Ambient Occlusion (HBAO) | |
| Horizon-Based Ambient Occlusion Plus (HBAO+) |
Forcing HBAO/HBAO+ on unsupported games
Other AO techniques
| Games | Ambient occlusion technique |
|---|---|
| Scalable Ambient Obscurance (SAO) | |
| Ground Truth Ambient Occlusion (XeGTAO) | |
| Ray-traced AO |