Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Cube Map Sampling

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2012

    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!

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    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.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog:

Posting Permissions

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