Cube Map Sampling

Hey Guys,
I’m currently attempting to implement omnidirectional shadow maps, and I’ve gotten to the stage where I am ready to create the necessary shaders.

However, one problem I have is how do I calculate which face I have to sample? I’m rather new to cube maps, so all I know is that I need to supply it with a vec4.

I attempted to re-use the method that I’m using to calculate the direction of a ray leaving the player camera (normalize the lightPosition - vertexPosition), but this doesn’t seem to work.

Finally, as a secondary question, I’ve also read about samplerCubeShadow on the OpenGL wiki, does this provide any benefits over the default cube map sampler?

Thanks for the help!

In traditional cube map sampling you don’t provide a face, you provide a 3D vector describing a direction from the center of the cube to select a texel when fetching. That means you practically simply have to transform the vertex position into the light’s space, interpolate it and use that vector as the texture coordinates for the cube map lookup.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.