Ok, I have shadow mapping working perfectly using the fixed-function pipeline. I use glTexGen with GL_EYE_LINEAR on GL_S, GL_T, GL_R, GL_Q, etc… Only problem is though, that to use shaders, I have to do shadow mapping in the shader as well.
I think I’ve officially found and tried every single GLSL shadow mapping tutorial and code bit that can be found online. And the ones I could get to work, all end up having the same issue: my shadows aren’t projected correctly.
The following is a simple scene using plain opengl without any shaders:
It works great.
The following is the same scene rendered using the shadow mapping shaders from the opengl orange book:
I haven’t blended anything with the base textures yet, since I want to solve the shadow mapping problem first. But, as you can see, the shadows aren’t being projected properly. And I’ve run into this same projection problem with every other GLSL shadow mapping shader I’ve gotten to “work.”
My guess is that it has something to do with how I’m setting up and creating the shadow map texture, but I fail to see why my method would work with the plain-opengl method and not a shader method? I’ve tried fiddling with my light’s matrices and perspective without any luck so far. About the only thing I haven’t been able to try is a non-power-of-two texture for the shadowmap to match the screen resolution (when I try that, my machine just freezes for some reason). Still, I don’t understand why it works fine when not using shaders.
Any ideas? Code examples? A possible tutorial I haven’t found yet?
ANY help is greatly appreciated! I’ve been stuck on this for a while now.