Screen Space Ambient Occlusion

Recently I made an attempt to code some examples of this technique based on existing on-line code.

My results were mixed, but interesting.
Two of the demos don’t really use “SSAO” but rather more of an edge detection algorithm that looks similar.

Performance is pretty bad…my intent was to get things working and learn the techniques rather than optimize. An obvious optimization would be to use smaller off screen FBO’s for the SSAO and then scale up after.

I cobbled together my own Render to Texture class also from examples I found because I needed a Depth attachment which current OF examples didn’t have.

There’s also an updated and slightly modified ofxShader addon that you’ll probably need to use.

The examples were based on these links:
http://www.idevgames.com/forum/showthre-…-149&page=4
http://mattisb0rgen.wordpress.com/2009/-…-ao-part-1/
http://iquilezles.org/www/articles/ssao/ssao.htm
http://www.gamerendering.com/category/l-…–lighting/
http://www.opengl.org/discussion-boards-…-98&fpart=2

If you make any improvements or optimizations please send them to me, or if you have better examples please share as well :slight_smile:

One last thing - I found that for most of the examples using a small dithering radius caused really bad banding. I think this is normal - a result of the low freq. sampling (moiré effect). However I’d love to improve this somehow if anyone has any ideas…

You can find the code here, with Linux Codeblocks projects, but very easy to convert to win32 and osx. Make sure you have the following addons: ofxVectorMath, ofx3DUtils, ofx3DModelLoader and my version of ofxShader:

http://digitalstarcode.googlecode.com/f-…-ls-0.1.zip

this is a screenshot of an implementation i did (not optimized for performance either):

its pretty much the same as described here (i also use my own, messy rendertarget classes):
http://www.gamerendering.com/2009/01/14/ssao/

Looks nice…my first picture above is using pretty much the same shader…I also posted the same link (permalink which is why it looks different).

One thing I didn’t manage to do was find a blur shader liked. I tried the ones they used in their project (x and y lateral blurs) but didn’t get satisfactory results …but it’s always subjective I guess. Is that model highly tesselated? If you can be bothered to post your code I’d be curious to check it out, messy or not.

cheers

I am at work right now, but I might prepare a small example later tonight, the polygoncount on that is pretty high, i also used the blur shaders provided with the sample on the site and as you can see with tweaking the settings a little bit you can achieve really good results. anyways. ssao is way to expensive for (realtime use) the results you are getting in my opinion.