Hi all -- I'm trying to find a way to set a Uniform to a different value depending on the display. In a multi-display environment, this uniform variable would have a different value depending on which display is being rendered to. Ideally, this should support osgViewer as well as other viewer models (direct SceneView usage, osgProducer, VR-Juggler, etc).

I've already looked at supporting this for osgViewer apps by using slave Cameras to hold the Uniforms. If the slave Cameras were actually nodes in the scene graph, this would be pretty easy. For a dual monitor system, the scene graph would be multi-parented to the two slave Cameras, and the slave Camera StateSets would each contain their Uniform with the same uniform variable name but with different values. Unfortunately, slave Cameras are not nodes in the scene graph and don't have StateSets (as far as I know -- someone correct me if slave Cameras actually do have StateSets that affect rendering).

So I looked at how OSG sets the osg_ViewMatrix Uniform for inspiration, because the uniform value could potentially be different for each display. Turns out this is stored in the local StateSet of the SceneView, and there is one SceneView per slave Camera. I imagine I could code a solution like this, but with the SceneView class marked deprecated, I'm reluctant to code a solution that depends on its existence.

Alternatively, it seems like I could use a cull callback to set the Uniform directly in osg::State. But there doesn't appear to be a public method for this. Am I missing something? This would certainly be the easiest and most efficient solution, and would work for any viewer usage, as long as there is a cull traversal per display (a pretty safe bet).

Thanks for any ideas.

(Not that it matters, but the Uniform is a 4x4 matrix, and is a concatenation of the view orientation and the projection with tweaked near/far values. It's derived from the actual view and projection matrices in use per display, so in theory I could derive this matrix in the vertex shader, but it would be redundant to do this work for every vertex.)
--
Paul Martz
Skew Matrix Software LLC
_http://www.skew-matrix.com_ <http://www.skew-matrix.com/>
+1 303 859 9466

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to