Screen Space Ambient Occlusion
How to take the samples is a big concern as it will impact what will occlude and how much. The currently best implementations takes random samples in a hemisphere in the direction of the normal. This limits the amount of self occlusion. Another problem is that if you only take the depth into consideration then a flat surface might occlude itself because of the perspective. By also comparing the normal when calculating the AO, this problem will go away.
One of the hard parts of implementing SSAO is to choose the correct smoothing technique. Because of the big cost of taking occlusion samples you want to take as few samples as possible but this will give much noise in the SSAO so the result needs smoothing. Just doing a simple gaussian blur will not be good as the blur will make the SSAO bleed. Instead a blur that considers the depth and/or normals is needed. One of those is the bilateral filter which often is used in combination with SSAO.
The steps of a simple SSAO implementation:
- Render the scene. Save the linear depth in a texture. Save the normals in eye space in a texture.
- Render a full screen quad with the SSAO shader. Save the result to a texture.
- Blur the result in X
- Blur the result in Y
- Blend the blurred SSAO texture with the scene, or use it directly when rendering the scene.
An optimization is to render the SSAO in a lower resolution than the screen and upsample it when blurring. Another optimization is to store both the normals and the depth in a single texture.
Probably one of the best implementations of SSAO is this one by NVIDIA (although it’ rather slow). The SDK 10 has a paper about the technique and also source code!
http://developer.download.nvidia.com/SDK/10.5/direct3d/samples.html
And here’s three papers/presentations from NVIDIA describing their SSAO in detail:
http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_Ambient_Occlusion.pdf
http://developer.download.nvidia.com/presentations/2008/SIGGRAPH/HBAO_SIG08b.pdf
http://developer.download.nvidia.com/SDK/10.5/direct3d/Source/ScreenSpaceAO/doc/ScreenSpace AO.pdf
Some information of how Starcraft II will use SSAO is included in this paper ( see chapter 5.5 ):
http://ati.amd.com/developer/SIGGRAPH08/Chapter05-Filion-StarCraftII.pdf
A link to a description of the SSAO implementation in the game Two Worlds:
http://www.drobot.org/pub/GCDC_SSAO_RP_29_08.pdf
The paper and game that started it all (look in the chapter 8.5.4.3):
http://delivery.acm.org/10.1145/1290000/1281671/p97-mittring.pdf?key1=1281671&key2=9942678811&coll=ACM&dl=ACM&CFID=15151515&CFTOKEN=6184618
One of the papers that probably inspired the Crysis team:
http://perumaal.googlepages.com/
A simple but smart SSAO implementation, here with well commented shader source code:
http://rgba.scenesp.org/iq/computer/articles/ssao/ssao.htm
A gamedev.net thread with lots of discussion about SSAO
http://www.gamedev.net/community/forums/topic.asp?topic_id=463075
5 Comments »
RSS feed for comments on this post. TrackBack URI



























Hej,
Jag har jobbat endel med SSAO i softwarerendering, och började själv använda mig av normalen för jag tyckte det som jag såg på gamedev var för dåligt och inkorrekt. Roligt att se att nvidia använder sig av samma liknande teknik nu lite senare. Skrev mitt jox på http://www.malmer.nu i april. Nvidias whitepaper står det september på…weee! Inte för att jag inbillar mig att nvidia läst vad jag skrivit, för det är ju en naturlig förlängning för att göra så det inte ser ut som skräp.
Kommer säkert kolla över min kod lite och plocka andra förbättringar från nvidias papper nu när jag sett att det finns. Kommer nog också lägga in lite blur också, även om det inte direkt behövs då vi kör mycket fler samples per pixel eftersom det är softwarerendering i 3dsmax och inget behov av realtid. Tack för länken!
Kan dock tipsa om min lilla post om energy-minimization för att plocka samples. Gör stor skillnad.
http://www.malmer.nu/
Yes, I used that energy-minimization algorithm from your page to get a better result in my SSAO implementation and it worked very well.
cool explanation and web page! I was wondering if you are going to release a demo with source so others may learn from a working example.
mm.. love this ..
Now you need to extend your methods for SSDO: http://www.mpi-inf.mpg.de/~ritschel/Papers/SSDO.pdf