fbo with attachments of different formats

i set up a fbo with 3 texture attachments of the following type:

components: 4
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:

components: 1
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…)

i did, didn’t help. 4-component floating point textures work fine, but i actually just need one channel :stuck_out_tongue: 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.


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[3] = vec4( -vViewPosition.z );

could i possibly achieve the same with a depth texture?!

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.

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.

Anyone heard about GL_EXTX_framebuffer_mixed_formats yet?

Its appearing in my GTS8800 extension list. But unfortuantely, no information is available on it :frowning:

mh… any recommendations how to setup my mrt then?

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.

but a depth attachment is allowed, right? any idea if i can achieve what i want using a depth attachment? (see above)

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));
	return dot(color,byte_to_float);

vec3 float_to_color(float f)
	vec3 color;
	return color;

works fine if the texture is floating-point, but always returns 0 when using fixed-point :frowning:

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.