PDA

View Full Version : Shadow Mapping Projection Question



dirtyLogic
04-04-2005, 07:07 PM
Quick question, I have shadow mapping working fine. But I decided to make my projection matrix for the light orhto. Of course my light didnt scale smaller or bigger as the light moves back and forth. But I noticed that I lost my shadows.

My question is that if I dont have my prespective projection in does that mess up my R compare in the GL_TEXTURE_COMPARE_FUNC_ARB. Something to do with the r/q? Perspective projection always throws my brain for a loop:)

Any help would be fantastic. I'd like to know if Im on the right track.

Troy

zed
04-04-2005, 09:08 PM
My question is that if I dont have my prespective projection in does that mess up my R compare in the GL_TEXTURE_COMPARE_FUNC_ARB.o perspective orthogonal, its all the same dif, both genrerate depth values, the only dif typically is with perspective things appear smaller the larger that depth value is

dirtyLogic
04-06-2005, 10:15 AM
I understand what perspective projection works. I cant seem to figure out why changing my projection to orthonormal would cause my shadowmap shadows not to work

zed
04-06-2005, 11:11 AM
I cant seem to figure out why changing my projection to orthonormal would cause my shadowmap shadows not to workmost likely cause either
A/ the shadowcasters are not in the frustum
B/ the shadow recievers are not in frustum
C/ both A+B

the best way to see this is to draw the ortho projection frsutum onscreen to see which area is inside the shadow frustum

dirtyLogic
04-06-2005, 11:57 AM
Yea I am. I got a teapot and a ground and the projected texture (the lights color texture) projects through and no shadow happens. It seems like the compare doesnt work in orhto mode. I don't know what would be the cause of it. I switch back to perspective projection and its fine.

dorbie
04-06-2005, 12:18 PM
Ortho should work but your z buffer values need to match the distance from light along the r axis (or the equivalent for however you are implementing this).

Make sure you're not screwing this up with a texgen coefficient or texture z translate that mover your ortho z (r) into the wrong place. This is the most likely cause of your problem.

Are you multiplying an ortho matrix onto your texture stack or just doing this yourself with vertex programs mapping coords directly to texture? Again make sure z and r are compatible.

dorbie
04-06-2005, 12:21 PM
Zed, receivers don't need to be in the shadow rendering. In fact this can help reduce artifacts.

azcoder
04-06-2005, 07:17 PM
In troubleshooting Shadow Mapping, I have found that sometimes it helps to invert the Shadow Map e.g.:

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_COMPARE_F UNC_ARB,GL_GEQUAL);

instead of
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_COMPARE_F UNC_ARB,GL_LEQUAL);

In this case, anything NOT in shadow renders black, and shadowed renders as regular. Also, remember to CLAMP_TO_BORDER to prevent the texture from bleeding.

BTW, an Ortho projection will work.

zed
04-06-2005, 09:02 PM
Originally posted by dorbie:
Zed, receivers don't need to be in the shadow rendering. In fact this can help reduce artifacts.true for shadowcast, i was talking about the pass when u draw the shadows 'into' the scene (then again i might just be overcomplicating things :) )anyways the best way is like i said
to draw the ortho projection frsutum onscreen