A Comparative Study of Screen-Space Ambient Occlusion Methods
In this report we present a comparison between six screen-space ambient occlusion (SSAO) methods. The aim is to compare their strengths and weaknesses and ultimately to ﬁnd a superior method. The methods are chosen to differ algorithmically to get the broadest overview as possible. We ﬁnd that a method known as Alchemy AO is the superior approach. The report also includes discussions of topics related to the ﬁeld of ambient occlusion in general.
As the abstract above describes, we implemented six different approaches to screen-space ambient occlusion and compared the results in terms of quality and performance. Please refer to the report for a detailed coverage of the topic. In the following sections I will give a short overview of the study. The intention is to give a taste of the report. Unlike the report, I will assume that the reader is familiar with ambient occlusion theory. A good understanding of real-time computer graphics is also recommended.
The Candidate Models
Six models were selected for the comparison. The models have been chosen to be as algorithmically different as possible. A consequence hereof is that the models also span a broad timeline. I will go directly into detail with each candidate method in the next subsections.
CryEngine 2 AO
As the heading indicates, it was introduced in CryEngine 2 by Crytek [Mittring 2007]. It works by sampling randomly distributed points in a sphere at each pixel location, p. The sampling is done directly in screen-space. Each sample point, s, is then projected onto the scene surface using the depth buffer. The depth value of the projected sample point, sd, is then compared against the original depth value, sz, to determine if the sample is occluded or visible. The ratio of visible to occluded sample points is used to approximate AO. Consult Figure 2.1 for reference.
The CryEngine 2 AO method is computationally cheap. In our implementation we use 24 samples per pixel in our performant configuration. However, the CryEngine only uses 8 samples per pixel. Furthermore, those 8 samples are generated by randomly rotating a cube and then use the cube’s 8 corners as sample points. I suspect that the time saved using this fast sampling method is instead spent to blur the result in order to smoothen out noise artifacts.
StarCraft II AO
Another implementation that came to be during the development of a video game, namely StarCraft II [Filion and McNaughton 2008]. This approach uses a similar technique to that found in CryEngine 2 AO but with some key differences. First of all, the samples are generated in a hemisphere which is true to the theoretical formulation of AO. Furthermore, samples are generated in world-space and then transformed into screen-space. See Figure 2.2 for reference.
Note that in the CryEngine 2 AO approach, at least half of the samples end up occluded since the sampling is done in a sphere around p. Effectively, half of the samples are wasted. StarCraft II AO does not have this problem since it samples in a hemisphere.
Horizon-based AO with Ray Marching
This method works by ray-marching in screen-space through the depth buffer to find the angle of the free horizon, h [Bavoil et al. 2008]. See Figure 2.3 for a side view. First, a ray direction is chosen perpendicular to the view direction (the gray dashed line). Then, several samples are taken along said ray in progression. At each step, the depth value is read. If the depth value is lower than at the previous step, then the horizon angle is updated. Several rays are cast and the average free horizon angle, h, is then used to approximate the AO factor.
This method produces high quality results. Unfortunately, it tends to be slow since a lot of samples have to be taken in each ray direction.
An AO approach that is based on a volume integral [Loos and Sloan 2010]. The AO term will be approximated the ratio of visible to occluded volume. The integral is over a sphere positioned the pixel position, p. Said integral is then evaluated using line samples as shown in Figure 2.4. Samples are generated at random on a disc that is perpendicular to the view direction. Each sample position represents a volumetric column slice of the sphere. In turn, each volumetric slice is represented by a simple line segment (see Figure 2.4). The sample position is then projected onto the surface using the depth buffer. Now the visible part of the line segment can be calculated using simple trigonometry.
The continuous nature of the line samples used in Volumetric Obscurance makes this method temporally coherent. That is, a slight variation in viewing direction or surface position will only cause a gradual change in the AO term. The point sample-based methods can suffer from pop-in artifacts when a low number of samples are used.
This method projects sample points, s, generated on a disk onto the scene surface. Each s is then used to construct the vector v as s−p. See Figure 2.5 for a reference. The average dot product between each v and n can then be used to compute the AO factor [McGuire et al. 2011].
Theoretically, the method works by defining a clever falloff function which simplifies the integral in the AO term. The method gains its efficiency from the fact that it is cheap to compute the vectors v.
The study concludes that Alchemy AO has the best quality-performance ratio. A key advantage of this method is that all accepted samples (the green rectangles in Figure 2.5) are visible. I.e., each accepted sample is indirectly a (rough) measure of the angle of the free horizon, h, as seen in [Bavoil et al. 2008]. Thus the sampling strategy makes effective use of every accepted sample. Consequently, only a few samples are needed overall. Contrast this to the point or volume sampling methods where many samples are needed to compute a reasonable visible-occluded ratio.
Unreal Engine 4 AO
This approach also attempts to measure the angle of the free horizon, h, as seen in [Bavoil et al. 2008]. The difference is that samples are grouped in pairs, s1 and s2, as seen in Figure 2.6. Like in [McGuire et al. 2011], the samples are first generated on a disk and then projected onto the scene surface. Then h is approximated as the angle between the vectors s1−p and s2−p [Mittring 2012].
For the same reason as with Alchemy AO, this method only needs a few samples to produce quality results. Additionally, the pairing scheme can be used to mitigate depth buffer discontinuities as explained in the report.
- 2008. Image-space Horizon-based Ambient Occlusion. In ACM SIGGRAPH 2008 Talks (SIGGRAPH '08). ACM, New York, NY, USA, 22:1–22:1. DOI=10.1145/1401032.1401061..
- 2008. Effects & Techniques. In ACM SIGGRAPH 2008 Games (SIGGRAPH '08). ACM, New York, NY, USA, 133–164. DOI=10.1145/1404435.1404441..
- 2010. Volumetric Obscurance. In Proceedings of the 2010 ACM SIGGRAPH Symposium on Interactive 3D Graphics and Games (I3D '10). ACM, New York, NY, USA, 151–156. DOI=10.1145/1730804.1730829..
- 2011. The Alchemy Screen-space Ambient Obscurance Algorithm. In Proceedings of the ACM SIGGRAPH Symposium on High Performance Graphics (HPG '11). ACM, New York, NY, USA, 25–32. DOI=10.1145/2018323.2018327..
- 2012. The Technology Behind the "Unreal Engine 4 Elemental Demo". In Advances in Real-Time Rendering in 3D Graphics and Games Course ((SIGGRAPH '12)). ACM, Los Angeles Convention Center..
- 2007. Finding Next Gen: CryEngine 2. In ACM SIGGRAPH 2007 Courses (SIGGRAPH '07). ACM, New York, NY, USA, 97–121. DOI=10.1145/1281500.1281671..