Skip to main content

Screen-Space Global Illumination

Gather colored diffuse light bouncing between surfaces that are visible in the current frame. createSSGIShaderPassPipeline traces a screen-space hemisphere, reprojects indirect-light history, denoises across compatible surfaces, and adds the stabilized radiance to scene color.

GitHub

At a Glance​

PropertyValue
ExportcreateSSGIShaderPassPipeline
BackendWebGPU
Render passesSix: hemisphere trace, temporal resolve, depth history, two spatial filters, and composite
Required bindingsdepthTexture, normalTexture, and velocityTexture
Persistent statergba16float indirect-light and depth history
Lighting modelVisible-screen diffuse bounce; no offscreen geometry

Usage​

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

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

renderer.renderToScreen({
sourceTexture: litSceneTexture,
bindings: gBuffer.getShaderPassBindings(),
uniforms: {
ssgiTrace: {
projectionMatrix,
inverseProjectionMatrix,
radius: 4.5,
thickness: 0.32,
intensity: 2.2,
rayCount: 7,
stepCount: 8,
frameIndex
},
ssgiTemporal: {inverseProjectionMatrix, historyWeight: 0.89, depthThreshold: 0.022}
}
});

Parameters​

ParameterDefaultRange or purpose
resolutionScale1Relative resolution of tracing, history, denoising, and indirect-radiance textures.
radius4.5View-space hemisphere tracing distance.
thickness0.32Depth thickness accepted when a ray intersects visible scene geometry.
intensity2.2Multiplier applied to gathered diffuse bounced radiance.
rayCount7Hemisphere directions per pixel; supported range is 1 to 12.
stepCount8Samples per ray; supported range is 2 to 12.
historyWeight0.89Contribution from depth-validated indirect-light history.
depthThreshold0.022Temporal depth rejection threshold.
strength1Final ssgiComposite contribution added to scene color.

Quality and Limitations​

The trace cost grows with both rayCount and stepCount, while resolution affects every intermediate and history texture. Only geometry and radiance visible in the current screen can contribute; offscreen emitters and surfaces hidden behind the first depth layer are unavailable. Velocity reprojection and depth/normal-aware denoising reduce frame-to-frame noise but do not recover missing scene information.

Place SSGI after direct lighting and ambient occlusion. Place it before Screen-Space Reflections when reflective surfaces should include the newly added diffuse bounce.