Hi,

We have to manage some similar problems. We have different shaders and different uniforms in the same
scene graph.

Some nodes have a cull callback. During the cull traversal, the callback identify the current view/context and push the corresponding state set in the render graph, traverse the children and pop the state set.



On 23/10/2013 18:49, Robert Osfield wrote:
HI Paul,

If you have just a single uniform value per context then I'd simply place the Uniform on the each if the viiewer's osg::Camera's StateSet, such that each Camera assigned to each Context gets it's own state inherited down including the Uniform.

If you want to put a vector of Uniform in the scene graph, then It would probably be most robust to use a custom osg::Group node that manages the cull traversal where it push/pops the approach Unifiorm as well as any resizeGLObjectBuffers/releaseGLObjects etc. The key to doing it thread safe is to make sure you have allocated the vector to the required number of contexts prior to traversal - this is what the resizeGLObjectsBuffers() helps with.

Robert.


On 23 October 2013 17:38, Paul Martz <[email protected] <mailto:[email protected]>> wrote:

    Hi all -- I've been inactive with OSG lately, but from time to
    time get called back. Given my lack of recent experience, I would
    appreciate your help with this issue.

    I have a multicontext/multidisplay app that needs to compute a
    uniform during cull, and it will have a different value for each
    context/display. Computing the uniform value is straightforward,
    but actually executing the uniform per-context during draw is
    somewhat difficult.

    I can't simply store the uniform in the Node's StateSet, for
    example, because doing that during cull is not thread safe.

    Ideally I would store the uniform in a vector indexed by context
    ID, but I don't have a context ID during cull.

    Would it be feasible to store the uniforms in a map indexed by
    RenderStage address, then execute the uniforms from a Camera
    per-draw callback?

    Assuming I use a per-context or per-RenderStage container to store
    the uniforms, how do I initially grow that container in a
    thread-safe way during the first frame?

    What are other people doing in this situation? Thanks in advance
    for the advice.

-- Paul Martz
    Skew Matrix Software LLC

    _______________________________________________
    osg-users mailing list
    [email protected]
    <mailto:[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

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

Reply via email to