Sign in to follow this  
IMYT

Noise in SSAO

Recommended Posts

IMYT    109
Hi everyone:

I implemented a SSAO described in "Simple and Practical SSAO" on gamedev.net. The result is good but very noisy. I tried adding a simple blur pass but the noise was still there. Does anyone know a good way to eliminate the noise?

Share this post


Link to post
Share on other sites
Hodgman    51334
Pretty much every SSAO technique is going to produce noisy results :( Your results there actually don't look too bad compared to other implementations I've seen.

You can:
* add more samples to your SSAO algorithm
* add move samples to your blur algorithm

What kind of blur are you performing at the moment?

Share this post


Link to post
Share on other sites
IMYT    109
[quote name='Hodgman' timestamp='1302329042' post='4796230']
Pretty much every SSAO technique is going to produce noisy results :( Your results there actually don't look too bad compared to other implementations I've seen.

You can:
* add more samples to your SSAO algorithm
* add move samples to your blur algorithm

What kind of blur are you performing at the moment?
[/quote]


Thanks for your reply.

I use a very simple 3x3 blur with following weight:

16 26 16
26 41 26
16 26 16

By the way I also want to know what is the best way to integrate SSAO with other lighting models? Say if I know the ao and light intensity at a given pixel how can I determine the color of the pixel?

Share this post


Link to post
Share on other sites
Locater16    100
Make sure not to blur onto pixels with a z value that's too far away or you'll get occlusion bleeding. As far as using the AO, you should probably make sure it only applies to the ambient term.

Share this post


Link to post
Share on other sites
IMYT    109
[quote name='Locater16' timestamp='1302332903' post='4796237']
Make sure not to blur onto pixels with a z value that's too far away or you'll get occlusion bleeding. As far as using the AO, you should probably make sure it only applies to the ambient term.
[/quote]

Thank you.

It seems to me that the contribution of AO to the whole scene is very small when there are a lot of lights in the scene.

Share this post


Link to post
Share on other sites
Hodgman    51334
Like all real-time graphics, there's no right way to incorporate your screen-space AO results ;)
Technically, since it's [u]ambient[/u] occlusion, you should only multiply the ambient light against this texture - but that means you simply won't see the effect in well lit areas.
You could multiply [i]all[/i] light contributions against the AO texture, but then well-lit areas will look way too shadowed sometimes.

You can apply different weightings to different contributions, e.g. full occlusion factor on ambient light, and half occlusion for direct light:[code]float ao = /*sample ssao texture*/
float halfAo = ao * 0.5 + 0.5;
ambientLight *= ao;
diffuseLight *= halfAo;[/code]There's lots of other ways too, for example, naughty dog use their cascaded-shadow-map to mask out the AO effect, so it is only applied to shadowed areas.

Also as Locater says, to avoid 'bleeding' artifacts in the blur step, you need to use a depth-aware [url="http://en.wikipedia.org/wiki/Bilateral_filter"]bilateral[/url] blur filter that ignores samples that cross a depth discontinuity.

Share this post


Link to post
Share on other sites
IMYT    109
[quote name='Hodgman' timestamp='1302341463' post='4796260']
Like all real-time graphics, there's no right way to incorporate your screen-space AO results ;)
Technically, since it's [u]ambient[/u] occlusion, you should only multiply the ambient light against this texture - but that means you simply won't see the effect in well lit areas.
You could multiply [i]all[/i] light contributions against the AO texture, but then well-lit areas will look way too shadowed sometimes.

You can apply different weightings to different contributions, e.g. full occlusion factor on ambient light, and half occlusion for direct light:[code]float ao = /*sample ssao texture*/
float halfAo = ao * 0.5 + 0.5;
ambientLight *= ao;
diffuseLight *= halfAo;[/code]There's lots of other ways too, for example, naughty dog use their cascaded-shadow-map to mask out the AO effect, so it is only applied to shadowed areas.

Also as Locater says, to avoid 'bleeding' artifacts in the blur step, you need to use a depth-aware [url="http://en.wikipedia.org/wiki/Bilateral_filter"]bilateral[/url] blur filter that ignores samples that cross a depth discontinuity.
[/quote]

Thanks. This is really helpful.

Share this post


Link to post
Share on other sites
MJP    19786
Scalar ambient occlusion is just your visibility about the hemisphere, which makes it a pretty good approximation for sky lighting and other IBL sources. Where it doesn't really work is direct lighting, or any lighting contribution where the visibility is already accounted for (such as indirect lighting from radiosity). Not that it'll necessarily look bad if you apply it to those lighting terms...you'll just be over-darkening things a bit. For some games (like Gears of War 2) this fits in perfectly with the look they're trying to achieve.

Share this post


Link to post
Share on other sites
Jason Z    6436
[quote name='IMYT' timestamp='1302333507' post='4796238']
[quote name='Locater16' timestamp='1302332903' post='4796237']
Make sure not to blur onto pixels with a z value that's too far away or you'll get occlusion bleeding. As far as using the AO, you should probably make sure it only applies to the ambient term.
[/quote]

Thank you.

It seems to me that the contribution of AO to the whole scene is very small when there are a lot of lights in the scene.
[/quote]
The typical way to remove the noise is to apply a bilateral filter to the results, where discontinuities in the depth and/or normal vector are used to determine how similar two values are. This should minimize the amount of bleeding, but still produce a smoothed version of your occlusion.

Share this post


Link to post
Share on other sites
Shirakana2    500
We can see some square even in the part without noise. make sure that you use bilinear filtering when sampling your AO in the blur pass, and in the compositing pass. BTW even if there is noise remaining, it would become invisible when mixed with high frequency texture. I also encourage you to have a look to [url="http://www.gdcvault.com/play/1012459/Uncharted_2__HDR_Lighting"]that Naughty Dog presentation[/url] which give good motivation and explanation for AO, and a "correct" way to composite it with your lighting.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this