Hey guys,
I tried to implement Shadow Mapping in my OpenGL Game. For directional light it worked perfectly, but now I need point lights. I have created 6 depth maps and combined them into a cube map. For directional light I needed a texture matrix for the shader. I calculated the texture matrix like that: Bias * LightProjection * LightView * CameraViewInvert. Now my question: Do I need a texture matrix for cube maps (point lights) too? And if yes, how I can calculate it? Because the point light has 6 light view and projection matrices.
Sure you need. First, you definitely have to transform your vectors using the CameraViewInvert and your LightView matrix (choose the negative Z face’s LightView matrix for the purpose), the tricky part will be applying the projection and bias. I cannot recall by hearth how to do it exactly, but if you do the math you should figure it out.
Btw, you shouldn’t use fixed function texturing, it’s 2013, use shaders
If you use the same projection for all faces of the cube map (likely) you can get away with only 2 texture matrices: one for LightProjection and one for LightView*… – with just a little glue math in between to grab the correct depth to compare against for that cube map face. Here’s the trick: