Hi Hartwig, In principle what you are doing should work, the project and modelview matrix by default should be inherited down correctly - there shouldn't be a frame delay.
The only thing that looks like it could cause problem is that you switch off the compute near/far for the slave camera but not the master camera, try doing it for both. Robert. On 7 January 2017 at 18:21, Hartwig Wiesmann <[email protected]> wrote: > Hi, > > I have two graphs that have completely different content. One is used for > initialising the depth buffer, the other one for showing the scene. > > Code: > visibleGraphPtr = ... > depthGraphPtr = ... > depthGraphPtr->getOrCreateStateSet()->setAttributeAndModes(new > osg::ColorMask(false,false,false,false)); // does not use the color buffer > > > > I use two cameras, one for rendering to the depth buffer, the other one > (viewer's main camera) for generating the scene. > > Code: > osg::Camera* renderToDepthCamera(new osg::Camera()); > > renderToDepthCamera->addChild(depthGraphPtr); > renderToDepthCamera->setClearMask(GL_DEPTH_BUFFER_BIT); > renderToDepthCamera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); > renderToDepthCamera->setGraphicsContext(viewer->getCamera()->getGraphicsContext()); > renderToDepthCamera->setRenderOrder(osg::Camera::PRE_RENDER); > renderToDepthCamera->setViewport(viewer->getCamera()->getViewport()); > viewer->addSlave(renderToDepthCamera,false); > > viewer->getCamera()->setClearMask(GL_COLOR_BUFFER_BIT); // use also depth > buffer from pre-rendering > viewer->setSceneData(visibleGraphPtr); > > > > > Basically this setup works. The only problem is that flickering can be seen > when zooming into and out of the scene or moving the scene. > > My explanation is that the camera rendering to the depth buffer is using a > different frustum (namely the old one (one frame old) from the main camera) > than the main camera rendering the visible graph. > > Is there a possibility to eliminate the flicker without using a third render > path at the beginning just to calculate the final frustum? > > I could have implemented the same by using a RTT camera and some shader code > afterwards but I think that this does not make any difference with respect to > flicker, or? > > Any suggestions? Thank you! > > Cheers, > Hartwig > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=69919#69919 > > > > > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

