Original Post
Hello, I have shadowmapping working for a spotlight. Now I would like to have it for a pointlight as well. I guess the common approach is to render the scene 6 times for each pointlight and store the results in a cube map. What I got did not look quite right. I assume the problem lies in the way I project the shadow back to the scene. Here is what I do for a spotlight: Here is what I do for the pointlight: Could it be that I set up the g_texTransform-matrix in a wrong way for the point light? I have no experience with cubemaps. Thanks for any help.
//prepare the shader:
Matrix4 worldViewProj = world * m_view * m_proj * s_bias;
effect->setMatrix("g_texTransform", worldViewProj);
//vertex shader:
output.projCoord = mul(pos, g_texTransform);
//pixelshader:
float shadow = (tex2Dproj(shadowMap, input.projCoord).rgb + SHADOW_EPSILON < input.projCoord.z / input.projCoord.w) ? 0.0f: 1.0f;
//prepare the shader:
effect->setMatrix("g_texTransform", world * s_bias);
//vertex shader:
output.projCoord = mul(pos, g_texTransform);
//pixelshader:
float shadow = (texCUBEproj(shadowCubeMap, input.projCoord).rgb + SHADOW_EPSILON < input.projCoord.z / input.projCoord.w) ? 0.0f: 1.0f;