Do you apply SSAO to rendered image or to ambient light term only?

Started by
7 comments, last by Prune 10 years, 1 month ago

While it seems to me SSAO shouldn't affect direct lighting, I've seen examples where it's just done as a post-process and multiplied to the final color buffer. I'm guessing one reason is convenience, at least with forward rendering, since if you don't have the depth buffer from a Z-prepass, then you can't sample the SSAO until after rendering. In terms of looks, in scenes mostly lit by direct lighting, I guess the SSAO would have little effect, which is the downside of using the more realistic ordering.

"But who prays for Satan? Who, in eighteen centuries, has had the common humanity to pray for the one sinner that needed it most?" --Mark Twain

~~~~~~~~~~~~~~~Looking for a high-performance, easy to use, and lightweight math library? http://www.cmldev.net/ (note: I'm not associated with that project; just a user)
Advertisement

In terms of looks, in scenes mostly lit by direct lighting, I guess the SSAO would have little effect, which is the downside of using the more realistic ordering.

That's not a downside, it means it's being more accurate. Light with strong directionality should only be occluded by blockers found in that direction. SSAO (and other forms of ambient occlusion) will darken areas with high overall occlusion, even if the light can perfectly hit those areas based on the location of the light. A good example would be a crease in the corner of a room: SSAO will make the crease dark, but if you shine a flashlight right on the crease it's actually quite bright. Thus you achieve more "correct" results by only applying ambient occlusion to the ambient term, since typically the ambient term consists of lighting from many directions.

Trust me: you really don't want your game looking like someone outlines your characters with a permanent marker. It's not a good look. tongue.png

It probably depends how you interpret the ambient occlusion. it's not a mathematical or logically defined tech, it's rather a cheat to fake lighting effects that are hard to do in real time. while you can make assumptions on what 'would be correct', you should apply it in the way it looks best, 'cause that's what really matters in the end. if your direct lighting is "correctly" not affected bei AO, but looks totally plain, then try to tweak your AO to make it look better.

if you look at the original ssao http://en.wikipedia.org/wiki/Screen_space_ambient_occlusion you also see they don't just do darkening of corners, but brightening on edges. while some say this is 'wrong' it gives plain ambient (shadow) areas some kind of "lighting" instead of just one boring ambient color intensity with dirt in the corners. (and they were for sure not just too stupid to make a "saturate(intensity*2)" in shader to remove the brightening effects.)

so, do what looks best and if you make a pool for the decision, then show us some screenshots so we could compare what looks nicer to our humble eyes ;)

it's not a mathematical or logically defined tech

AO is very clearly defined, mathematically-speaking. Lambertian diffuse is computed by integrating lighting * occlusion * cos(theta) for all directions about the hemisphere, and AO approximates this by integrating the lighting and occlusion factors separately and then combining afterwards. The fact that it's an approximation doesn't mean that we can't reason about when it makes sense to apply it, and what will produce results that best simulate real physical phenomena.

Applying SSAO only to ambient is a correct way to go, but it also requires an interesting and strong ambient term. In last game I did something in between those solutions. I just scaled SSAO strength depending on the lighting strength. This way SSAO was stronger in shadows, but less visible when light was shining directly on the surface.

How about do you apply SSAO also to ambient specular or just diffuse part?

it's not a mathematical or logically defined tech

AO is very clearly defined, mathematically-speaking. Lambertian diffuse is computed by integrating lighting * occlusion * cos(theta) for all directions about the hemisphere, and AO approximates this by integrating the lighting and occlusion factors separately and then combining afterwards. The fact that it's an approximation doesn't mean that we can't reason about when it makes sense to apply it, and what will produce results that best simulate real physical phenomena.

you define Lambertian lighting, by using occlusion and say occlusion is defined? I think that's not the way definitions work in math.

but you are right, AO approximates occlusion, and that was my point also. if you had a specific light source, you could separate lighting from occlusion (in that case it's commonly called shadow or radiosity map) and we'd all follow well defined algorithms.

and if there would be a clear definition of AO, then every tool should generated the same results, but the results of AO baking (and even in interactive rendering) varies a lot.

if you'd just go for the generic occlusion (aka not per light), indoor would be always just black. that's why baking tools usually have some tweaking values to set the range you sample the occlusion and in what way the angle/distance/density will be mapped to 0-1 and depending on how you apply those baked maps, artist will tweak the maps in a different way.

It's even more vague in screen space effects.

that's why I'm suggesting to go for the optically most wanted results than for some theoretically most convincing argument that looks inferior. We can somehow define what we want to achieve, but we strive into approximations, into theories and it ends in a pool about what most think would be best in theory. what if the 'best' we vote looks worst in the game he makes?

That's why I suggest to vote for the visually nicest results and he should post the 3 versions (probably just a change of 3 lines of shader code).

just stumbled across it, interesting real world reference regarding the correctness of AO and SSAO, IMHO, so I thought I'd share it:

http://nothings.org/gamedev/ssao/

just stumbled across it, interesting real world reference regarding the correctness of AO and SSAO, IMHO, so I thought I'd share it:

http://nothings.org/gamedev/ssao/

Fantastic link--thanks! I think directional AO methods like SSDO would probably show more realistic results. But the main take-away for me is that the reason SSAO makes things look good even though it's not realistic (as shown by this article), is simply that it adds more shading detail, which is still lacking in real-time renders. Until we have fully dynamic GI that is not just low frequency, as is the case with current real-time methods, the SSAO fills in for the the high frequency GI, the finer details, even though it's unrealistic.

"But who prays for Satan? Who, in eighteen centuries, has had the common humanity to pray for the one sinner that needed it most?" --Mark Twain

~~~~~~~~~~~~~~~Looking for a high-performance, easy to use, and lightweight math library? http://www.cmldev.net/ (note: I'm not associated with that project; just a user)

This topic is closed to new replies.

Advertisement