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

Thread: Easiest way to render only one side of a cub map for debugging purposes

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2011
    Posts
    23

    Question Easiest way to render only one side of a cub map for debugging purposes

    Hello,

    I created a shadow cube map consisting of 6 frame buffer objects (with only a depth texture attachment), one for each side:

    Code :
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, Handle, 0);

    Now I want to visualize the content of the cube map for debugging purposes.

    So basically I want to render each side of the cube map to the screen to check if the values look reasonable.

    What is the easiest way to do this? It seems I cannot just select one side of the cube map texture and then render it with GL_TEXTURE_2D?

    Help is really appreciated!
    ++i--;

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,194
    Quote Originally Posted by RealtimeSlave View Post
    So basically I want to render each side of the cube map to the screen to check if the values look reasonable.

    What is the easiest way to do this? It seems I cannot just select one side of the cube map texture and then render it with GL_TEXTURE_2D?
    You could (they're just 0..1 values afterall), but the result mapped directly to intensity wouldn't be that useful since depth values rendered using a perspective projection tend to cluster up close to 1.0 fairly quickly. You want to map that non-linear 0..1 back to linear depth values -NEAR..-FAR and "then" map that linearly to 0..1.

    To get to EYE-SPACE Z values:

    Code :
    eye.z = near * far / ((depth * (far - near)) - far);

    where depth is the non-linear 0..1 depth value in the depth buffer. This gives you -n..-f. Now to map to 0..1, negate, subtract near, and divide by (far-near).

    Doing that and simplifying, you get something like:

    Code :
    linearized_depth = -depth*near / [ depth*(far-near)-far ]

  3. #3
    Junior Member Newbie
    Join Date
    Nov 2011
    Posts
    23
    Hi,

    thanks. I already have the shader for depth buffer linearization.

    My question was more about how to render each side of the cube because
    the cube texture was generated with GL_TEXTURE_CUBE_MAP.

    Can I just use the same texture handle and then somehow specify
    GL_TEXTURE_2D and some index for the face side or how does it
    work?

    Thanks
    ++i--;

  4. #4
    Junior Member Newbie
    Join Date
    Nov 2011
    Posts
    23
    So basically I would like to render each side of the cube map as a 2D image to the screen but I don't know how to do this since the cube map handle is a GL_TEXTURE_CUBE_MAP and not a GL_TEXTURE_2D.
    ++i--;

Posting Permissions

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