Opengl : SSAO vs Shadow mapping

1k Views Asked by At

Literary every tutorial that has written an article on SSAO ends with 'dosent exactly produce realistic results'. We can get much more accurate shadows with shadow mapping without the extra memory required to store a texture[or an uniform array] full of random vectors for sampling or an extra blur pass to reduce banding so why still use SSAO?

I have also seen some tutorials combining SSAO and shadow mapping which seems like overkill to me. Both techniques are to produce shadows right?

2

There are 2 best solutions below

9
SurvivalMachine On BEST ANSWER

They solve different problems and complement each other.

SSAO solves ambient occlusion. Even if your point is in shadow, SSAO modifies the intensity so that more occluded areas are more dark. Shadow maps aren't that accurate.

Here's a comparison image. The whole area is in the shadow, but with SSAO you can better see the curtain's shape (click it to open it larger so it's more apparent):

enter image description here Shadow maps solve the visibility from light source, not taking into account light bouncing (SSAO fakes this by using the depth buffer).

A scene rendered only using shadow maps looks more flat than a scene with SSAO and shadow maps.

0
httpdigest On

Shadow Mapping and Screen-Space Ambient Occlusion solve different parts of the rendering equation because they make different assumptions.

As the name says, Screen-Space Ambient Occlusion assumes that light is coming equally from every possible direction above the hemisphere of our sampled point towards that point. That is, in order to solve ambient occlusion, we need to integrate a constant function (the irradiance) over the hemisphere of the sample point to determine the fraction of the hemisphere's solid angle that is occluded from the ambient light source.

And also in the word Screen-Space Ambient Occlusion there is the phrase "Screen-Space". It means, the computation, that we do in order to compute the fraction of the sampled point's hemisphere occluded from the uniform ambient light source, is only based on information we have ready available in screen-space (and not world-space by e.g. doing analytic ray casting/tracing of scene geometry - which we could do of course, but then it won't be called Screen-Space Ambient Occlusion anymore).

So, Ambient Occlusion (which Screen-Space Ambient Occlusion is a way to approximate that based on information we rendered into screen-space):

  1. assumes that light is coming equally from all directions over the sampled point's hemisphere
  2. approximates the occlusion factor (fraction of solid angle over the sampled point's hemisphere that has no incident light from the ambient light source)

On the other hand: Shadow Mapping. This is a technique that makes a completely different assumption about the irradiance incident to our sampled point. Here we do not assume light coming equally from all directions above the hemisphere of our sample point, but assume that light is coming from a single direction (or a small solid angle around that direction when we approximate soft shadows).

In order to solve that, we can sample the scene from the light direction and then test whether our sampled point could have received light from that light direction.