Return to the Java 3D FAQ
Performance Guide for Java 3D 1.1
By Doug Twilleager (Doug.Twilleager@eng.sun.com)
posted to this site by permission
I - Introduction
The Java 3D API was designed with high performance 3D graphics
as a primary goal. Since this is a new API, many of its performance
features are not well known. This document presents the performance
features of Java 3D in a number of ways. It describes the specific
API's that were included for performance. It describes which
optimizations are currently implemented in Java 3D 1.1. And, it describes
a number of tips and tricks that application writers can use to improve
the performance of their application.
II - Performance in the API
There are a number of things in the API that were included specifically
to increase performance. This section examines a few of them.
- Capability bits
Capability bits are the applications way of describing its intentions
to the Java 3D implementation. The implementation examines the
capability bits to determine which objects may change at run time.
Many optimizations are possible with this feature.
- Compile
The are two compile methods in Java 3D 1.1. They are in the
BranchGroup and SharedGroup classes. Once an application calls
compile(), only those attributes of objects that have their
capability bits set may be modified. The implementation may then
use this information to "compile" the data into a more efficient
rendering format.
- Bounds
Many Java 3D object require a bounds associated with them. These
objects include Lights, Behaviors, Fogs, Clips, Backgrounds,
BoundingLeafs, Sounds, and Soundscapes. The purpose of these
bounds is to limit the spatial scope of the specific object.
The implementation may quickly disregard the processing
of any objects that are out of the spatial scope of a target
object.
- Unordered Rendering
All state required to render a specific object in Java 3D is
completely defined by the direct path from the root node to the
given leaf. That means that leaf nodes have no effect on other
leaf nodes, and therefore may be rendered in any order. There
are a few ordering requirements for direct descendents of
OrderedGroup nodes or Transparent objects. But, most leaf nodes
may be reordered to facilitate more efficient rendering
- Appearance Bundles
A Shape3D node has a reference to a Geometry and an Appearance.
An Appearance NodeComponent is simply a collection of other
NodeComponent references that describe the rendering characteristics
of the geometry. Because the Appearance is nothing but a
collection of references, it is much simpler and more efficient for
the implementation to check for rendering characteristic changes when
rendering. This allows the implementation to minimize state changes
in the low level rendering API.
III - Current Optimizations in Java 3D 1.1
This section describes a number of optimizations that are currently
implemented in Java 3D 1.1. Other optimizations will be implemented as
the API matures. The purpose of this section is to help application
programmers focus their optimizations on things that will compliment
the current optimizations in Java 3D.
- Hardware
Java 3D uses OpenGL and Direct3D as the its low level rendering API's.
It relies on the underlying OpenGL and Direct3D drivers for its low
level rendering acceleration. Using a graphics display adapter that
offers OpenGL or Direct3D acceleration is the best way to increase
overall rendering performance in Java 3D.
- Compile
Java 3D currently implements only one compile optimization at this
time. When a BranchGroup is compiled, the implementation descends
the subtree looking for static Shape3D nodes. Once it finds all the
static Shape3D nodes, it will combine Shape3D nodes that have the
same rendering characteristics into a single Shape3D node.
- State Sorted Rendering
Since Java 3D allows for unordered rendering for most leaf nodes,
the implementation sorts all objects to be rendered on a number
of rendering characteristics. The characteristics that are sorted on
are, in order, Lights, Texture, Geometry Type, Material, and finally
localToVworld transform. The only exception to this is any child of
an OrderedGroup node. There is no state sorting for those objects.
- View Frustum Culling
The Java 3D implementation implements view frustum culling.
The view frustum cull is done when an object is processed for a
specific Canvas3D. This cuts down on the number of objects needed
to be processed by the low level graphics API.
- Multithreading
The Java 3D API was designed with multithreaded environments in mind.
The current implementation is a fully multithreaded system. At any
point in time, there may be parallel threads running performing
various tasks such as visibility detection, rendering, behavior
scheduling, sound scheduling, input processing, collision detection,
and others.
IV - Tips and Tricks
This section presents a number of tips and tricks for an application
programmer to try when optimizing their application. These tips focus on
improving rendering framerates, but some may also help overall application
performance. A number of these optimization will eventually be handled
directly by the Java 3D implementation.
Return to the Java 3D FAQ