2

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?

Sync it
  • 1,180
  • 2
  • 11
  • 29

2 Answers2

3

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.

httpdigest
  • 5,411
  • 2
  • 14
  • 28
2

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.

SurvivalMachine
  • 7,946
  • 15
  • 57
  • 87
  • How does SSAO account for light bouncing? It just samples a random sphere of points around a fragment. and since it's random how can we say its reliable? – Sync it Jan 12 '21 at 13:52
  • @Syncit it checks how many of the random points are visible, and modifies the intensity based on that. It's random, it's a hack, but it's fast. – SurvivalMachine Jan 12 '21 at 13:55
  • I see. can be used to replace shadow mapping then?. Any light source be it spot,directional,point can just sample the occlusion factor and use that to produce shadows right Or does it depend? – Sync it Jan 12 '21 at 13:57
  • @Syncit It can't replace shadow mapping because it only samples a small distance. Shadows can cover a large distance. – SurvivalMachine Jan 12 '21 at 13:58
  • SSAO works even without any light sources. It just makes things more dark if there's stuff near the pixel. – SurvivalMachine Jan 12 '21 at 13:59
  • So in a way can we say SSAO makes shadow mapping look more realistic? – Sync it Jan 12 '21 at 14:01
  • @Syncit without SSAO, the shadow mapped areas generally have the same intensity everywhere. SSAO can darken some areas, so the intensity depends on the surrounding geometry. – SurvivalMachine Jan 12 '21 at 14:03
  • So i take that as a yes then. I need some time experimenting with both combined before i can mark this as accepted. I'll come back then – Sync it Jan 12 '21 at 14:07
  • @Syncit I added a comparison image that shows a scene rendered only with shadow maps and shadows + SSAO. – SurvivalMachine Jan 12 '21 at 14:59