# The Industry's Foundation for High Performance Graphics

1. ## 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. Originally Posted by JoshKlint
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. Thanks for the explanation.

#### Posting Permissions

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