Burger Engine Blog
23Jul/111

Exponential Shadows Maps

Exponential Shadow Maps with openGL and GLSL

Exponential Shadow Maps with openGL and GLSL

After a not so convincing attempt at implementing real-time soft shadows with Variance Shadow Maps (VSM), I started to look for another technique. I needed something quite simple, ideally allowing me to blur the shadow map before performing depth comparisons. That’s pretty much what Exponential Shadow Maps are about and it’s really simple to implement, once you know a few things.

Here’s how I proceed for my spotlights :

  • for each light write scaled linear depth to a single component 32bits rendertarget (unlike regular shadowmaps, render objects with BACKFACE culling)
  • then blur each buffer using a 2 pass gaussian blur. The trick here is to use a logarithm filterging to avoid some artefacts. (GLSL code for log blur)
  • during the deferred lighting pass, for each fragment affected by light, perform depth comparison

float fShadow = clamp( exp( fDarkeningFactor * ( fShadowMapValue - fScaledDistanceToLight ) ), 0.0, 1.0 );

And that’s it! I spent some time tweeking the parameters (scale and darkening factor) and the result are very satisfying!

Exponential Shaodw Maps

Exponential Shaodw Maps

There’re some drawbacks though : some light bleeding when the receiver and caster are to close to each other, and the shadows tends to become “harder” when the receiver is to far from the caster. Also some artifacts with non planar receivers.

Overall I think it’s a good choice for the spotlights, the next step would be to test with a directional light (sun), but that’s another story!

Here’s a video of Burger Engine's Exponential Shadow Maps :

and more screenshots on Burger Engine website!

Sources :
http://pixelstoomany.wordpress.com/
http://www.slideshare.net/march1n0/probabilistic-approaches-to-shadow-maps-filtering-presentation
http://www.bungie.net/images/Inside/publications/siggraph/Bungie/SIGGRAPH09_LightingResearch.pptx
www.mpi-inf.mpg.de/~tannen/papers/esm.ppt

Share on Facebook
Comments (1) Trackbacks (0)
  1. Il faudrait que toutes vos teapot soient remplacées par des burgers.


Leave a comment

(required)

No trackbacks yet.