HI Aurelin, You can attach an osg::StateSet with an osg::Uniform to the osg::Camera assigned to the View(er), this will decorate any scene graph that you attach to the View(er). Placing a uniform on leaf won't effect the global uniform as state is inherited top down.
The only exceptions to this are the positional state which are specifically collected in the cull traversal and then applied together with a modelview matrix right at the start of each RenderStage. If you want to set a uniform value based on the result of cull traversal hitting a leaf then a cull callback that sets a Uniform assigned the Cameras StateSet would do the trick. You'd need to take care of multi-window/multi-threaded set ups though - here you'd need to make sure that you have one Uniform per Window, and use the Camera associated with each Window when managing the appropriate uniform for each window. Robert. On 20 March 2012 17:22, Aurelien Albert <[email protected]> wrote: > Hi, > > I would like to add a global uniform to my scene graph (OSG 3.0.1). > > By "global", I mean that "all shaders can access to its value, anywhere in > the graph" > > So, first I've binded this uniform on my scene graph root object, it works > well. > > But now, the project has evolved and I need a modification : the global > uniform is not anymore a part of the scene graph root object stateset, but > added to a leaf node stateset. > > Is there anyway to make this uniform accessible by every shader in the scene > graph ? > > I'm thinking about the "gl_light" stateattribute which affect the whole scene > even if it's not set on the top object. Is there anyway to get this behavious > for a uniform ? > > I've also read this topic : > http://forum.openscenegraph.org/viewtopic.php?t=4755 : > use cull callback to edit a uniform value, but I need to add a uniform > > And I found this : "osgUtil::SceneView::getGlobalStateSet()" which is maybe > usefull, but the "osgUtil::SceneView" is deprecated, so I don't know if I > really can use it. > > Thank you! > > Cheers, > Aurelien > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=46455#46455 > > > > > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

