[osg-users] Multiple render passes and multithreading

Sebastian Messerschmidt sebastian.messerschmidt at gmx.de
Wed May 3 08:49:28 PDT 2017


I've just stumbled upon something I find hard to understand.
My setup contains multiple cameras (using FBO and MRT) with a specific 
render-order set to them. The first camera is essentially a 
render-scene-to-MRT pass.
In the simplest case a second camera will pick up the textures rendered 
to and use them to draw to the framebuffer.

A cull-callback is attached to the group containing the cameras. The 
callback simply extracts the current ViewMatrix and passes it to the 
stateset as a uniform. This uniform is used in one of later 
cameras/passed to reconstruct worldspace from the depth buffer.

Now while this all works great when setting the viewer to 
SingleThreaded, it seems that using multithreading in the viewer causes 
the Uniform for the ViewMatrix to be from the previous frame in some 
cases. From my understanding the cull-visitor runs asynchronously to the 
drawing, causing the uniform to be either from the correct or from 
another frame.

What would be the multithreaded-cull/draw alternative to get the 
ViewMatrix (or any other camera-related values) used for rendering in 
the first camera down the chain reliably?


More information about the osg-users mailing list