PDA

View Full Version : depth textures not working with fbos



angrybob
08-18-2005, 11:34 AM
Ok so I'm trying to get shadowmapping working. The frist thing I've done is setup an fbo with an rgb texture for the color attachment and a depth texture for the depth attachment. I'm rendering from the light's point of view and then displaying the color texture in the corner of the screen so I can see what the light is looking at. the problem is that even though I've bound a depth texture to the depth attachment it is clear that no depth testing is going on. If bind a depth renderbuffer instead of the depth texture then depth testing start to work, but that's no good obviously since I'll need the depth texture later on to do shadowmapping.

to create a depth texture I use:
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, 512, 512, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0);

I check for completeness and it says it's ok so I'm not sure what's wrong

is there any way to test what opengl thinks is bound to each attachment?

jide
08-18-2005, 12:11 PM
Try to check some gl errors. Also, check you disabled reading and drawing from it (glDrawBuffer (GL_NONE); glReadBuffer (GL_NONE); before checking it). Also, read the recent posts about FBOs.

I'd like to also advice to keep depth-texture instead of a depth-rendering buffer. Also keep a color rendering buffer object attached to the vbo.

Hope that helps.

angrybob
08-18-2005, 01:03 PM
I'm not getting any gl errors, checking the fbo's status indicates it is complete, it's just that the depth buffer isn't working... unless I use a depth renderbuffer, which isn't what I want.

maybe this is just a problem with the linux nvidia drivers (using version 7676 btw)

tamlin
08-18-2005, 04:01 PM
Having seen the other issues with FBO, I'm starting to think this is an issue with what FBO is defined to be. An ARB issue...

I'm sure it would be appreciated if one (or more) ARB members shared their opinions re. FBO - perhaps especially in the obvious cases of single-channel. Was that really intended to be unavailable, or was it oversights?

jide
08-19-2005, 01:07 AM
Originally posted by angrybob:
I'm not getting any gl errors, checking the fbo's status indicates it is complete, it's just that the depth buffer isn't working... unless I use a depth renderbuffer, which isn't what I want.

maybe this is just a problem with the linux nvidia drivers (using version 7676 btw)I got the 7667 on linux (maybe your version is a typo error ?) and I need a color renderbuffer object along with a depth texture in order it to work.
Also, be careful of the errors under linux. Check for the gl error directly but not threw glu: it will hang the output stream (at least on my system). This comes from the fact that glu isn't matching the nvidia gl and doesn't know new errors (Ox206 or so, take a look at other posts about fbos).

Tamlin, I read the specs several times, and from what I understood (and regarding the example #7) FBO should be useable with a single depth-texture attached to it (so without any other textures or renderbuffers).
Where the specs don't suffice, it's well explained: vendors could require some specific (non generic) things in order a FBO to be validated.
So, not as you, I think the specs are well defined. But I think we need more information about that for us to conclude and not speculate.

regards

angrybob
08-19-2005, 02:15 AM
Originally posted by jide:
I got the 7667 on linux (maybe your version is a typo error ?) and I need a color renderbuffer object along with a depth texture in order it to work.
Also, be careful of the errors under linux. Check for the gl error directly but not threw glu: it will hang the output stream (at least on my system). This comes from the fact that glu isn't matching the nvidia gl and doesn't know new errors (Ox206 or so, take a look at other posts about fbos).
version 7676 is the latest one http://www.nvidia.com/object/unix.html. I'm checking for errors with glGetError() and there's still nothing wrong.

I've tried using a color renderbuffer with a depth texture (to see the results I just glCopyTex* the color renderbuffer into another texture to view it) but depth testing is still not happening

are there any small but full examples of depth textures that can be run under linux?

angrybob
08-19-2005, 02:20 AM
quick question: if I render to a depth renderbuffer and then just do glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, width, height); with the depth texture bound will it copy the depth values from the renderbuffer, or do i need to fiddle with glReadBuffer() ?

it would slightly defeat the point of fbos but until they work reliably I need a way to work around them

jide
08-19-2005, 02:35 AM
First of all, read docs about gl (mainly about textures and buffers i/o). Also, read the FBO specs.

Then, can you post your code so that we can see what's good and what might not ?

Finally, thank you for the info about the drivers, I always miss the new ones :) I'll try them later.

Also, you wrote "I've tried using a color renderbuffer with a depth texture (to see the results I just glCopyTex* the color renderbuffer into another texture to view it) but depth testing is still not happening"

What exactly have you done ? I tried but failed to understand what you really made.

angrybob
08-19-2005, 04:08 AM
doh! sorry to waste peoples time, the problem was just a simple typo (in my haste to play with fbos I forgot to call glGenTextures() before binding my depth texture).

my shader to view the depth texture currently looks like this:

uniform sampler2D diffusemap;
varying vec2 tc1;

void main (void)

{
vec3 d = texture2D(diffusemap, tc1).rgb;
float depth = d.r + d.g + d.b;
gl_FragColor.rgb = depth*depth*depth*depth / 75;

}

is there any way to make it better?