The shadow maps we use in Overgrowth are unusual in that they contain two parts: direct shadows and ambient occlusion. These correspond to the two light sources in outdoor scenes, the sun and the sky. Here is an explanation of how it works using an example.

Posted by on

The shadow maps we use in Overgrowth are unusual in that they contain two parts: direct shadows and ambient occlusion. These correspond to the two light sources in outdoor scenes, the sun and the sky. To explain how this works, let's consider this scene with a house in the desert:

The first part of the shadow map consists of direct shadows. We calculate them by dividing the scene into a grid and accumulating high-precision depth map shadows. This is done on the graphics card in order to achieve a much higher calculation speed. Here are the direct shadows for this scene:

There are some texture alignment artifacts here, but they're subtle when lit, so I'm saving them for later

The second part of the shadow map is ambient occlusion -- how much total light is received from the sky. This is calculated by accumulating the direct shadows from 64 points on the sky hemisphere. Here is the ambient occlusion for this scene:

See this post for more complex examples of ambient occlusion.

We could store both of these shadow maps separately, but for efficiency we can combine them into one shadow map. The graphics card stores images with three color channels (red, green and blue), so we can store the direct shadows in the red channel and the ambient occlusion in the green channel. Below you can see the direct shadows, the ambient occlusion, and the combined two-part shadow map.

To apply shadowed lighting, we just modulate the direct lighting by the direct shadows, and the ambient lighting by the ambient occlusion. We then add the modulated direct and ambient lighting to get the total lighting for each pixel. Below you can see the modulated direct lighting, modulated ambient lighting, and combined total lighting.

Now all we need to do is combine the lighting with the color map, and we have our finished image! Here is the total lighting, the color map, and the final image.

We recently discussed why ambient occlusion is important for characters (in this post), and it's important for environments for the same reasons -- it helps define the space and adds depth to shadowed areas. Below we have a comparison shot without ambient occlusion on the left and with ambient occlusion on the right. Look under the awning and the wooden walkway to see how it helps define enclosed spaces.

Many games approximate direct and indirect lighting using cascading shadow maps, screen-space depth comparisons, and deferred light accumulation. These techniques are powerful and fun to use, but their rendering artifacts and hardware requirements make them inappopriate for Overgrowth. For us, the efficiency and accuracy of baked shadow maps make them a better choice.

Track us

It looks realy good!

I really like your methode, Valve uses some of the same style for "TF2", just more cartoon like. Nice job!

Wooooooo!Awesome :D

I doubt a single depth comparison shadow mapping tech is slower than a dynamic shadow map approach especially in more complex scenes. Unless we talk of static sun light here.

Author

Could you elaborate on that? I am not sure I understand.

You say that baked shadow maps (aka dynamic shadow/light mapping) is more efficient and accurate than for example CSM, screen space depth comparison (which I'm not sure what you mean... SSAO?) and deferred light accumulation. I doubt this is the case especially if the complexity of the scene increases. For producing baked shadow/light maps you need to render to multiple textures grouping geometry triangles in color mode. For CSM for example you render for the entire view 3-4 depth textures in depth mode. Besides requiring a constant number of render turns depth mode rendering is double as fast as color mode rendering and depth comparison comes nearly for free (hw accelerated including hw-pcf or fetch4 if not using multi-tap PCF or something similar).

Would be a different situation if the lighting is all static but from what I get you use dynamic sun-light so you need to update frequently the direct lighting map (as AO is pre-processing and does not change no matter the direction of the sun-ligth so no update required).

Author

Ah, the sun is indeed static (unless you are in the editor, then you can update it in realtime on a modern graphics card).