Ambient Occlusion

( previously discussed over there, but for clarity moved here. )

there’s this very efficient global illumination technique out in the wild called ‘Ambient Occlusion’. it is successfully implemented in a bunch of games now and you can find a lot of code samples on the web.
as far as i can tell, screen spaced AO is the way to go, as dyanamic AO is even harder to implement. some links:

it would be wonderful to have this bleeding edge realtime render technique in vvvv. should work with easily with 30fps on a recent graphic card. i’m absolutely not into shaders, so could only go a few steps with the help of a friend.
there’s also a fake ambient occlusion technqiue that is a lot cheaper but faster and easier to write. it’s called ‘Depth Darkening’ and described here.

we’ve started to write a hlsl shader for it. the first results look like this:

so it somehow works but there are still problems with the edges etc. i’ve atteched the code, maybe some of the shader cracks can have a look at it, so a working DD shader would be a first start to have SSAO some day. horray. (11.0 kB)

yes shader gods, please give us realtime ambient occlusion in vvvv, and we’ll give you thanks and praises

I’ve never heard of AO before
From what I can discern, it seems to be related to generating shadows by darkening pixels which have a depth significantly greater than their surrounding pixels.

This definitely sounds like a multipass shader (wink wink to the devs), but should be wholly realisable in vvvv.
I’d do it by rendering a depth buffer and feeding that into a shader which can sample surrounding points on the depth buffer (e.g. 5 in each direction) and assign a darkening factor based on the gradient of the depth buffer.

That said, it’s probably a good idea to start with a div shader (a shader which performs the vector ‘div’ function) on the depth buffer, and clamp each sampling so that only +ve depths are counted (since objects behind dont contibute to a negative shadow, only objects in front contribute to a positive shadow)

Also some clever blurring would be useful, but you’d need to make sure to only blur along the correct depth. In order to do that it might be good to have two channels being output from the modified div shader: shadows and depth. Then blur the shadows channel and depthtest the shadows against the original image.

am i on the right lines?

it seems that there’s some decent examples of ambient occlusion in the screenshot gallery now, so somebody must have cracked it.

Sharing is caring!

if only vvvv supported opengl…

maybe you like this.

yea i definitely like. thx. but (quoting)

  • “The steps are simple to imagine but unfortunatley difficult to implement”

but i am absolutely no shader guy. still noone succeeded in vvvv ssao and is willing to share his/her code? please…

but i am absolutely no shader guy

aren’t there two ones in your office in berlin?
*a very tall one speaking some strange dialect and
*a not so tall one brumbling some strange math-theories (…nobody except himself understands…) into his beard?

Tonfilm did something which is nice but too heavy to compute even on a high end machine.

Perhas it runs well on a i7 config with a new graphic card

yes, its too slow… i will compare my code with kalles link and try to find the speed improvement. but first i have to move to berlin. rrrr aren’t you in the praxisberlin too? we can have a look at it then…

that would the gift of this summer :)


sorry for cutting in)

found this:

here we are,

this is a proof of concept copy/paste-job from a relatively new SSAO implementation as initially posted by ArKano22 on looks quite useable, check the ready-to-use module in the attachment.

there is still room for improvement though, especially with the global illumination technique that yet needs a better compositing mode with the original. also later in the thread ArKano22 postet a rendermonkey document that still could be compared for further source improvements.

now show me what you’re shading with. (54.0 kB)

wow!.. no text …

That wicked :)

very nice. thanks.

this is great news. thanks joreg!

wow, fantastic,
why you don’t put it in the shaders? ;))

wow. that’s a great step forwards. thanks very much for sharing.

Hi all,

here is Joreg’s great patch/shader a bit modified. i added a bilateral blur filter, which prevents blurring across object edges (as good as it gets) and to get rid of some artifacts. also tried a noise texture with higher resolution for slightly better ao quality. performs quite well on my machine (Core 2 Duo E7400, 260 gtx), just try…

best, flux (477.5 kB)