Shadow lookups in OpenGL 4

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:


[li]The shadow map lookup returns zero even if I set the shadowcoord.z value to 0.0. [/li][li]I also tried changing the compare function to GL_GEQUAL, with the same result. [/li][/ul]
Something is obviously wrong here. Am I missing some other little trick with OpenGL 4 shadow mapping?

Ah, the texture uniform wasn’t getting set. I knew it was something basic like that. Case closed.