The following information was supplied by Doug Gehringer
Implementation Note: Making compile() make your scene graph faster
Quick Summary:
Compiling scene graphs can make certain kinds of scene graphs render much more quickly. To take advantage of compile() your scene graph must: have lots of Shape3Ds which share common attributes and transforms, not have indexed geometry, and not have any capability bits or the "pickablity" flag set.
Compilation is a great unfulfilled promise for most Java3d applications today. The promise is much improved performance, but almost no applications are seeing a performance benefit today. The reasons for this are two-fold: compile() only helps certain kinds of scene graphs and the default flag settings prevent compile() from optimizing the scene graph.
Here is how compile() works. Compile implements two optimizations to the scene graph: attribute sorting and shape merging. Attribute sorting looks at the attributes on the Shape3Ds and builds a list of unique appearances. It then replaces the redundant appearances with references to the unique appearances. This minimizes the overhead to changing appearances as the scene graph is displayed.
Shape | Num Shapes |
Num Tris |
Shape Rate |
Triangle Rate |
---|---|---|---|---|
Tetrahedron | 0.5K | 2K | 4.6K | 18K |
Tetrahedron | 1K | 4K | 4.6K | 19K |
Tetrahedron | 2K | 8K | 5.0K | 20K |
Tetrahedron | 4K | 16K | 5.0K | 20K |
Icosahedron | 0.5K | 10K | 3.3K | 65K |
Icosahedron | 1K | 20K | 3.4K | 68K |
Icosahedron | 2K | 40K | 3.5K | 70K |
Icosahedron | 4K | 80K | 3.6K | 71K |
Shape | Num Shapes |
Num Tris |
Shape Rate |
Triangle Rate |
Compile Time |
---|---|---|---|---|---|
Tetrahedron | 0.5K | 2K | 30K | 125K | 0.6 |
Tetrahedron | 1K | 4K | 60K | 250K | 2.0 |
Tetrahedron | 2K | 8K | 120K | 500K | 8.4 |
Tetrahedron | 4K | 16K | 230K | 920K | 30.9 |
Icosahedron | 0.5K | 10K | 17K | 340K | 0.7 |
Icosahedron | 1K | 20K | 22K | 440K | 2.1 |
Icosahedron | 2K | 40K | 29K | 580K | 9.9 |
Icosahedron | 4K | 80K | 30K | 600K | 34.9 |
This document is based on the Java3D 1.1 implementation. The 1.2 implementation will have the the same behavior, but it will probably deliver the same performance without the same restrictions. 1.2 will deliver implement alot of the performance optimizations of compile() without the restrictions on pickablity, and may have a better implementation of compile() as well.
Doug Gehringer
Sun Microsystems
Return to the Java 3D FAQ