Screen space ambient occlusion (SSAO) is a real-time rendering technique that approximates how much ambient light reaches each visible pixel by examining nearby depth values in the current frame. In Real-time 3D, it adds soft contact shadows in corners, creases and under objects, which makes scenes look grounded without the cost of full global illumination.
The method was popularized by Crytek in 2007 with the game Crysis and quickly became a standard post-process in game engines and interactive 3D graphics & animation tools. Its defining feature is that it works only with data already on screen, mainly the depth buffer and often surface normals, so its cost depends on resolution rather than scene complexity.
How SSAO estimates occlusion from the depth buffer
SSAO estimates occlusion by sampling points around each pixel and testing whether nearby geometry blocks them. For every pixel, the shader reconstructs a view-space position from the depth buffer, places a small kernel of sample points around it and compares each sample’s depth with the depth stored at its projected screen location.
If a sample lies behind the stored surface, it counts as occluded. The fraction of occluded samples becomes the ambient occlusion factor, usually between 0 (fully occluded) and 1 (fully open). A range check discards samples whose depth difference exceeds the sampling radius, which prevents distant background objects from darkening foreground edges.
The table below summarizes the main stages of a typical SSAO pass.
| Stage | Input | Result |
|---|---|---|
| Position reconstruction | Depth buffer, projection matrix | View-space position per pixel |
| Kernel sampling | Normal, random rotation, radius | Occlusion test for each sample |
| Occlusion accumulation | Sample results, range check | Raw noisy AO value |
| Blur or denoise | Raw AO, depth, normals | Smooth AO texture |
| Composition | AO texture, ambient lighting | Darkened indirect light |
Modern variants orient the kernel in a normal-aligned hemisphere instead of a full sphere, which avoids the gray self-occlusion on flat surfaces seen in early implementations. A small tiled random rotation texture varies the kernel per pixel, trading banding for noise that a later blur removes.
Key parameters and their effect
SSAO quality is controlled by a few tunable parameters that trade visual accuracy against GPU time. Values depend on scene scale and target hardware, so the ranges below are typical starting points rather than fixed rules.
| Parameter | Typical range | Effect when increased |
|---|---|---|
| Sample count | 8 to 32 per pixel | Less noise, higher cost |
| Radius | About 0.2 to 2 scene units | Wider, softer shadows; more halos |
| Intensity or power | 1.0 to 2.5 | Darker, higher-contrast occlusion |
| Bias | Small fraction of radius | Less acne, weaker fine detail |
| Resolution scale | Half or full resolution | Sharper detail at higher cost |
Many engines compute SSAO at half resolution and upsample with a depth-aware bilateral filter. This typically keeps the pass within about 0.5 to 2 milliseconds on current hardware at 1080p, although the exact figure varies with sample count, filter quality and GPU.
SSAO compared with other ambient occlusion techniques
SSAO is the cheapest dynamic option in a family of ambient occlusion methods. Later screen-space variants improve physical accuracy, while baked and ray-traced methods remove the screen-space limitation entirely.
| Technique | Data used | Strength | Weakness |
|---|---|---|---|
| SSAO | Depth and normals | Fast and simple | Halos, view dependence |
| HBAO | Depth horizons | More accurate falloff | Higher cost than basic SSAO |
| GTAO | Depth horizons, cosine weighting | Close to ray-traced reference | More complex to implement |
| Baked AO | Precomputed lightmaps or textures | Zero runtime cost, high quality | Static objects only |
| Ray-traced AO | Scene geometry via ray tracing | Sees off-screen occluders | Requires ray tracing hardware |
Ambient occlusion is often confused with shadow mapping. Shadow maps compute direct shadows from specific lights, while SSAO approximates blocked ambient or indirect light from all directions. The two techniques complement each other, and SSAO fits naturally into a deferred shading pipeline because the depth and normal buffers already exist there.
Integrating SSAO into a rendering pipeline
Correct integration means applying the AO factor only to ambient and indirect lighting. Multiplying the whole final image by the AO texture darkens directly lit surfaces as well, which produces a dirty look and is one of the most common setup errors.
- Deferred renderers read depth and normals from the G-buffer and run SSAO before the lighting pass.
- Forward renderers usually need a depth prepass, and sometimes a normal prepass, to provide the inputs.
- Temporal accumulation reuses results from previous frames to lower sample counts, at the risk of ghosting on fast motion.
- Physically based materials often contain baked AO maps; engines combine them with SSAO using a minimum or multiply rule.
In web frameworks such as Three.js and Babylon.js, SSAO is available as a post-processing pass. Developers should tune the radius to the scene’s real units, because a radius set for a room-sized scene will look wrong on a city-sized one.
Limitations and visual artifacts
Every SSAO variant shares the core limitation of screen-space data: geometry that is off screen or hidden behind other surfaces cannot occlude anything. The result changes as the camera moves, which experienced developers recognize as view-dependent occlusion.
| Symptom | Cause | Usual fix |
|---|---|---|
| Dark halos around objects | Large radius, weak range check | Smaller radius, distance falloff |
| Noisy or grainy shadows | Too few samples, weak blur | More samples or temporal filtering |
| Flat walls look gray | Full-sphere kernel, low bias | Hemisphere kernel, higher bias |
| AO fades at screen edges | Samples fall outside the frame | Guard band or edge clamping |
| Flicker during motion | Unstable random rotation | Temporal accumulation, stable noise |
Thin objects cause a further problem. The depth buffer stores only the nearest surface, so SSAO treats a thin pole or leaf as an infinitely thick wall behind it. This thickness assumption over-darkens areas behind slender geometry. Some implementations add a thickness heuristic or fall back to ray-traced ambient occlusion on hardware that supports it, while others accept the error because players rarely notice it in motion.
Explained without jargon
In real life, corners and narrow gaps look slightly darker. Less light from the surroundings can reach them. SSAO copies this effect in games and interactive scenes.
The computer looks at the finished picture and its depth information. For each dot on the screen, it checks whether nearby surfaces crowd around it. If they do, it shades that dot a little darker. The main benefit is that objects look solid and grounded. The main drawback is that it only knows what the camera can see.
A typical use case
A small team builds a browser-based furniture configurator with Three.js. Customers rotate a sofa in a virtual living room, but without ambient occlusion the sofa appears to float above the floor and the cushions look pasted together.
The developers add an SSAO pass with 16 samples per pixel, a radius of about 0.3 meters and half-resolution rendering followed by a depth-aware blur. They apply the result only to the ambient light, so sunlight on the cushions stays bright.
The sofa now shows soft contact shadows under its legs and between cushions. On a mid-range laptop the frame rate stays above 60 frames per second, and the team reports fewer customer comments about the scene looking artificial.