For rendering, data variance only applies to Drawables and StateSets, not
to Nodes. Data variance on Nodes is only honored by the osgUtil::Optimizer.
So if you want to change your materials at runtime in multi-threaded mode,
set the StateSet d.v. to DYNAMIC.


Glenn Waldron / @glennwaldron


On Thu, Aug 29, 2013 at 8:15 AM, Robert Milharcic <
robert.milhar...@ib-caddy.si> wrote:

> On 29.8.2013 10:30, Peter Bako wrote:
>
>> Hello guys.
>>
>> What is the correct way to change materials during rendering? What
>> callbacks should I use, update callback?
>> Sometimes I get a crash and I assume it is becasue of changing the
>> material.
>>
>> Should I use special updateCallback on every geode/geometry I am
>> changing, or it is enough to use the callback on a parent and change the
>> state attributes also on children?
>>
>> Should the data variance be DYNAMIC on these nodes?
>>
> Hi Peter,
>
> If I'm not mistanken, DYNAMIC variance has to be set only at the Node(s)
> associated with the state set (containing material state attribute)  you
> want to modify. Then you can change material before or after frame, in
> update or event traversal, or you can attach update operation to the
> viewer/view with addUpdateOperation/**removeUpdateOperation .
>
> Changing variance to DYNAMIC will introduce some performance penalty. If
> this is unacceptable you can always use "clone state set trick". You simply
> clone state set, change it, and then assign new stateset and update its
> parents. Old state set will be deleted by ref_ptr when no longer needed.
> This will prevent disruption of the rendering traversals. See how it is
> done in StateSetManipulator::clone() in osgGA module.
>
> If I'm wrong please someone correct me :)
>
> Robert Milharcic
>
> ______________________________**_________________
> osg-users mailing list
> osg-users@lists.**openscenegraph.org <osg-users@lists.openscenegraph.org>
> http://lists.openscenegraph.**org/listinfo.cgi/osg-users-**
> openscenegraph.org<http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org>
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to