Screen space ambient occlusion

Also known as: SSAO

On this page 7

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.

StageInputResult
Position reconstructionDepth buffer, projection matrixView-space position per pixel
Kernel samplingNormal, random rotation, radiusOcclusion test for each sample
Occlusion accumulationSample results, range checkRaw noisy AO value
Blur or denoiseRaw AO, depth, normalsSmooth AO texture
CompositionAO texture, ambient lightingDarkened indirect light
Stages of a typical SSAO pass

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.

ParameterTypical rangeEffect when increased
Sample count8 to 32 per pixelLess noise, higher cost
RadiusAbout 0.2 to 2 scene unitsWider, softer shadows; more halos
Intensity or power1.0 to 2.5Darker, higher-contrast occlusion
BiasSmall fraction of radiusLess acne, weaker fine detail
Resolution scaleHalf or full resolutionSharper detail at higher cost
Common SSAO parameters

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.

TechniqueData usedStrengthWeakness
SSAODepth and normalsFast and simpleHalos, view dependence
HBAODepth horizonsMore accurate falloffHigher cost than basic SSAO
GTAODepth horizons, cosine weightingClose to ray-traced referenceMore complex to implement
Baked AOPrecomputed lightmaps or texturesZero runtime cost, high qualityStatic objects only
Ray-traced AOScene geometry via ray tracingSees off-screen occludersRequires ray tracing hardware
Ambient occlusion techniques in real-time rendering

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.

SymptomCauseUsual fix
Dark halos around objectsLarge radius, weak range checkSmaller radius, distance falloff
Noisy or grainy shadowsToo few samples, weak blurMore samples or temporal filtering
Flat walls look grayFull-sphere kernel, low biasHemisphere kernel, higher bias
AO fades at screen edgesSamples fall outside the frameGuard band or edge clamping
Flicker during motionUnstable random rotationTemporal accumulation, stable noise
Typical SSAO artifacts and their fixes

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.