Fbo and stencil?

Hi,
I have tryed with last stable driver (nvidia quadro fx3400) to render a scene to an FBO texture using stencil buffer to mask some parts of the scene,then render the texture on a quad. It works fine if I deactivate stencil masking, but there is a problem when there is stencil masking ( no more image …) . It works previously fine with a pbuffer but no way to do this with FBO. Has anyone succeeded using stencil in conjonction with FBO ? any idee?

Searched the forum?
Currently unsupported. ARB is working on an extension to do depth_stencil.

I have searched the forum! But I was thinking the depth_stencil is an extension to draw a stencil map in a texture ?and I wants to render a scene using stencil mask and draw the scene in a texture to be redraw after . I am confused with these two things.

No, the problem is that current graphic cards don’t support seperate depth and stencil. The depth_stencil extension allows you to specify a combined depth_stencil format. This applies to both textures and renderbuffers…

That means if you want to render to a depth texture and need stencil, you have to render to a depth-stencil texture, if you don’t need the depth texture, you can use a depth-stencil renderbuffer.

So, in conclusion, FBO should works with actual driver with stencil masking ? ( meaning not using depth stencil buffer … I don’t use depth test, only stencil test)

As said, no, it’s currently unsupported.

thanks :slight_smile:
hope coming soon!! because making FBO useless for me!

Shouldn’t take too long on NVIDIA according to this thread: http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_topic;f=3;t=013819

I am trying to use FBO … I have always the same problem… I will render a scene to a texture then redraw after the texture… It works fine with FBO if I don’t use stencil in my scene … .but for example I use stencil to draw only a circle part of a texture. It works fine with pbuffer but not with FBO … Do i need to declare a stencil buffer in my FBO ? I don’t wants to have a stencil texture but I wants to use stencil to render my scene…

regards

To use stencil with FBO is only supported on Nvidia through this extension:
http://oss.sgi.com/projects/ogl-sample/registry/EXT/packed_depth_stencil.txt

yes I know… but I don’t understand how to use it… It don’t wants to render a stencil texture… but I just wants to be able to use a stencil buffer when rendering my scene in an FBO texture. Do I need to declare an FBO stencil texture do that ?

regards,

You don’t have to create a depth/stencil texture. Just create a depth/stencil renderbuffer like so:

GLuint depthStencilIdentifier;

glGenRenderbuffersEXT(1, &depthStencilIdentifier);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthStencilIdentifier);

glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, width, height);

glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthStencilIdentifier);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthStencilIdentifier);

thanks a lot … It works fine !!! I can now trash pbuffer… does anybody have performance problems when replacing pbuffer by FBO ?

Why such a question ? Performance problems could be driver issues.

I don’t have GL_DEPTH24_STENCIL8_EXT in my headers at all, neither any combination of DEPTH and STENCIL. I have the latest drivers for my card (nv 8174), so maybe it is due to linux ? Does anyone knows if that will be incorporated in a near future ? Also could I declare it myself ? If so, I lack its value.

However I have GL_DEPTH_STENCIL_NV which seems to work (didn’t really tested it yet, I’m just in the implementation stage).

Is there something similar on other cards, mainly ATI (like GL_DEPTH_STENCIL_ATI) ?

Hi,
I use glew … and glew is’nt updated … So I have download GLee (see recent news in opengl.org) and copy and past the corresponding declaration…

The relevant extension is
GL_EXT_packed_depth_stencil

ATI has not yet implemented this.

I don’t want to hijack this thread, but after reading the spec is this the only way to get a true 24bit depth buffer is by using the EXT_packed_depth_stencil extension? So the usage example they show by making a texture bound to both the depth and stencil buffers how do I just get the depth portion of the buffer then? I have FBO’s working now and they work fine, but would like to have a bit more precision sometimes than 16bit… The ATI cards all but I think x1600 don’t support 24bit depth buffers…

I was believing that almost all depth buffer are actually 24 bits sized.

Originally posted by jide:
I was believing that almost all depth buffer are actually 24 bits sized.
Maybe I am a bit off and need to restate depth textures? I can’t remember right now which one…