Ambient Occlusion is a concept used in computer graphics to describe the shadowing of ambient light. It is important because it helps improve the perception of creases and contact areas, and grounds objects, specially those which are not under direct illumination.

This images are from a car lit by ambient light. In the left image we see the floor under the car darkened by it. In the right one, the shadow under the car is removed, and the car appears to be floating, like it does not belong there. (Images taken from John Hable’s Uncharted 2: HDR Lighting presentation at GDC 2010).

Formally, ambient occlusion is defined as the integral of the visibility function over the hemisphere around the surface normal. It measures the amount of light being blocked by nearby objects. (Image taken from Separable Approximation of Ambient Occlusion presentation at Eurographics 2011).

The most common approach to solving the integral is to cast rays over the hemisphere around each surface location or vertex, which is extremely expensive to do at interactive framerates. Therefore it is used to precompute the occlusion factor for static scenes, both in games and in the film industry, as an offline method.

In order to achieve real-time framerates, several methods have been developed which approximate the effect in screen space, the first of them being Crytek’s Screen Space Ambient Occlusion method, originally developed for their game Crysis. The main idea behind these algorithms is this: for every pixel on the screen, sample a set of pixels around it from the depth buffer, and compare the depth values to get an estimate of the amount of occlusion of the pixel. The sampling can be done in 3D as well, but it requires having the positions of the objects rendered at each pixel, which can be either directly retrieved from a buffer, or reconstructed from depth. In addition, surface normals can be used to avoid sampling below the surface and to attenuate the occlusion value depending on the angle between the normal at the point and the direction towards the occluder. A buffer with occlusion values is obtained from this algorithm, which is then combined with the lighting information of the scene to produce the final image. Typically the occlusion factor only affects ambient light, but you can also made it affect direct light to achieve different results.