[osg-users] Preprocessing Viewer

Michael May michael_beham at gmx.net
Tue Aug 25 03:59:02 PDT 2015


Hi,

I want to add a pre-processing step for rendering several environment maps. The environment maps are used for rendering the scene later. 
How does it work?

Using multiple (composite)viewers does not work. So, I create a view for preprocessing. The view is then rendered using frame(). 
After render the preprocess view, I remove it and create the view for rendering the scene. Note, both views has several camera slaves.


Code:

//Scene Loading, creating cameras, and so on
...
osg::ArgumentParser psr(&argc, argv);
osgViewer::CompositeViewer* viewer2 = new osgViewer::CompositeViewer(psr);

osgViewer::View* view2 = new osgViewer::View();
view2->setCamera(m_camera2);
view2->setSceneData( scene_obj);
scene_manager->createPreprocess(graphic_context, view2); //Creates camera slaves for pre-processing
viewer2->addView(view2);
viewer2->frame();
viewer2->removeView(view2);

osgViewer::View* view = new osgViewer::View();
view->setCamera(m_camera);
view->setSceneData( scene_obj);

scene_manager->setSlaveCameras(view, graphic_context); //creates camera slaves for scene rendering

//Add Event Handler and so on... 
...

while(!viewer2->done()) 
{
if(!view->getCameraManipulator() && view->getCamera()->getAllowEventFocus())
view->setCameraManipulator(new osgGA::TrackballManipulator());	    
viewer2->setReleaseContextAtEndOfFrameHint(false);
if(_firstFrame)
{
view->init();
if(!viewer2->isRealized())
viewer2->realize();

_firstFrame = false;
}

viewer2->advance(USE_REFERENCE_TIME);   			
viewer2->eventTraversal();
viewer2->updateTraversal();
viewer2->renderingTraversals();
}






This technique works, but the frame-rate decreses dramatically. 
Does anybody have an idea?

Thank you!

Cheers,
Michael

I am using Osg 3.4 rc-2 with GL3.0 profile. 
Code:




------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=64889#64889








More information about the osg-users mailing list