[osg-users] Visual flicker when using multi-pass technique, related to frustum?

Hartwig Wiesmann hartwig.wiesmann at skywind.eu
Sat Jan 7 10:21:41 PST 2017


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








More information about the osg-users mailing list