Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Shadow lookups in OpenGL 4

  1. #1
    Junior Member Regular Contributor
    Join Date
    Mar 2009
    Location
    California
    Posts
    188

    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:
    Code :
    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):
    Code :
    attenuation *= texture(texture5,shadowcoord);
    In the second situation, I also set these values for the bound texture on the client side:
    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?

  2. #2
    Junior Member Regular Contributor
    Join Date
    Mar 2009
    Location
    California
    Posts
    188
    Ah, the texture uniform wasn't getting set. I knew it was something basic like that. Case closed.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •