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
Name | Type | Default | Description |
blendFunction | BlendFunction | BlendFunction.MULTIPLY | The blend function of this effect. |
distanceScaling | Boolean | true | Enables or disables distance-based radius scaling. |
depthAwareUpsampling | Boolean | true | Enables or disables depth-aware upsampling. Has no effect if WebGL 2 is not supported. |
normalDepthBuffer | Texture | null | A texture that contains downsampled scene normals and depth. See DepthDownsamplingPass |
samples | Number | 9 | The amount of samples per pixel. Should not be a multiple of the ring count. |
rings | Number | 7 | The amount of spiral turns in the occlusion sampling pattern. Should be a prime number. |
distanceThreshold | Number | 0.97 | A global distance threshold at which the occlusion effect starts to fade out. Range [0.0, 1.0]. |
distanceFalloff | Number | 0.03 | The distance falloff. Influences the smoothness of the overall occlusion cutoff. Range [0.0, 1.0]. |
rangeThreshold | Number | 0.0005 | A local occlusion range threshold at which the occlusion starts to fade out. Range [0.0, 1.0]. |
rangeFalloff | Number | 0.001 | The occlusion range falloff. Influences the smoothness of the proximity cutoff. Range [0.0, 1.0]. |
minRadiusScale | Number | 0.33 | The minimum radius scale. Has no effect if distance scaling is disabled. |
luminanceInfluence | Number | 0.7 | Determines how much the luminance of the scene influences the ambient occlusion. |
radius | Number | 0.1825 | The occlusion sampling radius, expressed as a resolution independent scale. Range [1e-6, 1.0]. |
intensity | Number | 1.0 | The intensity of the ambient occlusion. |
bias | Number | 0.025 | An occlusion bias. Eliminates artifacts caused by depth discontinuities. |
fade | Number | 0.01 | Influences the smoothness of the shadows. A lower value results in higher contrast. |
color | Color | null | The color of the ambient occlusion. |
resolutionScale | Number | 1.0 | The resolution scale. |
width | Number | Resizer.AUTO_SIZE | The render width. |
height | Number | Resizer.AUTO_SIZE | The render height. |