PDA

View Full Version : Can FBOs do this?



PfhorSlayer
06-18-2005, 06:56 PM
Can FBOs be used to render to a texture and have it NOT clamp my floating-point values to [0, 1]? If it can, screw Pbuffers. FBO!

fenris
06-19-2005, 12:23 AM
You sure can! If you have hardware that supports ARB_texture_float or ATI_texture_float, just render to a texture that uses an internal format specified by either of those extensions.

spasi
06-19-2005, 01:44 AM
NV_float_buffer works great too.

PfhorSlayer
06-19-2005, 11:18 AM
Awesome! Screw pbuffers, I'm using FBOs instead! :D

PfhorSlayer
06-19-2005, 01:03 PM
Strange errors... Here's my code:


glGenFramebuffersEXT(1, &i->fbo);
glGenRenderbuffersEXT(1, &i->rbo);
glGenTextures(1, &i->cubeMap);

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, i->fbo);

// bind the RB
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, i->rbo);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, SHADOWMAP_SIZE, SHADOWMAP_SIZE);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, i->rbo);

glBindTexture(GL_TEXTURE_CUBE_MAP, i->cubeMap);

CHECK_FRAMEBUFFER_STATUS();

glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

// bind the faces?
for (int x = 0; x < 6; x++)
{
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + x, 0, GL_RGBA8, SHADOWMAP_SIZE, SHADOWMAP_SIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + x, i->cubeMap, 0);
CHECK_FRAMEBUFFER_STATUS();
}

std::cout << "Done setup" << std::endl;
The first CHECK_FRAMEBUFFER_STATUS says that the fbo is incomplete because I haven't attached anything to the color buffer of the FBO, which makes sense.

After the first and all additional calls to CHECK_FRAMEBUFFER_STATUS after I begin binding textures to the different faces, though, it returns GL_FRAMEBUFFER_UNSUPPORTED_EXT, and I'm not sure why. It does it no matter what format I have for the cubemap faces! I should probably point out that I've got a GF6800GT and forceware 75.90 drivers.

Overmind
06-20-2005, 01:54 AM
Try disabling mipmapping, that is, set the filters to GL_LINEAR or GL_NEAREST.

PfhorSlayer
06-20-2005, 10:37 AM
Still unsupported :(

PfhorSlayer
06-20-2005, 11:33 AM
I just now copied and pasted the sample code from the Nvidia paper titled "OpenGL_FrameBuffer_Object.pdf" (You can google it if you want to read it), and I get the exact same error I've been getting with my code. Is something wrong with my system setup?

Steve Demlow
06-21-2005, 11:14 AM
You need to unbind the texture before you can attach it to the FBO.

pashamol
06-22-2005, 01:09 AM
You must check render buffer status after specifying color attachment. Without color it render buffer incomplete.

About cubemaps see specification http://oss.sgi.com/projects/ogl-sample/registry/EXT/framebuffer_object.txt:

If <texture> is a cubemap texture then, the value of FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE the named attachment point is set to <textarget>.

PfhorSlayer
06-22-2005, 09:20 AM
I solved it. It was due to my filtering on the cube map. Apparently my 6800GT doesn't like bilinear filtering on cube maps bound to FBOs. :(