View Full Version : Shadow lookups in OpenGL 4

09-21-2013, 05:52 PM
If I declare my shadow map texture uniform as a sampler2D value and do the comparison myself, shadow maps work perfectly:

if (shadowcoord.z>texture(texture5,shadowcoord.xy).r) attenuation=0.0;
If I declare my shadow map texture uniform as a sampler2DShadow and call texture(), shadow lookups always return zero (appear black):

attenuation *= texture(texture5,shadowcoord);
In the second situation, I also set these values for the bound texture on the client side:

glTexParameteri(gltarget,GL_TEXTURE_COMPARE_FUNC,G L_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?

09-21-2013, 06:41 PM
Ah, the texture uniform wasn't getting set. I knew it was something basic like that. Case closed.