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:

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!

[QUOTE=RealtimeSlave;1257467]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?[/QUOTE]

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:

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:

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

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

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.