Hi Colin,

Attributes provide a faster way of changing vertex properties even on a
per object basis, as it means all of your objects can share the same
state. Changing the value of uniforms cause the creation of a new state.
Lots of state changes can be very expensive.

Sure, but some types of state are less costly than others to change. See

http://home.comcast.net/~tom_forsyth/blog.wiki.html#[[Renderstate%20change%20costs]]

Based on my experience of OSG, the performance recommendations I have to
give is that uniforms are to be changed between different classes of
objects ( no more than a handful per frame ). Anything more frequent
should probably be set as a vertex Attribute.

Do you mean using vertex attributes in BIND_OVERALL mode? Otherwise you'd be sending an array of n times the same value for n vertices... So I'm sure that depends on the size of your geometry and how often the same uniform value will be reused between objects too.

OSG sorts by state to minimize state changes, but I'm not sure how it does the sort. If it just compares pointers, then multiple uniforms having the same name and value but not being exactly the same object might cause state changes. A good solution to that is a kind of shader manager which would do the actual adding of a uniform, so that the same object is used when the name and value are the same (kind of like using shared memory in std::string implementations that are expected to do a lot of copy-constructing and assignments).

J-S
--
______________________________________________________
Jean-Sebastien Guay    [email protected]
                               http://www.cm-labs.com/
                        http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to