A while ago I asked the list why the StateVisitor::Optimizer was not working
and why I had very poor optimizing results.
I was prompted by more experienced user to investigate the source myself....
This is what I did and I found a few tricks which will make the optimizer work
very well.
This holds especially true if you are building you own geometry of do your own
loader plugin.
1) Flag the DataVariance of all Attributes and osg::Objects as STATIC unless
you want otherwise. I noticed that at least 80% of the optimizer classes
skip states for optimization if the Attributes are not flagged as STATIC. So
"NO STATIC NO OPTIMIZATION".
2) Especially for the StateVisitor::Optimizer class there is also something
else to consider. This Optimizer class should merge all the
similar StateSets, but in my example even though the StateSets had exactly the
same attributes and values they never go merged.
Looking further into that matter I found out that the StateVisitor does a
shallow compare when checking two StateSets for equality,
this means that it looks if the pointers and not their contents are the same.
Although OSG supports StateSets compares which take into account the contents
of the Attributes
there is no way to pass this flag into the StateVisitor::Optimizer class. So
there are two solutions if you want it to work
a) Mess with the source
b) When creating the StateSets take care to attach instanced Attributes whever
possible, by reusing the same pointer if the StateSets Attributes have the same
values.
In general look up yourself the source whenever the optimizer is not working as
expected. Also dont always use the DEFAULT_OPTIMIZATION flags there are many
more flags
which can be used to produce better results. Like the MERGE_GEOMETRY or
TRISTRIP_GEOMETRY flag. Also sometimes running 2 consecutive optimizer passes
with the same flags produces better results than only one pass. Experimenting
is the key.
Dimi
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org