PDA

View Full Version : Using FBO to render to partial texture



MarcusL
05-15-2009, 06:26 AM
Hi,

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.

wizard
05-15-2009, 06: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 :)

MarcusL
05-15-2009, 06: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 ?

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

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

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

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

MarcusL
05-19-2009, 09: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.