Real time ambient occlusion - now with textures!

I updated it with textures and the ability to see either the final composite, no ambient occlusion at all or just the ambient result with no objects.

Some of you might have seen a thread in ShaderLab about this: http://forum.unity3d.com/viewtopic.php?t=9249

I got extra interested in this method because it operates on the level of the pixels flat on the screen and creates a very strong effect that catches the human eye and makes the image seem more “real”. I’ve always wondered if rendering could be done with more focus to what is actually on the screen similar to how a painter creates a realistic image with oils and brushes, by many tricks pulled on the viewer’s eyes to make things appear real and in perspective when they actually aren’t at all. This effect seems like a step in the right direction for that type of rendering so I was instantly a fan of it.

Well I almost pulled it off, it works fully but has some problems:

1: It doesn’t work transparent objects at all (they don’t appear in the final composite frame), but alphatest is ok.

2: Due to precision issues the range is limited to about 120 meters (though it handles this limit well, its still there)

3: It doesn’t always look good (duh) and can produce artifacts sometimes

4: It uses an unhealthy mix of immediate mode and normal rendering and is not robust in any way.

But it works! It is pretty fast for small resolutions too, considering I didn’t even try to optimize at all.

All Important Webplayer Link (not guaranteed stable) : http://yogware.bluegillstudios.com/SSAO/SSAO.html

And Unity package:

63660–2335–$ssao_579.unitypackage (520 KB)

1 Like

You’re a madman :wink:

It looks quite convincing and runs fairly well even on my machine. I’m curious what happens when you increase the resolution, does it look better or do the artifacts become more pronounced?

Great work as always.

I did a test and it does work somewhat ok at high res with a little tweaking:

www.yogware.bluegillstudios.com/SSAO/hires.png

Though that knocks me down to about 10 fps.

That’s awesome! It’s also more fun than I expected flinging those objects around.

It’s also really interesting to see how different developers approach this problem. I’ve seen quite a few different examples and all have slightly different results and levels of success.

Nice stuff!

That is fantastic! I am very much in agreement with you that there should be more “painterly” tricks in real time renderings. Hope to see more of this if you explore it further.

I read this one a while back:
http://www.shalinor.com/code.html

Thought I’d post it just in case it’s of any help.

wow forest, very well done (i like the simple light setup too - there’s a game hiding in there somewhere ; )

Very nice!

Another totally hacked trick that might be worth trying: just blurring the depth buffer and subtracting from unblurred one. See here: Photo Retoucher. Professional Digital Photo Restoration Software.

I like that look too but sadly it crashes here…

Superb. I think even though you’ll improve on it, once you have your textures, lightmaps bumps etc on the surfaces that is going to be totally useable.
I’d love to see how it looks with the other texture layers applied.
Cheers
Boxy

Its very cool Yoggy, I got between 15 and 20 fps on my abacus. It amazaes me the stuff you come up with. Good job.
AaronC

This is pretty awesome. Will say that on my Mac Pro, it gets around 30FPS in fullscreen, altho I think it loses quality. If that is the case or not, awesome work man, would love to see this with some textures/materials applied. Gives me yet another reason to get the 8800 when they release it for the original Mac Pros…


64252--2360--$picture_1_798.png

The loss of quality at high resolution is because the render texture I use still a 512x512, in my high res test I used a higher resolution render texture.

I updated it with textures and the ability to see either the final composite, no ambient occlusion at all or just the ambient result with no objects.

15fps with all
22-25 AO only
25ish No AO

Looking great Yoggy
AC

HAHA Dude this is SO cool…
Good work!

It looks great with textures though yes there are one a two artifacts full screen. I’m getting between 75 and 100 fps on my macbook pro. Great job.

great work. i get 200fps at fullscreen with a 8800gt.

Once again, I have to say how cool this is. Someday soon I won’t have to bake ambient occlusion anymore!

And just to help with your data: With all lighting modes on I dip down to 48 fps in the webplayer window and down to 28 fps in full screen mode. This is on a mac book pro in OS X.

Very nice!