Skip to main content

Screen-Space Ambient Occlusion

Darken tight creases and nearby surface contacts using the current scene depth buffer. createSSAOShaderPassPipeline evaluates screen-space ambient visibility, smooths it with a depth-aware bilateral blur, and composites the result into scene color.

GitHub

At a Glance

PropertyValue
ExportcreateSSAOShaderPassPipeline
BackendWebGPU
Render passesFour: evaluate, horizontal blur, vertical blur, and composite
Required bindingdepthTexture
Optional bindingnormalTexture when normalSource: 'normal-texture'
HistoryNone

Usage

import {ShaderPassRenderer} from '@luma.gl/engine';
import {createSSAOShaderPassPipeline} from '@luma.gl/effects';

const renderer = new ShaderPassRenderer(device, {
shaderPasses: [
createSSAOShaderPassPipeline({
normalSource: 'normal-texture',
resolutionScale: 0.5
})
]
});

renderer.renderToScreen({
sourceTexture: gBuffer.colorTexture,
bindings: gBuffer.getShaderPassBindings(),
uniforms: {
ssaoEvaluate: {
nearPlane: 0.1,
farPlane: 200,
radius: 7,
bias: 0.03,
intensity: 1.35
}
}
});

Parameters

ParameterDefaultDescription
normalSource'reconstruct-from-depth'Reconstruct normals from depth or consume an explicit normalTexture.
resolutionScale1Relative resolution of all three occlusion intermediates.
nearPlane0.1Camera near plane used to linearize hardware depth.
farPlane200Camera far plane used to linearize hardware depth.
radius7Screen-space sampling radius around the current pixel.
bias0.03Depth tolerance that reduces self-occlusion.
intensity1.35Strength of the accumulated occlusion estimate.

Performance and Composition

The evaluation stage visits 12 nearby depth samples; two subsequent Depth-Aware Blur passes preserve foreground/background boundaries. resolutionScale: 0.5 reduces intermediate pixel count to approximately one quarter. SSAO does not maintain temporal history and composites onto the complete source color.

Choose GTAO when horizon integration, temporal stabilization, or ambient-only composition is required.

  • GTAO adds horizon-based visibility, temporal history, and ambient-only composition.
  • Depth-Aware Blur explains the bilateral denoising stages.
  • Outlines can consume the same depth and normal attachments.