Framebufferobject, DepthTest and Floating Point

Hi, I checked the combination of FBO and Floatingpoint Textures. Everything works fine. But when I enable depth testing, nothing works. I can get around this problem by setting glDrawBuffer to GL_NONE, but is there no way to use both at the same time?
Thanks,
Benjamin

The thing I forgot the mention: I have a renderbuffer as depth buffer, color buffer has got a texture, with the internal format GL_RGB (or similar) the combination (FBO+DepthTest) works fine and very well. But when I change the internal format of the texture to GL_RGB16F_ARB it doesn’t work anymore.
In both cases, I write frag and depth values with a fragment shader.

Are you checking whether the texture and render buffer is being attached properly without any errors? What hardware are you using? I worked with FBO’s on NV3x sometime back, and they had some bad problems with render buffers. So i had to revert back to using depth texture. You can try that too. Just use a depth texture instead of a depth render buffer as the depth attachment. I doubt that there will be any performance difference between using render buffers or regular textures, but can’t say for certain.

What hardware/driver are you using?

  1. I check the framebuffer object after attachment of the renderbuffer and the depth buffer. Everything seems ok. The init:
  
const float bcolor[4] = {0,0,0,0};

	// create renderbuffer and framebuffer
	glGenFramebuffersEXT( 1, &fb );

	// texture
	glGenTextures( 1, &tex );
	glBindTexture( GL_TEXTURE_2D, tex );
	glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB16F_ARB, 512, 512, 0, GL_RGB, GL_FLOAT, 0 ); 
	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, bcolor);

	// render buffer
	glGenRenderbuffersEXT( 1, &depth_rb );
	glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, depth_rb );
	glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16, width, height );

the bind:

	glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fb );
	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex, 0);
	glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb );
 
  1. My card is an ATI 9600. I am using drivers from last friday, 9th, GL_VERSION = 2.0.5523

As I told you in my first postings, everything works fine, if I
a. turn off depth testing
b. or use fixed point format as internal format for the texture. But I need the combination of both.

Addon: I also tried with depth texture. Same problems like before

Verify the width and height values in glRenderbufferStorageEXT. Your code is working at 9600, ATI 5.10 :slight_smile:

I checked it. Same problem persits with both set to 512x512 and other power of two sizes.

@Racoon:
Does it also work, when you try the following:

BIND BUFFER
ENABLE DEPTH TEST
RENDER
DISABLE DEPTH TEST
UNBIND BUFFER

Because without depth testing enabled it works on my card too. But not when I enable depth testing. I also checked this combination on a nvidia. So the questions comes to my mind, if FBO+DepthTesting+Floating Point Textures are not allowed? But there is nothing about that in the spec.

Anyway it is working.

But is unexpected color behavior. So, render code:

glColor (1, 1, 0);
DrawPrimitive ();
glColor (1, 0, 0);
DrawPrimitive ();

Both primitives is red in contrast to in framebuffer 0 output – first - yellow, second - red.

I am afraid I cannot really follow you. I write the frambuffer and the depth buffer’s values with shaders. (gl_FragColor and gl_FragDepth). I have no such abnormal color behaviour. Can you please exactify your assumption?

I am too using a shader with gl_FragColor and gl_FragDepth writing. And too it is working. The test rendering is in two passes. First: draw into FBO with that shader; second: draw into framebuffer the plane with apply FBO’s texture.

Color behaviour. Sorry, I corrected :slight_smile: It is depending from glTexEnv for FBO’s color texture. I set glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE).

Hi,

I found out, that this combination doesn’t work on an ATI 9600/9800. As Emil Persson from ATI told me:

There’s a hardware limitation on R300 class hardware that prohibits you from writing to
depth when using a floating point render target. This should be fixed on
R420 class hardware though (X700 and up).

This means, that the combination of Flaoting Point Buffer + Depth Testing is not possible on 9600/9800.

Benjamin

What’s your hardware Racoon?

ATI 9600, Catalyst 5.10.

Hm, can you send me binary code of programm? If no, I can send it to you (or source).

Post your e-mail, I send you binary and source of main module. (if you want, then I shall add .obj code of other modules to you be able to build the .exe)

arhch…, At present I see what when GL_RGB16F_ARB then writing in the gl_FragDepth is ineffective. But depth test is working.