[osg-users] Stencil and render to texture
Nicolas Baillard
nicolas.baillard at gmail.com
Mon Oct 12 05:54:20 PDT 2015
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
More information about the osg-users
mailing list