Simple Screen-Space Ambient Occlusion
Using Screen-Space Ambient Occlusion (SSAO)
Screen-Space Ambient Occlusion is a post-process that coarsely approximates a shadowing effect from ambient light.
Its practical effect is a better perception of spatial relations between objects in.
Screen-Space Ambient Occlusion can be enabled with the Environment node's attribute "SSAO".
The attribute "SSAOamount" determines the strength of the SSAO effect.
The attributes "SSAOblurDepthTreshold" and "SSAOradius" must be tweaked according to the scale of the scene.
<Environment id='myEnv' SSAO='true' SSAOamount='0.3' SSAOblurDepthTreshold='1.0' SSAOradius='0.7'> <Environment>
SSAO disabled (left) and enabled (right)
How it works
The post-processing shader measures the amount of occlusion for each pixel.
It does so by sampling a spherical kernel where the size of the kernel depends on the world-space distance of the pixel to the camera.
As a result, the radius in which the amount of ambient occlusion is determined is specified in world-space (attribute "SSAOradius").
Thus, the sampling radius always stays the same (relative to the scene) if the camera is moved.
In order to keep the number of samples for the ambient occlusion low, each pixel is sampled with a different random seed.
This sparse sampling scheme results in noise that is removed with a depth-aware averaging filter.
This filter only incorporates neigboring pixels that are not too far away to prevent blurring across edges.
The attribute "SSAOblurDepthTreshold" defines how big the depth difference (in world space) is allowed to be.
Back to page top ⤴
Get this X3DOM example:
Read more about the X3DOM nodes used in this tutorial: