Fake ambient occlusion on compositor (SSAO)

Hey there, I’m trying to reproduce the ambient occlusion on the compositor, only with the depth buffer (like Screen space AO).
But its getting hard to find a way.

Someone knows how to?

Probably need to use ID mask to separate the objects out.

In the first days of the compositor someone had made a tutorial about it , but I can’t get my hand on it anymore.
I think what you’ve done is all that you can get.

You can use just one regular blur on the Z and take the difference from the blur and the Z, that give you something AO-ish…
IIRC you have to tweak it a bit (invert, remap value) as you did.

Now SSAO shaders/algorithm are a bit more sophisticated/clever, so they can get rid of shadows bleeding on the background, they can also calculate shadows by taking depth and normal informations. But this can’t be done by only filtering the image. I’m not sure it can be done with math nodes too.