Enabling Ambient Occlusion in Games
Enabling Ambient Occlusion in Games
Ambient Occlusion is a visual effect that was originally developed by Industrial Light and Magic (ILM) and used in the 2001 film Pearl Harbor. Hardware support has been available since 2003 with NVIDIA’s GeForce FX. One of the first games to use ambient occlusion was Crysis, which was developed by Crytek and released in late 2007. In 2009, NVIDIA added Ambient Occlusion as a Control Panel feature in its v185 drivers. An up-to-date list of games that support ambient occlusion through the Control Panel is given at the end of this article.
What It Is and How It Works:
One of the most difficult challenges in 3D game design is realistically modeling the behavior of light and its effects on various textures and surfaces without compromising frame rate. On a movie set, animators can leverage huge amounts of computational power and have the luxury of spending hours on a single frame. 3D game engines have no such luxury. Ambient occlusion is a technique to produce film-like lighting quality with real-time performance.
Ambient occlusion is a lighting model that calculates the brightness of a pixel in relation to nearby objects in the scene. More specifically, it determines when certain pixels are blocked from the environmental light by nearby geometry, in which case, its brightness value is reduced. It accounts for the general dimming effect when two evenly lit objects are brought close to each other.
Below are some examples of how ambient occlusion works, beginning with a simple model.
The Stanford dragon above is rendered in an evenly lit environment. There are a few darker and lighter areas on the model, but the lighting is mostly uniform. Despite having fairly intricate geometry, the dragon appears flat and without clear depth perception.
Below is the same model, with ambient occlusion enabled.
The most distinct change with AO is that smooth shadows have been added to the image. Unlike standard shadows which appear as solid regions enclosed by blurred edges, AO based shadows have wide and smooth gradations.
Ambient occlusion can be thought of as an approximate form of global illumination (GI). GI calculates the color of each pixel based on the light contributed from the surrounding hemisphere. Areas that are fully exposed to the surrounding environment (such as the dragon’s fins) appear brighter, whereas areas that are blocked (such as the dragon’s inner belly) appear darker. To calculate these characteristics using GI typically requires a large number of raytracing operations which is not feasible in a realtime environment. AO achieves a similar effect by comparing the relative depth of neighboring pixels. The end result is that AO is able to render softly lit and shadowed images with a global illumination look and feel in real-time.
In modern games, ambient occlusion may be listed in the graphics options menu as HBAO or SSAO. Both refer to ambient occlusion; HBAO (Horizon Based Ambient Occlusion) is an optimized type of SSAO (Screen Space Ambient Occlusion). If a game supports AO via a menu option set it there. Otherwise, set it in the NVIDIA Control Panel (see the appendix of this article for a full list of supported games). There is no need to set it in both locations and no benefit to doing so.
To activate AO in a game that doesn’t natively support it, do the following:
- Right-click on the desktop, then select the NVIDIA Control Panel.
- Click on “Manage 3D Settings”
- Highlight “Ambient Occlusion.”
- Select either Performance or Quality. Performance is faster, Quality produces finer images. Prior to the release of the 256 driver series, Ambient Occlusion could only be set to “On” or “Off” in the NVIDIA Control Panel. Release 256 allows users to switch between two different quality levels, as shown below .
Half Life 2
Below we have a pair of screenshots from HL2. All of the games built on Valve’s Source engine support AO when enabled from the CP, including Counterstrike, HL2, the Left 4 Dead series, and Team Fortress 2.
Here’s Half Life 2 without ambient occlusion enabled.
The exact same image and angle, with AO enabled in the Control Panel.
AO is applied in multiple areas of the screenshot above, but the most dramatic area of difference is around the wall phone just left of center. In the top image, the phone is a flat model against the wall; there’s no sense of relative depth between the object and the surface it rests against. In the second shot, with ambient occlusion enabled, the phone box casts a realistic shadow against the wall.
World in Conflict
Next up is the DX10 title World in Conflict:
World in Conflict: No Ambient Occlusion
World in Conflict: Ambient Occlusion
The benefits of AO aren’t limited to indoor areas or shadowy corners. World in Conflict is a title that illustrates how potent the impact of ambient occlusion can be. In WiC, ambient occlusion dramatically improves the grass and nearby grove of trees. It’s much easier to believe the sky in this scene is a mix of clouds and sun, with the former responsible for some of the specific shadow patterns on the grass.
Another popular game that supports ambient occlusion is the fast-paced Mirror’s Edge.
Mirror’s Edge: AO Off
Mirror’s Edge: AO On
In the first screenshot, a good deal of ambient occlusion is already present in the scene. This is likely based on offline rendered lightmaps. One area where AO is evidently missing is the firebox on the wall, possibly because this object was added later in the production pipeline. With Control Panel AO enabled, the correct shadow is applied to the box. This shows one of the benefits of AO over offline shadow techniques—AO works in realtime and works for all objects in the scene.
Far Cry 2
Our last example comes from Far Cry 2, which takes place in a lush, tropical environment. Here, the effect stands out clearly:
Far Cry 2: No Ambient Occlusion
Far Cry 2: “Performance” Ambient Occlusion
Far Cry 2: “Quality” Ambient Occlusion
The difference between the Performance and Quality modes is fairly subtle. The difference between having AO on and having it off, however, is immediate. With AO activated, the tropical grass casts a shadow on the ground and its self shadowing is more realistic. In a game like Far Cry 2, where the details of the jungle are essential to the game’s environment, ambient occlusion plays an important role in enhancing the game’s realism.
While features like anisotropic filtering or antialiasing improve image quality by eliminating artifacts, ambient occlusion enhances realism by adding an additional layer of sophistication to a game’s lighting and shadowing. In doing so, it delivers many of the benefits of global illumination without sacrificing playable frame rates.
As of the 257.15 (beta) drivers, the NVIDIA Control Panel supports ambient occlusion in the following applications:
- World of Warcraft
- Mirror's Edge
- Fallout 3
- Call of Duty 4
- Call of Duty 5
- Left 4 Dead
- Counter-Strike Source
- Half Life 2: Episode 2
- Team Fortress 2
- Half Life 2 (original)
- Assassin's Creed
- F.E.A.R. 2
- Dead Space
- Unreal Tournament 3
- Armed Assault II
- Left 4 Dead 2
- Operation Flashpoint: Dragon Rising
- AION Online
- The Call of Juarez: Bound in Blood
- Street Fighter IV
- Dragon Age: Origins
- Need for Speed: Shift
- Assassin's Creed
- Lost Planet: Extreme Condition
- Lost Planet: Colonies
- Call Of Juarez
- Company Of Heroes
- Devil May Cry 4
- Farcry 2
- World In Conflict
- Resident Evil 5