View Full Version : fbo with attachments of different formats
10-14-2007, 02:52 AM
i set up a fbo with 3 texture attachments of the following type:
internal format: GL_RGBA8
source format: GL_RGBA
source type: GL_UNSIGNED_BYTE
works fine. then i tried to change one of the attachments to this:
internal format: GL_FLOAT_R32_NV
source format: GL_LUMINANCE
source type: GL_FLOAT
now glCheckFramebufferStatusEXT() returns GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT. why? the spec states that all attachments must have the same dimensions (all 1024x768) and bpp. and that's 32 for all of them, isn't it? i've got a gf7800gt.
The reason probably is the 1-component floating format. AFAIK there were drivers out which supported this but now they don't anymore (even with texture rectangle).
To be sure try creating the FBO only with R32 float format buffers and see if that works.
(can't test it with the latest drivers because my laptop drivers are old...)
10-14-2007, 07:21 AM
i did, didn't help. 4-component floating point textures work fine, but i actually just need one channel :p i want to setup a fat buffer for deferred shading like this:
3 fixed-point textures, 4 channels -> 4x8 = 32bpp
1 floating-point texture, 1 channel -> 1x32 = 32bpp
The floating point formats I've been using successfully are only the ones with 3 or 4 components (and not mixed with other formats).
So, if you can't use floating point formats with one component it also won't be possible to use them the way you need it.
Well, then you have to create two fbos and do your calculation in two passes.
10-14-2007, 08:05 AM
maybe i don't even need a color texture.. this is what i save in that texture:
varying vec4 vViewPosition;
vViewPosition = gl_ModelViewMatrix*gl_Vertex;
vViewPosition /= vViewPosition.w;
gl_FragData = vec4( -vViewPosition.z );could i possibly achieve the same with a depth texture?!
10-14-2007, 08:09 AM
You can attach GL_FLOAT_R16_NV & GL_FLOAT_R32_NV to a framebuffer object but you cannot do a linear interpolation into these textures if they are ever used as a source in someother pass.
Also, check the status of you framebuffer object (glCheckFramebufferStatusEXT) once you attach all the different format textures, I bet it would say something like GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT
AFAIK the current FBO spec does not allow different pixel formats to be attached at the same time.
10-14-2007, 08:18 AM
All attached textures must have the same format. It's just that simple.
The only real drawback is that you can't do MRT into multiple formats at once. All other problems can be solved by just binding another framebuffer; the cost is negligible.
10-14-2007, 10:43 AM
Anyone heard about GL_EXTX_framebuffer_mixed_formats yet?
Its appearing in my GTS8800 extension list. But unfortuantely, no information is available on it :-(
10-14-2007, 11:58 AM
mh.. any recommendations how to setup my mrt then?
10-14-2007, 12:25 PM
any recommendations how to setup my mrt then?No. You're not allowed to have color images bound of different internal formats. So all of them have to be 1-channel R32 or all of them have to be 4-channel RGBA-32.
10-14-2007, 01:14 PM
but a depth attachment is allowed, right? any idea if i can achieve what i want using a depth attachment? (see above)
10-14-2007, 02:58 PM
ok another idea.. i could pack my floating-point value in a color. i found this code in a paper on deferred shading:
float color_to_float(vec3 color)
const vec3 byte_to_float=vec3(1,1.0/256.0,1.0/(256.0*256.0));
vec3 float_to_color(float f)
}works fine if the texture is floating-point, but always returns 0 when using fixed-point :(
10-14-2007, 05:59 PM
Perhaps you're running into color clamping? Try disabling that explicitly.
Also, try modifying the code to ensure that the color values are always between 0 and 1.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.