Shadow Maps

Hi all,

I’ve got depth-based shadow maps to work. However there is one problem: they suck ;( Even when using 512x512 depth buffer the jaggies are horrible.

I have tried all the silly ideas that came to my head. Some of them include glReadPixels and trying to blur the map on the CPU. In theory it should work (very slowly) but it didnt.

Another method I tried was to jitter the light. I think this method is more promising yet again it didnt work. The method I used was:

  1. clear colour+depth
  2. set camera position to light
  3. render scene
  4. jitter light position
  5. goto 2 for n times (I tried 2 to 6 times)
  6. bind the depth map
  7. glCopyTexSubImage2D

Any ideas/code appreciated

Brian Azzopardi.

Take a look at perspective shadow maps. http://www-sop.inria.fr/reves/publications/data/2002/SD02/PerspectiveShadowMaps.pdf
This technique seems to be a little bit tricky but according to what authors write it eliminates the jaggies in most cases.

Kuba

If you use shadow maps, you will get jaggies in some cases. All you can do is make those cases fewer, and forbid all the bad cases that are left. If you cannot forbid those cases, you have to use a different technique or live with the results.

Yes I agree.
And “perspective shadow mapping” - if you
get it to work - creates new problems. For example very distant shadows (far into the scene) get extremely low-resolution.

Instead I use normal depthmaps, dynamically
optimize znear and zfar. I pre-calculate everything that is static. The frustum - what the spotlights sees, is dynamically adjusted to only incorporate dynamic stuff
(= tracking moving parts)

By the way - 512x512 is not very hi-resolution. That would work ok for a medium-to-short shadow on ONE character. I use a
2K by 2K static shadowmap for a a 10 by 10 meter thing in a scene…

fritzlang

[This message has been edited by fritzlang (edited 12-11-2002).]

Arsenik,

Neither blur nor jitter will solve the shadow map problem. Percent-closest filtering may make it slightly better, however.

A 512x512 shadow map, rendered on a 1024x768 screen, is guaranteed to not have better than one shadow texel per two screen pixels; typically it’ll be much worse than that. You need to have a shadow map of sufficient quality that you’ll get 1:1 shadow ixel ratio to get rid of pixelation. However, this is not as expensive as you might think, because you don’t need a color or alpha buffer, only the depth buffer.