Bob Youmans wrote:

Hi All,

I’m starting to develop shader, texture, uniform, etc. code for our app and I have what’s probably a very simple question. I understand these shader-related objects live in the Stateset, and in most examples I see the stateset being set on osg::Geometry within osg:Geodes. If I have an externally loaded model with lots of Geometry and Geode objects, and they all will use the same shader and data, can I put the stateset containing the “stuff” in the “root” Group node, or should I replicate it myself to all the individual nodes (e.g., using update callbacks). I would think that if I have a stateset on the “Group” that acts as the root node, then all the child objects will get their shader stuff ok, right? Even if there’s only one stateset object created, do I still have to set it for the geometry nodes, or will they inherit from the parent path?


Hi, Bob,

Definitely put it as high as you can. A big advantage of a scene graph is that it helps minimize state changes, one of the most expensive operations in hardware rendering. Each distinct StateSet will cause a state change, so it's much better to put one instance at the root of the subgraph than it is to attach a copy to each geometry.

There is some state sorting and optimization done at cull time, so if you actually tried it both ways, you might not see a difference. It's better to be sure, though.

--"J"

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

Reply via email to