[osg-users] Viewer slaves and RTTs

Johny Canes petrussijsma at gmail.com
Fri Feb 17 11:46:39 PST 2017


Hi,

Sorry for one chunky looking post, but it's actually quite coherent. Can I have your short attention it's very appreciated.

I am trying to use viewer slaves with a chain of render-to-textures. I understand this is best done using several cameras.

I've looked at plenty of resources online as well as all the examples.

I am aiming for a postprocessing setup using a main camera and an orthographic camera that renders a quad to the screen.

I have a main camera that renders the scene, attached as

Code:
viewer.addSlave( main, osg::Matrix(), osg::Matrix() );




It is supposed to render the 'scene data' as set by setSceneData. This kind of works... but not without peculiar problems.

And my orthographic camera, with a quad as its child, attached as 
Code:
viewer.addSlave(ortho, osg::Matrix(), osg::Matrix(), false);




One problem is that osgViewer has a default camera, and when I override it with mine using 
Code:
viewer.setCamera( main )

, the z-ordering goes nuts.

The orthographic is rendering its quad properly though, which has its texture set to the color attachment of the main camera, because my main camera has 
Code:
camera->attach( osg::Camera::COLOR_BUFFER, texture, 0, 0, false, 0, 0 );



However, problems remain. I have been outcommenting lines of my code to get nearer to the problem, and random things and unexpected discrepancies are happening as I go.
 

Code:
viewer.addSlave( camera, osg::Matrix(), osg::Matrix() );
viewer.setCamera( camera ); // unnecessary / messes up z-ordering ...



These two lines of code for example. If I switch these lines, the camera will not render (my texture will be black instead of the scene).

Another odd things, is that whilst I've set the color attachment of main, it is still writing to the screen. Sadly, when I tell it to use an FBO, it goes black completely (apparently neither rendering to my color attachment nor the screen).

So I have things working and not working, but currently I am battling some odd behavior that I cannot best.

Cheers,
Johny

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








More information about the osg-users mailing list