Skip to main content
GameDev.net gamedev.net
🔒 Locked

avoiding back projections in shadow mapping

Started by metalcrusader Sep 22, 2006 at 7:38 AM 0 replies 650+ views
Original Post
metalcrusader
metalcrusader
Hello! I've implemented shadow mapping using the texgen functions to calculate the texture coordinates. Unfortunately, I have these ugly back projections. I already read the chapter "Projective Textures" in "more OpenGL game programming" and the nVidia-paper 6800 leagues in shadows - and found a way to eleminate the back projections using a second 1D-texture. Unfortunately I didn't understand how this works. Can somebody explain it to me in detail?
HellRaiZer
HellRaiZer
I'm not an expert on these things, but since noone else replies, i'll give it a shot.

According to this when you are behind the light, the generated q coordinate is negative.
Now you have a 2x1 1D texture where the first pixel is black and the second pixel is white. If you could map the q coord to the s coord of the texture unit you have bound the 1D texture, so the negative values select the black pixel and the positive values select the white, you just have to modulate this with the shadow comparison result.

Remember to set the wrap mode to clamp (and not repeat) in case to map all negative values to black and all positive values to white.

Because texcoords must be in [0, 1] range, you have to map negative q coords to [0, 0.5] and positive q coords to [0.5, 1]. This can be done by scaling and biasing the generated q coord like this : q_final = 0.5 * q_gen + 0.5

I don't know how this can be done with texgen. I think by using the same texture matrix as you did with the shadowmap projection, and by altering the texgen matrix in case to put the generated q-coord to the s-coord of the second texture unit (where you bound the 1D texture) must work.

Hope that helps somehow. If someone else has any corrections on the above explanation, feel free to comment. I don't want to confuse the OP.

HellRaiZer
HellRaiZer

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.