Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm trying to implement shadow mapping with cube maps. I believe I've done the first stage by filling the cube map, but for the final shading pass I am unsure how to exactly calculate the cubemap coordinates. Any pointers?

share|improve this question
add comment

1 Answer 1

Cube maps are using direction as their texture coordinates. A quote from the OpenGL wiki:

The texture coordinates for cubemaps are 3D vector directions. These are conceptually directions from within the cube defined by the cubemap, pointing in a particular direction. The vectors do not have to be normalized.

You have to calculate the direction of the fragment is pointing at to get a cube map direction. You could use the vertex normals for that, or some other mechanism. In your case of shadows, I'm guessing (I've not actually done that yet myself, I am a learner too) you could get the direction from the camera to the fragment to get the correct depth texel, or at least something similar to that.

Read a tutorial about cube maps.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.