PDA

View Full Version : Framebufferobject, DepthTest and Floating Point



olmeca
12-15-2005, 10:53 AM
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

olmeca
12-15-2005, 11:02 AM
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.

Zulfiqar Malik
12-15-2005, 09:09 PM
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.

Fastian
12-15-2005, 09:14 PM
What hardware/driver are you using?

olmeca
12-15-2005, 11:39 PM
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 );
2. 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.

olmeca
12-15-2005, 11:46 PM
Addon: I also tried with depth texture. Same problems like before

Racoon
12-16-2005, 01:27 AM
Verify the width and height values in glRenderbufferStorageEXT. Your code is working at 9600, ATI 5.10 :)

olmeca
12-16-2005, 02:56 AM
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.

Racoon
12-16-2005, 03:57 AM
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.

olmeca
12-16-2005, 04:22 AM
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?

Racoon
12-16-2005, 05:56 AM
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 :) It is depending from glTexEnv for FBO's color texture. I set glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE).

olmeca
12-16-2005, 06:12 AM
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

olmeca
12-16-2005, 06:13 AM
What's your hardware Racoon?

Racoon
12-16-2005, 06:35 AM
ATI 9600, Catalyst 5.10.

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

Racoon
12-16-2005, 06:56 AM
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)

Racoon
12-16-2005, 08:25 AM
arhch..., At present I see what when GL_RGB16F_ARB then writing in the gl_FragDepth is ineffective. But depth test is working.