October 25, 2011

nicer SSAO

yet another screen-space ambient occlusion shader.
original technique is HERE by Arkano22.
I tuned it up a bit adding my circular texture sampling and pattern sample filtering.
Right now it is the best depth-only based SSAO I have come across.

another screenshot with noise dithering and "garea = 0.4;" instead of "garea = 0.6;" to lighten scene a bit.

scene with and without ssao:

glsl frag shader HERE

and blend file HERE


  1. Excuse me martinsh, but the only thing i get from your filter is a bit of black cell noise and an overall darker tone on the blend provided. When I try it on a custom scene, the filter turns the screenspace completely black. I am currently using 2.63 and a nvidia GT 540M. Could you give me a tip on how to make your filter work?

    1. Hi,
      a screenshot of how the blend looks for you would help me a lot.
      also can you give me more detail about your system specs? GPU seems to be fine for it to run. I made it on even lower-end GPU. does something show up in console?

  2. This comment has been removed by the author.

    1. Sorry I deleted my own comment! I was saying: thanks again for sharing this great shader, the vars permit fine tuning and it's awesome! The only problem I'm experiencing it's z-fighting with diffuse textures. I edited all vars but with no success. Can it be related to far/near algorithm? Thanks!

    2. Hi Antonio,
      it is depth buffer related. Depending how your engine "translates" the z-buffer the results can vary significantly. if you posted a screenshot how it looks for you perhaps I can help you :)

    3. Thanks Martins for the very quick reply, it's almost impossible to capture the glitch because it's like diagonal black/gray lines flickering on my model, when shader it's applied. I also noticed that effect is visible onlu when I use a post-production glsl effect that use Z-depth so, maybe, my problem is tied to the use of z-depth. I'll do more tests, thanks!