What is Ambient Occlusion
Ambient occlusion is a shading technique that games use to emulate out how much light is hitting each point or object in a scene by pre-baking shadows onto 3D objects.
Turning Ambient occlusion on in a game tells your computer to spend some processing power to approximate out how much light a given object should be exposed to.
Calculating and simulating light and shadows in a game environment is not cheap computationally.
Realistic lighting and shadows often makes a huge difference in picture quality and graphic realism, so if you can afford turning it on without a huge impact to your frames, I’d recommend you do so. For twitchy fast-paced shooters, you’re going to want maximum frames for best response times, so turn it off.
There are several different methods of ambient occlusion, some ways approximate ambient occlusion but don’t require as much computing power but are less accurate, some ambient occlusion methods that use very detailed geometry and pixels to map shadows, and then there’s techniques like Ray tracing, which is essentially processing all visible light sources in a scene, no emulation.
Types of Ambient Occlusion
Ambient Occlusion techniques have gotten better and better since Screen Space Ambient Occlusion (SSAO) was first introduced in Crysis in 2007, prior to true real-time ambient occlusion, game designers would bake AO into textures and maps of an object.
Screen Space Ambient Occlusion (SSAO)
SSAO is a real-time post processed ambient occlusion system that takes a frame in buffer, samples pixel depth and adds shadow and lighting data to the scene.
SSAO avoids using real geometry (real power hungry) to calculate shadows and lighting. When a 3d engine is rendering onto a 2d screen, it converts the 3d space into a 2d pixel screen. SSAO measures the depth of the pixel to try to determine where objects are in a 2d picture. SSAO doesn’t use any CPU power and gives a decent boost to visuals without being too computationally expensive.
SSAO only samples certain portions of the screen to make pixel depth measurements, so SSAO can often add noise or grain and a SSAO pass filter has to be done to remove noise. Because SSAO is really only trying to edges of objects without any regard to lighting, sometimes SSAO can add an unrealistic drop shadow effect to the scene when used poorly.
SSAO is the least demanding form of Ambient occlusion you can add into a game, some games do really well with SSAO and some games can overdo the shadows with SSAO, causing shadow borders around objects. In general, it’s very nice to be able to add shadows and lighting without slowing down your frames too much.
Horizon-Based Ambient Occlusion (HBAO)
HBAO is Nvidia’s propietary answer to ambient occlusion and is a major resolution step up from SSAO in terms of sampling. Instead of just looking at pixels depth, HBAO also restores small bits of the scene to sample geometry to better determine lighting and shadows. Of course, more sampling means more power, HBAO does provide a more accurate portrayal of lighting and shadow but comes with a bigger hit than SSAO.
HBAO+ is an updated version of HBAO with supposedly better algorithms and less of a performance hit.
High-Definition Ambient Occlusion (HDAO)
HDAO is AMD’s version of a self-shadowing object algorithm like HBAO. If you have an AMD card, use HDAO.
Screen Space Directional Occlusion (SSDO)
SSDO takes SSAO and adds lighting direction into the output, resulting in shadows that respect lighting direction. SSDO can add bouncing light and shadows into its rendering, resulting in a more accurate image.
Here’s a good video explaining SSDO:
Voxel Ambient Occlusion (VXAO)
VXAO gets even closer to pure geometric calculation of light and shadow. VXAO converts the screen space into 3d voxels instead of pixels. Voxels which is basically a 3d pixel, it’s a cube! Think of it like how you can use cubes in Minecraft to compose much more elaborate structures, this is what VXAO is doing to a regular 3d game in real-time.
Voxels roughly approximate the geometry of a scene allowing for even better occlusion rendering.
Not surprisingly, VXAO is more demanding than SSAO, HDAO and HBAO.
What is Ray Tracing?
Ray tracing is a significant step up from ambient occlusion. Ray tracing actually takes 3d geometry, surfaces and light directions into account, the result is significantly better and much more life like.
Calculating every light source and object would take way too much computational power to render a game in real time, Ray Tracing allows the game to only calculate light and objects if they are in the view of the camera, saving a bunch of computational power and even allowing a game to run real-time Ray Tracing at 60 fps.
Right now, game support is only okay and most graphics cards are not powerful enough to run it at playable speed. Ray Tracing will likely become a ‘thing’ when more power is available, the additional fidelity you add to a scene is 100% worth it.
Ambient Occlusion Comparisons
Here are the three most common Ambient Occlusion methods in The Witcher 3, if you look to the corners of the room, you can see that the scene has much more contrast and dynamic range with AO turned on, when AO is off, the scene feels a little grayer. HBAO adds a lot more subtle shadow than SSAO, which can look a little bit like adding drop shadow to objects.
Here are the individual stills for each setting.