Hi Jimmy,

Regarding of having a flat scene graph. Does it matter if the whole scene will 
always be seen? Would it still improve the performance if I balance the scene 
graph more?

In the case where the whole scene will always be seen (think about it carefully, though, because I think these cases should be rare in practice) then balancing the graph will not help, but removing groups and transforms will. That is to say, if all your objects will always be visible, then in order to reduce the cull time you need to reduce the number of objects to traverse to get to the geometry. To reduce the draw time, you need to group geometry so that data is uploaded to the card in good-sized chunks.

So for example, if two objects will always be in the same position relative to one another, place both in the same osg::Geometry, transforming the vertices of the second one to be where the transform would have placed it relative to the first.

Say object 0 has vertex array V0 and object 1 has vertex array V1, and suppose that object 0 is at world position T0 and object 1 is at position T1, then you can build a vertex array V2 containing the vertices of both objects like this:

V2 = (V0, V1 + (T1 - T0))

(suppose the addition above will apply the same translation to all vertices in V1) and then position the composite object at position T0.

You can extend this if you have groups of many objects that will always be in the same relative position from each other, of course. For example if a city has buildings and all the buildings are static in world space, then place them all in the world coordinate frame with no transforms or groups. They can still be in different geometry objects if they have a sufficient number of vertices (thousands). If not, then group several of them in the same geometry object and use a texture atlas to texture them all with the same texture file.

Similar scene graph optimization tips have been discussed in the past on the list. The archives should contain even more tips. I don't know if there is a wiki page on openscenegraph.org that collects such tips, but if there isn't we should create one...

Hope this helps,

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