Screen space ambient occlusion (SSAO) is widely used in modern PC and console games to approximate global illumination effects. It gives good results when approximating occlusion in a uniform lighting environment, such as an outdoor scene on an overcast day. Screen Space Directional Occlusion (SSDO) is a technique that was recently introduced to improve upon the visual quality of SSAO. It works by calculating occlusion and environmental lighting at the same time. However, due to its significant computational cost, it is only practical to use SSDO with a small number of dynamic light sources or a global lighting environment stored in a cube map. The proposed algorithm allows dynamic light sources to take advantage of local occlusion information in a deferred shading pipeline, commonly found in modern games. Local occlusion is approximated in screen space with second order spherical harmonics and stored in a render target. During the lighting pass, local occlusion can be reconstructed with a single texture fetch and a dot product. The result is a significant visual improvement over standard SSAO and a speed improvement over SSDO.
Directional Occlusion Accumulation
Occlusion information is calculated per pixel using world space positions and normals, similar to the regular SSDO algorithm. For every pixel on the screen, its world space position P and world space normal n are taken from the GBuffer. Then, a sphere with a radius r is constructed around P and its projection onto the screen is approximated with a disc. Several sample points are then chosen randomly within this disc and projected onto the scene to calculate their world space positions Si. Now a vector from P to Si represents a potential occlusion direction Vs. The result of the occlusion check for each Vs is weighted and accumulated using a two-band spherical harmonic basis. The weight of each occlusion direction is inversely proportional to the distance between P and Si. Only samples that are in front of P (such that dot(n,Vs) > 0) are considered in this process. The result is then filtered using an edge-preserving blur algorithm to reduce the noise introduced by stochastic sampling.
In the above figure, sample points S1-3 contribute to occlusion of P, but points S4-5 don’t.
Here is how the directional occlusion buffer looks for one of the frames in the earlier video:
Integration into Deferred Shading Pipeline
The DSSDO algorithm shares many implementation details with standard SSAO, such as rendering at reduced resolution, edge-preserving filtering and up-sampling. This makes it a simple drop-in replacement for SSAO in existing rendering pipelines. When lighting is calculated for the point P during the deferred shading stage, its local occlusion approximation is fetched from the occlusion accumulation texture. Light attenuation is then calculated using a simple second order spherical harmonic lookup with the light vector L (just a single dot product in the light shader).
The DSSDO algorithm is capable of achieving higher quality lighting than regular SSAO, but not as high as can be achieved with SSDO. However, it is much cheaper than SSDO and works well with many local light sources in a deferred shading pipeline.
Its performance characteristics make it a practical drop-in replacement for SSAO in computer games on current generation hardware.
Performance on NVidia 8800 GPU: Accumulation at 1280x720: 16 samples - 2.6ms, 8 samples - 1.4ms; Accumulation at 640x360: 16 samples - 1.0ms, 8 samples - 0.7ms; Edge-preserving blur at 1280x720: 9x9 - 2.3ms, 5x5 - 1.3ms Edge-preserving blur at 640x360: 9x9 - 0.9ms, 5x5 - 0.7ms
All of the issues which apply to standard screen space ambient occlusion algorithms also apply to DSSDO.
Strong normal maps may interfere with accumulation and filtering stages. In this case it may be necessary to generate a separate buffer with normals, based on the depth buffer.