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
    intensity={1.0} // intensity of the ambient occlusion
    bias={0.5} // occlusion bias
  />
)

Props

NameTypeDefaultDescription
blendFunctionBlendFunctionBlendFunction.MULTIPLYThe blend function of this effect.
depthAwareUpsamplingBooleantrueEnables or disables depth-aware upsampling. Has no effect if WebGL 2 is not supported.
normalDepthBufferTexturenullA texture with downsampled scene normals and depth, supplied automatically from <EffectComposer enableNormalPass resolutionScale>. See DepthDownsamplingPass.
samplesNumber30The amount of samples per pixel. Should not be a multiple of the ring count.
ringsNumber4The amount of spiral turns in the occlusion sampling pattern. Should be a prime number.
distanceThresholdNumber1Deprecated in favor of worldDistanceThreshold. A global distance threshold at which the occlusion effect starts to fade out. Range [0.0, 1.0].
distanceFalloffNumber0.0Deprecated in favor of worldDistanceFalloff. The distance falloff. Influences the smoothness of the overall occlusion cutoff. Range [0.0, 1.0].
worldDistanceThresholdNumberundefinedThe world distance threshold at which the occlusion effect starts to fade out.
worldDistanceFalloffNumberundefinedThe world distance falloff. Influences the smoothness of the occlusion cutoff.
rangeThresholdNumber0.5Deprecated in favor of worldProximityThreshold. A local occlusion range threshold at which the occlusion starts to fade out. Range [0.0, 1.0].
rangeFalloffNumber0.1Deprecated in favor of worldProximityFalloff. The occlusion range falloff. Influences the smoothness of the proximity cutoff. Range [0.0, 1.0].
worldProximityThresholdNumberundefinedThe world proximity threshold at which the occlusion starts to fade out.
worldProximityFalloffNumberundefinedThe world proximity falloff. Influences the smoothness of the proximity cutoff.
minRadiusScaleNumber0.1The minimum radius scale.
luminanceInfluenceNumber0.9Determines how much the luminance of the scene influences the ambient occlusion.
radiusNumber20The occlusion sampling radius, expressed as a scale relative to the resolution. Range [1e-6, 1.0].
intensityNumber1.0The intensity of the ambient occlusion.
biasNumber0.5An 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. Inherits <EffectComposer resolutionScale> if set.
resolutionXNumberResolution.AUTO_SIZEThe render width.
resolutionYNumberResolution.AUTO_SIZEThe render height.