Screen Space Ambient Occlusion (SSAO)
Illumination in a scene is a general term for the light that originates at the light sources and arrives at object surfaces. However, when light hits any surface, unless it is completely absorptive, light bounces off from the surfaces and hits other. This process keeps on going until the intensity of the light becomes zero. In the scenario, when light directly hits a surface from light source, we call it as Direct Illumination. When lights a surfaces and bounces off, the hit surface becomes an indirectly a light source i.e. it indirectly illuminates the scene; this is known is Indirect Illumination. Generally, developers Direct Illumination as Local Illumination and indirect illumination as Global Illumination.
Estimating global illumination is an expensive task and various techniques and tricks have been developed and used for estimating this. Ray Tacing is one of the technique which is used extensively in motion-picture industry for creating realistic images. In Ray Tracing, we shoot a ray and let it bounce between surfaces until to a certain number of bounce counts or till the intensity of the light attenuates to zero. This is a very expensive method, as rays are casted and traced multiple times to calculate the color of a single pixel.
Ray Tracing approximates to a very close effect of global illumination but it takes huge amount of time to render. Due to this, Ray Tracing is not a good option for real time rendering.
Ambient Occlusion is a well known computer graphics method for approximating global illumination in real time rendering techniques. There are various methods have been developed to approximate this. Few of them are:
1. Object Space Ambient Occlusion : In this we preprocess/bake the ambient occlusion for static meshes. This uses ray tracing technique to approximate the ambient occlusion before the actual draw calls. This makes it ineffective for moving geometries or moving lights.
2. Screen Space Ambient Occlusion (SSAO) : This is a multi-pass rendering algorithm which uses depth texture, normal texture and view space position of the fragments to calculate the ambient occlusion texture, using which we calculate the final lighting for the scene.
3. Horizon-Based Ambient Occlusion (HBAO) : This is also a screen space technique which uses Horizon mapping to approximate the ambient occlusion. Horizon mapping uses an azimuth angle to calculate this.
4. Voxel Based Global Illumination (VXGI) : This technique is developed by NVIDIA and it precomputes the diffuse lighting in various layers. Higher the layer gives better results.
Screen Space Ambient Occlusion
Screen Space algorithm uses information from the neighbouring pixels of the fragment. It uses random sample point on the hemisphere oriented along the normal of the surface/fragment.
1. Project each sample point into the screen space to get the coordinates
2. sample the Depth Buffer
3. If the sample position is behind the sample depth (i.e. inside geometry), it contributes to the occlusion factor.
Screen Space Ambient Occlusion - Update