Jump to content
  • Advertisement
Sign in to follow this  

Realtime Ambient Occlusion using multiple shadowmaps

Recommended Posts

Posted (edited)

So, i'm currently on a quest of finding a realtime world-space Ambient Occlusion algorithm for a game i'm making. (Or at least check if it's feasible. I wanted to avoid baking AO/lightmaps in a mapeditor as i would like to avoid storing lightmap data in my levelfiles in order to reduce the filesize as much as possible and avoid expensive/long precomputations in the first place.)

Now, i stumbled upon an AO concept which works by using multiple shadowmaps which are placed on the skys hemishpere and then merged together to create the Ambient Occlusion effect.

Here is an old example/demo from nvidia:


I was able to find a video which shows this in action:



It seems to work rather well, although i can see a couple issues with it:

- Rendering multiple shadowmaps is expensive (though that's expected with realtime AO)

- As shadows are only cast from the top, every surface which is pointing downwards will be 100% in shadow/black. (normally such a surface would have a bit of light around the edges due to the light bouncing around. It works best for surfaces facing upwards/towards the sky.)

- Flickering can be an issue if the shadowmap is covering a large scene/area or if the resolution of the shadowmap is too low. (could be fixed?)


It's incredibely hard to find information on this technique on the internet. (either demos, implementation/improvement details, etc...). I suppose because it's not that widely used?

Did anybody implement AO in a similar style like this? Are there any known sources which are covering this technique in more detail?

Edited by Lewa

Share this post

Link to post
Share on other sites

I implemented this on a PS3/360 game, but I rendered hundreds of shadow maps during the loading screen, and accumulated the results in texture space (a lightmap). For each shadow direction, I'd add 1/255 to any pixels in the lightmap that weren't shadowed. A few hundred shadowmaps later, and you got decent AO/skydome shadowing. 

If you don't use enough shadowmaps, the individual shadows can be quite visible, so you'd want to use a good soft shadowing technique (maybe VSM and friends?). 

To solve the resolution problem, I used a 1024px shadow map, but didn't do the entire level at one time - instead splitting the shadow view into a grid, and rendering each cell into the 1024px map (so it was actually like 256 directions x 9 grid cells = 2304 shadows). To split the work over multiple frames, I also didn't apply each shadowmap to the entire lightmap in one go - instead splitting the 4k lightmap into 4x4 1024px sections (so each shadowmap had to be applied up to 16 times, or up to 36864 total shadowmap->lightmap application steps). This kept the GPU cost as under 33ms per frame so the loading screens were interactive :)

Share this post

Link to post
Share on other sites

I just tested this simple setup in blender and baked AO there:


The middle part is correctly occluded but the edges on the side wouldn't be lit by the shadowmaps (because they are coming from the top.)

I suppose that placing additional shadowmaps on the botton isn't enough as those may then interfere with additional geometry (like a floor for example)

How did you handle this issue? Or is this just an artifact one has to accept with this technique?


Baking those lightmaps during the loading process is a good idea. (Hopefully it doesn't drag the loadingtimes out too much.)

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  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!