Pmndrs.docs

SSAO

A Screen Space Ambient Occlusion (SSAO) effect. For high quality visuals use two SSAO effect instances in a row with different radii, one for rough AO and one for fine details.

This effect supports depth-aware upsampling and should be rendered at a lower resolution. The resolution should match that of the downsampled normals and depth. If you intend to render SSAO at full resolution, do not provide a downsampled normalDepthBuffer and make sure to disable depthAwareUpsampling.

import { SSAO } from '@react-three/postprocessing'
import { BlendFunction } from 'postprocessing'

return (
  <SSAO
    blendFunction={BlendFunction.MULTIPLY} // blend mode
    samples={30} // amount of samples per pixel (shouldn't be a multiple of the ring count)
    rings={4} // amount of rings in the occlusion sampling pattern
    distanceThreshold={1.0} // global distance threshold at which the occlusion effect starts to fade out. min: 0, max: 1
    distanceFalloff={0.0} // distance falloff. min: 0, max: 1
    rangeThreshold={0.5} // local occlusion range threshold at which the occlusion starts to fade out. min: 0, max: 1
    rangeFalloff={0.1} // occlusion range falloff. min: 0, max: 1
    luminanceInfluence={0.9} // how much the luminance of the scene influences the ambient occlusion
    radius={20} // occlusion sampling radius
    scale={0.5} // scale of the ambient occlusion
    bias={0.5} // occlusion bias
  />
)

Props

NameTypeDefaultDescription
blendFunctionBlendFunctionBlendFunction.MULTIPLYThe blend function of this effect.
distanceScalingBooleantrueEnables or disables distance-based radius scaling.
depthAwareUpsamplingBooleantrueEnables or disables depth-aware upsampling. Has no effect if WebGL 2 is not supported.
normalDepthBufferTexturenullA texture that contains downsampled scene normals and depth. SeeDepthDownsamplingPass.
samplesNumber9The amount of samples per pixel. Should not be a multiple of the ring count.
ringsNumber7The amount of spiral turns in the occlusion sampling pattern. Should be a prime number.
distanceThresholdNumber0.97A global distance threshold at which the occlusion effect starts to fade out. Range [0.0, 1.0].
distanceFalloffNumber0.03The distance falloff. Influences the smoothness of the overall occlusion cutoff. Range [0.0, 1.0].
rangeThresholdNumber0.0005A local occlusion range threshold at which the occlusion starts to fade out. Range [0.0, 1.0].
rangeFalloffNumber0.001The occlusion range falloff. Influences the smoothness of the proximity cutoff. Range [0.0, 1.0].
minRadiusScaleNumber0.33The minimum radius scale. Has no effect if distance scaling is disabled.
luminanceInfluenceNumber0.7Determines how much the luminance of the scene influences the ambient occlusion.
radiusNumber0.1825The occlusion sampling radius, expressed as a resolution independent scale. Range [1e-6, 1.0].
intensityNumber1.0The intensity of the ambient occlusion.
biasNumber0.025An occlusion bias. Eliminates artifacts caused by depth discontinuities.
fadeNumber0.01Influences the smoothness of the shadows. A lower value results in higher contrast.
colorColornullThe color of the ambient occlusion.
resolutionScaleNumber1.0The resolution scale.
widthNumberResizer.AUTO_SIZEThe render width.
heightNumberResizer.AUTO_SIZEThe render height.