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 3 of 3

Thread: Cubemap shadowmap lookup

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

    Cubemap shadowmap lookup

    I'm doing a shadow map lookup with the following function:
    Code :
    texture(samplerCubeShadow sampler, vec4 coord)
    I am having some trouble with the depth value of the vec4 texture coordinate, and I want to eliminate one possible source of confusion. I assume the x, y, and z values just get multiplied by the w value, right? So the two vectors below would be functionally equivalent:
    Code :
    vec4(1,2,3,1)
    vec4(0.5,1,1.5,0.5)
    Is this correct?

  2. #2
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    474
    Quote Originally Posted by JoshKlint View Post
    I'm doing a shadow map lookup with the following function:
    Code :
    texture(samplerCubeShadow sampler, vec4 coord)
    I am having some trouble with the depth value of the vec4 texture coordinate, and I want to eliminate one possible source of confusion. I assume the x, y, and z values just get multiplied by the w value, right? So the two vectors below would be functionally equivalent:
    Code :
    vec4(1,2,3,1)
    vec4(0.5,1,1.5,0.5)
    Is this correct?
    No.

    Querying a shadow sampler doesn't return the depth value, it returns the result of comparing the depth against the reference value, which is normally the last component of the texture coordinates (except for samplerCubeArrayShadow, as samplerCubeArray already needs a vec4, so the shadow version has an extra parameter for the reference value).

    If you want to perform the comparison yourself, don't use a shadow sampler, just use the equivalent non-shadow form (e.g. samplerCube instead of samplerCubeShadow). However, the dedicated shadow form may perform filtering for you.

    texture() never does perspective division on the texture coordinates; textureProj() exists for that. But you don't need that for cube maps, as perspective division simply scales the vector, and cube map lookups don't care about the magnitude, only the ratios of x:y:z.

  3. #3
    Junior Member Regular Contributor
    Join Date
    Mar 2009
    Location
    California
    Posts
    188
    Thanks for the explanation.
    Last edited by JoshKlint; 09-23-2013 at 10:04 AM.

Posting Permissions

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