Screen Space Ambient Occlusion

Ambient Occlusion

Ambient occlusion is typically defined as a measure of the amount of light reaching any particular point from all directions, or from
a hemisphere tangent to the surface on which the point is embedded. Variations on ambient occlusion general attempt to bring higher
dimensional information to the point. Aperture occlusion adds a vector pointing to the widest gap to the surrounding environment, and an angle
describing the width of the aperture. Spherical Harmonic maps encode accessibility information modulated continuously around the point.

Accessibility Shading

Accessibility shading preceded screen space methods. It was introduced into film production by Hayden Landis of ILM, and described in a Siggraph
course in 2002 http://www.renderman.org/RMR/Books/sig02.course16.pdf.gz.
A good overview and history of these methods are in Hayden’s presentation, and can also be found
in Chapter 17 of GPU Gems.
Accessibility information is stored on a mesh and used to modify the lighting calculation during rasterization.
An up to date implementation on GPU is described in this paper
by Samuli Laine and Tero Karras of nVidia.

Screen Space Ambient Occlusion

Screen Space Ambient Occlusion is based on the notion that the depth buffer contains much of the information needed to
compute lighting similar to accessibility shading.

The technique was popularized by Crytek’s Martin Mittring in a presentation at Siggraph 2007, see section 8.5.4.3 for details.
A full screen render pass is performed wherein z-buffer data is sampled around each pixel and a darkening value is computed based on depth differences.
Sampling occurs randomly in three space in a sphere around each pixel, and darkening is proportional to the number of sampled occluders.
Here’s an example of their results:

Some early debate on the technique occurred on gamedev.net,
with the initial discussion here resulting in an algorithm and
techniques for resolving sampling artifacts that occur on flat gradients in the scene.
Ultimately a nice 4k demo using the technique on rendered Julia fractals is presented.
This method, based strictly on depth sampling, works best with this sort of highly detailed geometry.

25 May 2008. A new version of the demo Kindercrasher has been posted.
Inigo has a page of explanation including some shader fragments here.


RGBA (Iñigo Quilez) of kinernoiser and kindercrasher fame has a treasure trove
of ambient occlusion experimentation and research references.
This explanation of the lighting in Plastic 195/95/256
is an example of the quality, in depth information you’ll find there.



Plastic by RGBA.


Robust methods for achieving hardware accelerated AO are presented in the
influential paper Hardware Accelerated Ambient Occlusion Techniques on GPUs by Perumaal Shanmugam and
Okan Arikan. Unlike most presentations, this method yields results similar to ground truth AO calculations.
In this paper, the AO search is split into two phases, one for high frequency near detail, and another phase for low frequency detail with a wider search.
The second phase in particular is of interest, it allows large objects to occlude each other as they pass.
The low frequency pass is described by this image:

Peter-Pike Sloan et al., have recently published Image-Based Proxy Accumulation for Real-Time Soft Global Illumination which
works by accumulating shadowing and indirect illumination in screen space splats. As with other AO methods, a further pass is necessary to introduce direct illumination.

A very cheap method is developed within Blender by Mike Pan, with convincing results.
The effect is subjectively a too strong at deep depth discontinuities, but given the simplicity of the approach, it could be considered
acceptable. The image on the left is the simple flat shaded image for comparison. The trick involved here is very clever – the depth buffer
is blurred, then subtracted from the original depth buffer. The image is clamped and scaled to reduce artifacts and subtracted from the original image.
This method is about a zillion times cheaper than any of the others presented on this page.

This technique and several variations are discussed in detail in the Siggraph 2006
paper, Image Enhancement
by Unsharp Masking the Depth Buffer
. Several NPR effects are achieved by mapping the depth discontinuities to look up tables to get
Gooch like effects. For more, see the project website.

Another technique mentioned by Ignacio in the comments: Ambient Occlusive Crease Shading, by Fox & Compton.
For each pixel, nearby pixels are sampled, and dot products between normals are scaled by distance between samples to compute occlusion. The resulting pass is
bloomed, blurred, and contrast enhanced before being applied to the framebuffer. The page includes the pixel shader doing
the work.

Via Ziggyware: Alex Urbano Alvarez has generously released an SSAO implementation for XNA GS 2.


The movie shows that in general screen space ambient occlusion makes for a lively and attractive image. It also highlights artifacts
that can result from not taking linear depth into account. The effect here is not scaling well with depth; shadows are uniformly thick no matter how
far the object is from the camera, note that the shadow halo around the top of the pillars is as wide as the halo on the bottom of the pillars. The
effect is not taking depth discontinuity into account. This variation of the effect could be further developed for NPR applications; for example, with
some thresholding an attractive toon shader could result.

This thread at BlitzBasic shows what I believe to be the same algorithm as Alvarez.
The artifacts in the game example late in the thread are largely hidden by the lighting in the scene. It seems if you are not after a photorealistic result,
this algorithm can sweeten your look.

Aras Pranckevičius has a practical discussion

on using blur on lower resolution ambient occlusion buffers to improve the look of a screen space pass.

DirectToVideo has an in-depth overview of the techniques utilized in FrameRanger.



A Siggraph course presenting techniques used in StarCraft II. StarCraft’s unique twist is that they use SSAO to fake low frequency diffuse inter-reflection as well as crease emphasis. They accomplish it by taking samples at two distances; near samples for creasing, and far samples for fake diffuse inter-reflection.

This Russian tutorial (translated) contains several code samples, and improvements based on data available from G-buffers.
http://steps3d.narod.ru/tutorials/ssao-tutorial.html, as well as an OpenGL test program.

An article with some phonecam capture at GDC08 (slides). This lecture does a review of multiple depth-buffer-based ambient occlusion techniques. Three of the described algorithms are ray-marching in the depth buffer, an algorithm based on accumulating solid angles, and a new hybrid method called tangent tracing. Real-time demonstrations included.

More information.


Thanks to everyone’s contributions in the comments!

Post to Twitter Post to Delicious Post to Facebook

  • Is your bathroom small? Are you trying to figure out how to accomplish magic with small space bathroom remodeling? You’ll be amazed at what you can accomplish by using a few tips form the pros.
  • Hi, thanks for this compilation of links ! I noticed a few broken links that you might want to fix :

    Iñigo quilez is now : http://iquilezles.org/www/articles/ssao/ssao.htm
    Crease shading is now : http://www.shalinor.com/research.html

    Cheers
  • robertjekob
    .net is one of the most user friendly and yet so reliable platform for .net development. <a href="http://www.aegisisc.com/net-developers.ht... developers can get help of simplified programming flow with .net.
  • This page was a great resource for SSAO links. I have written an online Flash implementation in AS3 utilizing PixelBender which you can check out here :) http://kode80.com/ssao2
  • admin
    nVidia can impose SSAO on a game. It looks good, although I'm not entirely sure it's kosher to go back in and modify a game's look that way without involving the developers.

    http://www.nzone.com/object/nzone_ambientocclus...

    I must admit that SSAO provides visible improvement in some of the examples they've posted. If a driver provides anti-aliasing or texture filtering, that's legit; those definitely provide a qualitative improvement to an image. SSAO however invokes an aesthetic modification on the game however.

    I imagine that I would appreciate it in the case that a game was not strongly art directed, but if a game had a strong aesthetic sense, this seems like maybe not such a good thing.

    What do you think?
  • Seen the new horizon-based AO stuff, extremely neat. Though it's definitely a bit slower than regular SSAO, yet still real-time :)
  • admin
    Newly posted, a chapter from a Siggraph course on recent rendering techniques:

    http://ati.amd.com/developer/SIGGRAPH08%5CChapt...

    on StarCraft II's use of SSAO. The unique twist is that they use SSAO to fake low frequency diffuse inter-reflection as well as crease emphasis. They accomplish it by taking samples at two distances; near samples for creasing, and far samples for fake diffuse inter-reflection.
  • admin
    nVidia has posted a whitepaper and demo on SSAO.

    http://developer.download.nvidia.com/SDK/10.5/d...

    http://developer.download.nvidia.com/SDK/10.5/d...

    Their method uses horizon-split ambient occlusion, but steps in screen-space, not eye-space. They use bilateral filtering to reduce the typical depth discontinuity artifacts seen with SSAO.

    There are some notes here on HSAO.

    http://levelofdetail.wordpress.com/2008/02/27/r...
  • admin
    There's an excellent tutorial, in Russian, here:

    http://steps3d.narod.ru/tutorials/ssao-tutorial...

    Google translated:

    http://translate.google.com/translate?u=http%3A...

    It contains several code samples, and improvements based on data available from G-buffers.

    Finally there's a full OpenGL based test program where you can play with shaders and algorithms.
  • admin
    Here's nullsquared's new demo. The shots look pretty nice!

    http://www.ogre3d.org/phpBB2/viewtopic.php?t=42350
  • nullsquared
    Well, not the "same" post, I deleted the old one, but I mean the same title xD
  • nullsquared
    Just figured I might mention I just released the actual Ogre SSAO demo. It includes rather updated code, that I'd say looks and feels a lot better. Same post in the Ogre showcase forum.
  • admin
    I like your implementation on the Ogre forum, it's very easy to understand, the dithering from the texture is a nice touch. Have you tried bilateral filtering as a method of reducing halos? Jeremey Shopf suggests it here - http://levelofdetail.wordpress.com/2007/11/01/i... . It seems like a good solution.
  • nullsquared
    Ah, very nice :). Sorry, I get a little defensive of cool stuff (even when it's not mine xD) when there's a misconception. Anyways, I've been playing with some SSAO of my own, if anyone would like a look: http://www.ogre3d.org/phpBB2/viewtopic.php?t=41320
  • admin
    nullsquared: I modified the last paragraph to make it clear that I am talking about the implementation shown in the video.
  • nullsquared
    The last paragraph there with the "limitations" is very, very crappy. First of all, ghosting can be practically 100% eliminated using a correct quadratic falloff for the occlusion. Second, the technique scales very, very well with depth (if you're using a linear view-space depth buffer, that is) - both far away and up close objects occlude themselves and others rather correctly. And third, the shadows are only uniform if your sampling sphere is in screen-space, which it shouldn't be. With a view-space random sampling sphere for dithering, the shadows are NOT uniform.
  • cowness
    Here's another algorithm... this one's for a 3DSMax renderer though, but anyway, the pseudo-code should look the same...

    http://www.malmer.nu/index.php/2008-04-09_ssao-...
  • admin
  • admin
    An article with some phonecam capture at GDC08

    http://www.4gamer.net/games/047/G004713/2008022...

    The official description of the talk is:

    Real-Time Ambient Occlusion
    14:50-15:10, Room 3004 (West Hall), Friday, Feb 22
    NVIDIA Speaker: Miguel Sainz
    This lecture does a review of multiple depth-buffer-based ambient occlusion techniques. Three of the described algorithms are ray-marching in the depth buffer, an algorithm based on accumulating solid angles, and a new hybrid method called tangent tracing. Real-time demonstrations included!

    via this page, I've found the slides!
  • admin
    Level of Detail has a thread going on SSAO.

    http://levelofdetail.wordpress.com/2008/02/10/2...
  • admin
    Thanks Eric! I do like watching kindernoiser in any case :)

    I hadn't spotted the SSAO article at Wikipedia, I like the idea of documenting algorithms and research there.
  • Two more of interest:

    http://en.wikipedia.org/wiki/Screen_Space_Ambie... - by the actual algorithm designer at Crytek.

    http://rgba.scenesp.org/iq/computer/articles/ss... - reverse engineered, as it were. I don't think he's got it quite right: a flat surface will shadow itself half the time if you count all samples in the sphere, so I think you want to throw out half the occlusions and use what's left. But, he's close.
  • admin
    Thanks for the link Ignacio! I've updated the survey.
  • Another alternative discussed at gd-algorithms recently is:

    Ambient Occlusive Crease Shading
    http://www.shalinor.com/code.html

    the main difference is that it does not only use the depth buffer, but also the screen space normals, which are generally available in deferred shading engines.
blog comments powered by Disqus

Bad Behavior has blocked 800 access attempts in the last 7 days.