SSAO – Screen Space Ambient Occlusion

I recently implemented SSAO which the acronym for “Screen Space Ambient Occlusion”, which in turn is a way of simulating ambient occlusion in screen space.

Normally real time games only light that directly hits a surface is used in lighting calculations. However, in the real world light bounces of surfaces and interacts with the environment in a multitude of ways. Ambient occlusion is a way of simulating all this bouncing around by estimating how much light will be able to reach a point in the world. This was something only used in offline (non real time) rendering and only used in games as precalculated light maps or similar.

Now that graphical processors can crunch billions of calculations per second it is finally possible to try things like Ambient Occlusion in real time. The way it works is simply by using the depth map (which stores distance from screen to pixel) of the rendered scene and on a per pixel basis checking neighboring pixels if they are in front or behind the current. By doing this for enough pixels one can determine an occlusion value for the current pixel and use that as a value for the ambient occlusion.

Because ambient occlusion in itself is an approximation of a global lighting model, ssao is an approximation of an approximation. So in my approach I have tried to make it as nice and fast as possible and ignored trying to copy any proper formulas. The result is a quite fast algorithm that gives less then 20% drop in frame rate (at the time, still more things to imporove!) and gives a pretty nice results! It also allows the artists to skip alot of extra lights that have previously been added only to simulate ambient occlusion and might therefore even improve the frame rate in the end!