[osg-users] Stencil and render to texture

Sebastian Messerschmidt sebastian.messerschmidt at gmx.de
Mon Oct 12 06:02:08 PDT 2015


Hi Nicolas,

The error indicates an incomplete frame buffer setup.
As far as I remember You need to use the PACKED_DEPTH_STENCIL_BUFFER, as 
stencil buffers are not attachable themselves (you cannot directly load 
back a stencil buffer) but only in combination with the depth buffer.
Take a look at the osgpackeddepthstencil example, it might contain some 
additional help.
My own MRT/FBO code is to convoluted to be of any use directly, but it 
seems I use PACKED_DEPTH_STENCIL_BUFFER as well.

Cheers
Sebastian


> Hello Sebastian. Thank you very much for your answer.
>
> I can create a depth texture and share it between the two cameras. It works. However it doesn't share the stencil buffer.
>
> I tried creating a texture for the stencil and attaching it to both camera, just like I did for the depth buffer. Like this :
>
> Code:
>
> osg::Texture2D* _display_stencil = new osg::Texture2D();
> _display_stencil->setInternalFormat(GL_STENCIL_INDEX8_EXT);
> _display_stencil->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::NEAREST);
> _display_stencil->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::NEAREST);
> _stencil_camera->attach(osg::Camera::STENCIL_BUFFER, _display_stencil, 0, 0, false, 0, 0);
> _display_camera->attach(osg::Camera::STENCIL_BUFFER, _display_stencil, 0, 0, false, 0, 0);
>
>
>
> But it gave me an error message "RenderStage::runCameraSetUp(), FBO setup failed, FBO status= 0x8cd6", and it doesn't work of course.
>
> I also tried creating a common texture for both the stencil and the depth buffer, using GL_DEPTH_STENCIL_EXT or GL_DEPTH24_STENCIL8_EXT format, and attaching it to both cameras, but it gave me the same error.
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=65346#65346
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




More information about the osg-users mailing list