View Full Version : setup for fbo with depth/stencil renderbuffer
08-20-2006, 08:41 AM
i start to feel uncomfortable for asking 2-3 questions a day, and here's another one already ^^
i have a multipass shadow volumes algorithm and a camera attached to one of the light sources. this camera renders to a fbo (which has a depth renderbuffer attached to it) and the fbo's target texture is placed on the front wall. as you can see, the shadows aren't visible. i realized that i have to add stencil support to my fbo and the EXT_packed_depth_stencil extension seems to be what i have to use. but after reading the spec i'm confused even more: in the sample code they create a texture to store depth and stencil information, but i actually thought i had to store this information in a renderbuffer? thanks!
08-20-2006, 09:01 AM
If I get this correctly, you can use either renderbuffers or textures, just like the usual FBO.
08-21-2006, 04:18 AM
ok, but i don't want a 2nd texture, all i want to add is support for the stencil buffer.
08-21-2006, 04:29 AM
Then use a renderbuffer for it :-) Just initialize it to be DEPTH_STENCIL instead of DEPTH
08-21-2006, 08:54 AM
mh doesn't work.
ok if i create a fbo with a depth texture, it works fine. but if i substitute:
glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, m_uiWidth, m_uiHeight, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0 );with:
glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8_EXT, m_uiWidth, m_uiHeight, 0, GL_RGBA, GL_INT, 0 );and:
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, m_pkTarget->GetId(), 0 );with:
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, m_pkTarget->GetId(), 0 );
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, m_pkTarget->GetId(), 0 );.. which is what the spec proposes, then i get a black texture. i just realized that i even get a black texture when i try to use a 24bit depth texture instead of a 16bit one.. is it possible that my good old radeon9800pro is simply not able to handle more than 16bits depth?
08-21-2006, 11:37 AM
You should be seeing a GL_INVALID_ENUM error from this call:
glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8_EXT, m_uiWidth, m_uiHeight, 0, GL_RGBA, GL_INT, 0 );When the format parameter is set to GL_DEPTH_STENCIL_EXT or GL_DEPTH24_STENCIL8_EXT the type must be GL_UNSIGNED_INT_24_8_EXT.
08-21-2006, 12:13 PM
Previous oratour is totally right )))
See this: http://www.opengl.org/registry/specs/EXT/packed_depth_stencil.txt
08-21-2006, 01:08 PM
mh ok but in the same document they do this:
// Setup depth_stencil texture (not mipmap)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8_EXT, 512, 512, 0, GL_RGBA, GL_INT, NULL);
GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, tex_depthstencil, 0);
GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, tex_depthstencil, 0);
mh whatever - still doesn't work :p
08-21-2006, 01:13 PM
That is their bug, and I remember they had a post on this forum that thay have mistaken is the specification.
Try using this:
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8_EXT, 512, 512, 0, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, NULL);
This should work anyhow.
08-21-2006, 02:37 PM
Sorry for the confusion. Jackis is correct that this is a bug in the spec example which was fixed in a later version of the spec (version #12, dated Sept 26, 2005). Unfortunately the registry still has an older version (#11, Sept 20, 2005). I'll make sure the registry gets updated with version #12. Jackis' revised example matches the example in version #12.
08-21-2006, 02:57 PM
thank you, but this didn't help either. to repeat my question, is it possible that my good old radeon9800pro is simply not able to handle more than 16bits depth?
08-21-2006, 03:42 PM
Did you check GL for any errors?
Is your framebbuffer complete after all you've done?
Try to scan GL for errors via glGetLastError() before and after this glTexImage2D() string, if everything is okey, ask FBO object for completeness via checking glCheckFramebufferStatusEXT() to return GL_FRAMEBUFFER_COMPLETE_EXT.
Unfortunately, I've did it on nVidia cards only, they really do support it (24 depth, 8 stencil). I had no problems.
BTW: for waht do you need stencil exactly? As I understood, you render simple shadowmap, you get depth - and that's all you need! Or if you are using shadow volumes - then why do you need to place camera in the light position?
BTW^2: did you ensure, that your driver do support EXT_packed_depth_stencil extension?
BTW^3: read this, it's an Eric Lengyel blog, it's all about ATi and their FBO/dept_stencil support. The very first issue, dated May'06. I don't think, that there are any positive motions from that ((
08-21-2006, 04:39 PM
is it possible that my good old radeon9800pro is simply not able to handle more than 16bits depth?No. Every graphics card of note (that's not a 3DFx one) was capable of 24-bit depth buffers ever since TNT and TNT2.
08-21-2006, 06:05 PM
I made a quick search and it seems to be true: ATI just does not support this extension oO
Well, I guess this is the reason why I stuck with nvidia for last years...
08-28-2006, 07:58 AM
BTW, EXT_packed_depth_stencil is still dated with revision #11 (((
08-28-2006, 09:58 AM
thank you for all this information! so it seems that there's no way to get fbo's working with depth/stencil on an ati card atm, right? it's time to switch to nv i guess -.-
09-10-2006, 03:50 AM
I think there is only one solution how to solve this problem on ATI. You have to render your scene to the standard framebuffer with a stencil buffer support and then copy it to the texture via glCopyTexImage2D. It seems you'll have no choice, if you really need a stencil buffer.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.