PDA

View Full Version : fbo + cubemap + depth



muadib
02-05-2007, 09:06 AM
Hi,
I'm trying to render depth to cubemap using fbo, but i get GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT error when checking glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
here's code i use:

GLuint fbo;
glGenFramebuffersEXT(1, &fbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
// color texture //
GLuint light_cb;
glGenTextures(1, &light_cb);
glBindTexture(GL_TEXTURE_2D, light_cb);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_TEXTURE_2D, light_cb, 0);

// depth cube map //
GLuint light_depth;
glGenTextures(1, &light_depth);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, light_depth);

glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
for(int i = 0; i < 6; ++i)
{
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB + i, 0, GL_DEPTH_COMPONENT,
width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
}
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, light_depth, 0);i'm using Radeon9600 with newest drivers on winxp. Anyone have any idea what can be wrong?

jide
02-05-2007, 10:06 AM
muadib ;) , I guess that if it's a cube textures need to be of the same width and height. Maybe I'm wrong. I personnally only have tried that with the same size.

muadib
02-05-2007, 10:16 AM
you are right, but in my example width == height == 256 :)

tomtrenki
02-05-2007, 10:17 AM
I'm not sure why you're getting incomplete dimensions error, it looks like your textures are all of the same size, so it should be ok.
However, I don't recommend using FBO to render to a cube map with depth buffer or depth texture, because that won't work correctly on some hardware (eg. my GF6600).
When rendering to a cube map it's best to use the copy to texture method.

arekkusu
02-05-2007, 11:18 AM
DEPTH_COMPONENT cubemaps don't exist, unless you have EXT_gpu_shader4.

This has nothing to do with FBO, depth cubemaps have never been supported.

muadib
02-06-2007, 07:40 AM
ok, thanks for clearing things up. so the only way to access omnidirectional depth data in shader is to copy depth from 2D texture to each color cubemap face?