Skip to main content

Ground-Truth Ambient Occlusion

Estimate horizon-based ambient visibility with temporally reprojected history and edge-aware spatial denoising. createGTAOShaderPassPipeline can attenuate either the complete lit image or only a separately supplied ambient-light contribution.

GitHub

At a Glance

PropertyValue
ExportcreateGTAOShaderPassPipeline
BackendWebGPU
Render passesSix: evaluation, temporal resolve, depth history, two bilateral blurs, and composite
Required bindingsdepthTexture, normalTexture, and velocityTexture
Optional bindingambientLightingTexture when composition: 'ambient-only'
Persistent stateOcclusion and depth history textures

Usage

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

const renderer = new ShaderPassRenderer(device, {
colorFormat: 'rgba16float',
shaderPasses: [
createGTAOShaderPassPipeline({resolutionScale: 0.5, composition: 'ambient-only'})
]
});

renderer.renderToScreen({
sourceTexture: litSceneTexture,
bindings: {...gBuffer.getShaderPassBindings(), ambientLightingTexture},
uniforms: {
gtaoEvaluate: {projectionMatrix, inverseProjectionMatrix, radius: 2.2, intensity: 3.2},
gtaoTemporal: {inverseProjectionMatrix, historyWeight: 0.88, depthThreshold: 0.015},
gtaoAmbientComposite: {strength: 0.68}
}
});

Parameters

ParameterDefaultDescription
resolutionScale1Resolution multiplier for visibility, temporal history, and bilateral denoising.
composition'color'Apply visibility to full scene color, or use 'ambient-only' with an explicit ambient-light texture.
radius2.2View-space sampling distance for the horizon evaluation.
bias0.04Depth tolerance used to reduce self-occlusion.
intensity3.2Strength of the evaluated horizon occlusion.
historyWeight0.88Contribution from reprojected, depth-validated occlusion history.
depthThreshold0.015Maximum accepted temporal depth disagreement.
strength0.68Final composite strength in gtaoComposite or gtaoAmbientComposite.

Ambient-Only Composition

With composition: 'ambient-only', the final stage subtracts only the occluded portion of the separate ambientLightingTexture. Direct lighting, emissive materials, and source alpha remain unchanged. The application owns that ambient texture and must provide it as an explicit binding; the effect does not reach across other pipelines to discover hidden render targets.

Performance and Placement

GTAO creates five intermediate targets, including persistent occlusion and depth history. Half-resolution evaluation reduces intermediate pixel count substantially but can soften narrow contact edges. Reset history after camera cuts or attachment-size changes. Compose after deferred lighting and before diffuse global illumination or reflective postprocessing.