Ambient occlusion

From Valve Developer Community
Jump to navigation Jump to search
This article or section is a stub. You can help by expanding it.
Icon-callout-cleanup.png
This article or section needs to be cleaned up to conform to a higher standard of quality because:
Reason 
This page was recently moved to become a page document every AO types, aswell explaining what AO is in general.
An example of traditional prerendered ambient occlusion in Blender 3D. SSAO attempts to mimic this look in real-time.
Note.pngNote: Not to be confused with baked ambient occlusion on models!

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).

Note.pngNote: The SSAO in Apex Legends is a custom implementation of ambient occlusion. The developers themselves did not specify the name of the algorithm, so it is referred to by the generic term "SSAO", even though the actual implementation might have a different name. Similarly, any other AO technique might actually have a specific implementation name. Therefore, "SSAO" should not always be interpreted as the native implementation originally developed by Crytek in 2007; it is a generic term used to refer to any screen-space AO method.
Games using SSAO
Source Filmmaker Source Filmmaker
Dota 2 Dota 2
Tactical Intervention Tactical Intervention
Counter-Strike Online 2 Counter-Strike Online 2
Double Action: Boogaloo Double Action: Boogaloo
Vindictus Vindictus
Apex Legends Apex Legends

Source Filmmaker

Source Filmmaker includes an SSAO option (labelled "Ambient Occlusion"), accessible by right-clicking on the viewport. The default setting is very grainy.

Todo: Adjust number of samples?

Adding SSAO to Source Engine

You can implement Basic SSAO Shader on Source SDK Base 2013 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).

Note.pngNote: For baked Ambient Occlusion maps per model within the Source Engine, see $ambientocclusion.
Note.pngNote: A post process SSAO shader currently ships with the Source Shader Editor.

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
Estranged: Act I Estranged: Act I
Insurgency Insurgency
Blade Symphony Blade Symphony
Day of Infamy Day of Infamy
Horizon-Based Ambient Occlusion (HBAO)
Titanfall Titanfall
Titanfall 2 Titanfall 2
Horizon-Based Ambient Occlusion Plus (HBAO+)

Forcing HBAO/HBAO+ on unsupported games

Todo: HBAO can be forced through GPU driver control panel (or NVIDIA Profile Inspector) for other Source games that only support other AO techniques or never had native support for AO at all. Document how to do it. HBAO Compatibility flags can be found here.

Other AO techniques

Games Ambient occlusion technique
Military Conflict: Vietnam Military Conflict: Vietnam Scalable Ambient Obscurance (SAO)
Strata Source Strata Source Ground Truth Ambient Occlusion (XeGTAO)
Portal with RTX Portal with RTX
Half-Life 2 RTX Half-Life 2 RTX
RTX Remix RTX Remix
Ray-traced AO

External links