Perspective shadow map projection

Started by
4 comments, last by HellRaiZer 20 years ago
Hello... I''m trying to understand how "Perspective Shadow Maps" work, and i have a question concerning how to project the shadow map on the scene. I read the original paper (i haven''t found anything else talking about it), and i read the "Recipe for Computing the Perspective Shadow Map Matrix". I tried to implement, what i understood and here are results for a simple scene. Scene rendered from light. The red ball is the camera, and the line is camera'' direction. The shadow map. As you can see, the perspective "distorsion" is working. I mean, parts closer to the camera are having bigger resolution, than those far from the camera. My problem is, assuming that the above are correct, how to project this on the scene. Normal projective texturing doesn''t apply. I can''t figure out what i''m missing, so it projects correctly. I''m not posting a screenshot to show how the shadow is projected on the scene, because for the above camera-light position, i can''t see any shadow! What i mean with projective texturing, is what you use with normal shadow mapping. If anyone has a comment to make, please post it. Thanks in advance. HellRaiZer
HellRaiZer
Advertisement
When projecting onto scene the shadow map texcoords are generated the same way as non-perspective shadow mapping. That is (s,t,r,q) = M * model_space_pos where M is matrix that converts from model space to shadow-map space. The projective texturing is used regardless of whether it''s perspective or non-perspective shadow mapping and that gives you (s/q,t/q) to lookup shadow map and (r/q) to compare with depth in shadow map.
I've not looked closely at perspective shadow maps, but before you proceed any further:
People on the GDAlgorithms list have been landing very hard on perspective shadow maps, all concluding that it's a total pain to implement robustly, and that it's wholly impractical. Jonathan Blow even said that there are "facts" in the original PSM paper that are plain wrong, and that the authors didn't understand what they were proposing well. Rusch Matthew seconded that, I think.

In general, the wisdom was "Friends don't let friends try to implement PSM"

The thread is titled Perspective Shadow Maps, and in case you fail to find the useful posts (because SourceForge's thread-view is somewhat useless), these are some posts pointing out why they're bad:
http://sourceforge.net/mailarchive/message.php?msg_id=6247537
http://sourceforge.net/mailarchive/message.php?msg_id=6247536
http://sourceforge.net/mailarchive/message.php?msg_id=6248133

Muhammad Haggag
Bitwise account: MHaggag -

[edited by - Coder on March 28, 2004 2:55:23 AM]

Good point. I second that. Don't use them ! Yann is one of the few people to get them working in his game, but he's awesome and he did mention they were a pain.

They sound good in theory but in practise they have enough gotchas to make them not worthwhile. The problems include (1) shadow texel swimming when the camera moves, (2) avoiding singularities can cause PSMs to degrade to uniform shadow maps (which means you lose control over your shadows for certain light positions), and (3) the biggest one (which isn't mentioned in the paper) that shadow map resolution goes to crap very quickly with view distance which, when combined with problem (2), can mean that most of your shadow map texels can be spent on stuff that isn't even visible because it's behind the viewer (in the PSM paper you sometimes have to move the virtual camera behind the real camera). Problem (3) manifests as shadows in the distance looking far worse than if you'd used the same resolution uniform shadow map. PSMs are the inverse of uniform shadows - uniform shadows are bad up close, but great in the distance - PSMs are good up close but bad in the distance.

Jon Blow's alternative (see above mentioned GDAlgorithms thread) of using multiple, hierarchical, uniform shadow maps looks like a better alternative and is more theoretically sound (see Falker Schamel's post at the bottom of http://www.gamedev.net/community/forums/topic.asp?whichpage=3&pagesize=20&topic_id=179941 where he talks about logarithmic mapping which is what Jon Blow's idea is based on).

[edited by - soiled on March 28, 2004 9:20:54 PM]
I really recommend picking up GPU Gems, in which Koslov fixes many of the problems with PSMs.

Disclosure : I work for nvidia, which receives a royalty for this book, although I personally don''t receive anything, despite having edited one of the sections.
Thanks for the replies.

I understand that making them work correctly is something very hard, so i'll let them become more widely used before attempting to implement them.

I read a presentation from nVidia (GDC'04) talking about PSMs and they mention that they solved many of the problems the initial algorithm had. They also mention a demo, but i can't find anywhere. I hope someday they upload it, and i hope it is an OpenGL demo I know that there are some differences between the two API (concerning shadow mapping), and because i haven't touched DirectX ever, i can't work with it!

About the alternative solution you mentioned, i'll check it out. Are there any other resources on it, except GDAlgorithms forum? I haven't read the thread you mentioned (i'll do that today), but from my experience (in these forums at least), despite how good a "forum reply" is, there are some things that are always missing! You know, little details which makes everything clearer (if present) and very difficult (if not)

Thanks again for the replies.

HellRaiZer

[edited by - HellRaiZer on March 29, 2004 5:33:37 AM]
HellRaiZer

This topic is closed to new replies.

Advertisement