If I declare my shadow map texture uniform as a sampler2D value and do the comparison myself, shadow maps work perfectly:
If I declare my shadow map texture uniform as a sampler2DShadow and call texture(), shadow lookups always return zero (appear black):Code :if (shadowcoord.z>texture(texture5,shadowcoord.xy).r) attenuation=0.0;
In the second situation, I also set these values for the bound texture on the client side:Code :attenuation *= texture(texture5,shadowcoord);
Code :glTexParameteri(gltarget,GL_TEXTURE_COMPARE_MODE,GL_COMPARE_REF_TO_TEXTURE); glTexParameteri(gltarget,GL_TEXTURE_COMPARE_FUNC,GL_LEQUAL);
- The shadow map lookup returns zero even if I set the shadowcoord.z value to 0.0.
- I also tried changing the compare function to GL_GEQUAL, with the same result.
Something is obviously wrong here. Am I missing some other little trick with OpenGL 4 shadow mapping?