new and fast SSAO

This is 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. It is mostly artifact-free and quite fast. It is made on a slow Mobility Radeon GPU so it should run fine on any decent computer. But anyway it would be nice if you guys could take a look at it and test it. Here is the 2D Filter : (last one)
and blend: (1st version) (current one)
a picture:

an animated gif:

You may use it anyway you like.
Have fun.

No sample blend? That would really help me out. In any case, it looks awesome. I’m going to check it out. Great job, martinsh. :smiley:

P.S. Could you possibly also upload a couple of pics of what that scene looks like textured without the filter, and what it looks like filtered? Unless everything in the scene is white…

Hey, thanks SolarLune!
I will post a blend soon.

without ssao
with ssao
ssao pass only

… Curses. Now I need to make a game in an abandoned subway. LOL - That looks awesome. Is that part of a game project? Or is it just a scene that you had lying around?

Thanks Martinsh! :slight_smile:

Thanks Martinsh, Im happy that you are back, this filter is very cool !

Thank you guys!
That scene is an old one, now I am using it to test some shaders in it.

here is a blend file:
scene in the demo is done by Mike Pan

This filter is very cool, thank you.

I’ve been away from this community for some time now it seems. Come back and see all the stuff you’ve been working on.
All I feel right now is jealousy. :stuck_out_tongue_winking_eye: Gifted artist and a good coder!!
Love what you’re doing. Keep it coming.

Great work.

I notice that when the SSAO is rendered on a Normal Mapped surface, it loses it’s darkness. I used this shader, and when I made a gravel texture, I put a strong Normal Map on it and the SSAO “wore off”.

Great to see some more good shader work from you, martinsh. :slight_smile:

The .blend file in your post #7 doesn’t work on my laptop. This is possibly because my laptop is very old though (5 years?). The scene appears without textures, not sure if this is intended. The shader doesn’t work too well either. There are lines across the objects that move according to the camera orientation.

The graphics card is nVidia GeForce Go 7600


Well the AO is not connected to Normal Mapping in any way, but the strength of AO is based on luminance of the scene, so basically - more light, less occlusion. Perhaps the scene got brighter so the occlusion is less noticeable. If you want stronger AO, in the shader Line 126: gl_FragColor = vec4(vec3(color*mix(vec3(ao),vec3(1.0),luminance*0.5)),1.0);
0.0 for no luminance influence.
I will update the shader with a new variable - “lumInfluence”

Yeah I ran into that problem myself with my old Mobility Radeon. The cause of it is the Z-Buffer precision and it seems like it differs on every hardware, at least old ones. Try to play with your cameras Clipping Start/End values - I suggest you increase Start to something like 1.0.
And the scene has no textures.

Thank you martinsh, your filter is very nice and useful.

I tried to apply it to a pinball game I’m working on and it works well, but, as the scene is essentially static, I thought that applying it just one time by a delay sensor instead of an always one, could have helped to reduce its impact on frame rate, but is not so.
The camera doesn’t move and the only really moving object is the ball, so also a static mapping could work, but I cannot figure how to map AO over the whole scene, and on the other hand, baking the AO over each object does not work, because much of them are instanced.
The same is for shadows btw: I’d like to bake them in some way to get rid of the jagged ones in real time, but how?
Is there anybody with a good suggestion on this topic?

Thanks in advance, and excuse me for my bad English.


That’s how the 2D filters work, you activate it once and it is calculated in real-time until you disable it. To apply it once and not update it afterward would mean using the videoTexture module or another method to create an image out of it and use it as a static overlay on the scene (perhaps by applying the image to an overlay scene).

Anyway, I can say that there’s a few values I have found within the script that affects both the darkness and the occlusion length, but they’re not easy to find due to the relatively few comments throughout the code.

Thank you Ace Dragon,
this is my first attempt to use GE as you can guess, and I’m a new member of BlenderArtist, but the few things that I know of blender I’ve learned here, reading posts from the many skillful and helpful members, and you are at the top of the list.

I’m actually using video textures (to try) to get reflections on the ball, still I don’t find the proper way to get them mapped over it, but this is a problem apart…
In this case I don’t see how to use it to map the whole scene, as a filter do (may exist a way to save a filter output as image texture?) and I cant figure how to apply an image to an overlay scene (alpha transparence?). And anyway it would also wrongly affect the ball and the flippers.

Here I don’t undestand if you refers to my question, sorry.

Thanks again, paolo

Hi Paolo,

yeah I have ran into same problems with instanced objects. There is no definite solution for that. I just baked the ao for all static and non-instanced objects. And put alpha mapped planes as ao for instanced ones. In your case - for pinball game, there is not much of dynamic stuff. I can think of 3, so there is not much of a benefit for SSAO. I think that you could vertex-parent an alpha mapped plane for ball. something like tis one, but inverted -

I have updated the shader with more artist friendly variables.

Hi martinsh,
you are right, there is not so much benefit for SSAO, apart the fact it is nice and easy to set up…:yes:
but sure it would be better a static solution, the moving objects are many indeed, as bumpers and kickers and all are working dinamically, but the movements are minimal except for ball and flippers, as you say.
I have no idea of what “vertex-parent an alpha mapped plane”
but I promise that I will inform.
Thank you, also for the updated filter, far more clear to me.


Edit: maybe you mean i could use that method to mask the ball in the application of ao texture, but now the problem is to apply such texture over the displayed scene.

Anyway, this is not so a big issue, many things to do before completion, it was your filter, martinsh, to make me want to do it.

Thanks, that actually really helped. Keep up the good work. And is HBAO an option for Open GL? Or is it DirectX exclusive, because I read that it is supposed to be faster. Thanks for the help, man, you’re the best.

That looks so good… my brain just popped.