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
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to