View Full Version : Using FBO to render to partial texture

05-15-2009, 05:26 AM

I'm doing some volume rendering and want to compose the transparent stuff on top of the solid.

I figured I'd use FBO and a depth texture, two passes:

* Render solid color + depth texture
* Compute transparent color depending on depth texture

Is it possible to use the regular color framebuffer and a depth texture in these steps, or do I need to use a separate color buffer (render/texture buffer) since I'm using FBO?

The specs are a bit unclear here, or rather, I couldn't find the appropriate section.

05-15-2009, 05:41 AM
Just render normally, disable depth write and use the depth texture as a color texture for the next pass. This should work, since you just use the depth texture through a normal sampler so it reads the texel values as luminance components.

I think the best thing you can do in these situations is just test. That's what I usually do :)

05-15-2009, 05:43 AM
I was more curions about the first pass. Should I just set GL_BACK_BUFFER as the draw buffer instead of GL_COLOR_ATTACHMENT0 ?

05-15-2009, 05:44 AM
If there's a framebuffer set during rendering it will be used anyway. I mean 0 is the default.

05-15-2009, 05:46 AM
Ok. Will try it then. Thanks!

05-15-2009, 08:09 AM
Hm. I get INCOMPLETE_ATTACHMENT back. 0 doesn't work (glDrawBuffers()), neither does GL_BACK[_LEFT|_RIGHT].

05-15-2009, 09:53 AM
Could you list which textures you have attached and to which slots?

05-19-2009, 08:23 AM
It's probably a multisample problem. My depth buffer texture isn't multisampled and I can't really create one with the current framework. I've worked around it for now.