Skip to main content

Load Times

2 replies [Last post]
miles
Offline
Joined: 2004-06-05
Points: 0

So we have a 2D application implemented both using managed images in Java2D, and in Java3D; the images/textures are pretty big.

I've noticed on several machines that the Java3D version seems to take notably longer (2-3x) to load. By the same token, it seems to take notably longer to load a simple Java3D applet versus a simple Java2D applet.

Has anyone else observed this? Anyone have any suggestions on how to improve either startup or texture load times?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Matthew Hilliard

Given that the magnitude of data for a 3D scenegraph is usually
significantly larger than 2-3x what goes into a typical 2D app, that
shouldn't be too bad.

WRT textures, one thing that helps is to cut back on image resolution for
textures, and always use resolutions that are powers of 2.
For example, if I load a 1023x1023 image in j3d, I can expect that single
load to run upwards of 8 seconds on my p4. I can shave a second or two off
by rounding up to 1024, but where it really flies (going down to a few tens
of milliseconds) is cutting the resolution down to 256x256 before loading it.
Also, in many cases, using the utility class
com.sun.j3d.utils.image.TextureLoader to load textures will give you better
performance than simply wrapping a 2D image In an ImageComponent. Try both
paths for yourself and see what works better for your images.

You can leverage the awt.image libraries to resize Images for prior to
loading in j3d (make sure they are powers of 2, and cap the resolutions to
something like 512 or 256), but you'll have to keep a close eye on things
like alphas which will go funny when you resize/repaint them, and you may
just have to load images with alphas without resizing. I also discovered
(and no amount of profiling ever explained it to me), that Images created
by Toolkit or ImageIO, will be loaded by TextureLoader more slowly than
when the same Images repainted into a BufferedImage, and passing the
BufferedImage to TextureLoader instead--it defies logic, but for many apps
written and profiled here, its true.

Matt

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@java3d.dev.java.net
For additional commands, e-mail: interest-help@java3d.dev.java.net

miles
Offline
Joined: 2004-06-05
Points: 0

> Given that the magnitude of data for a 3D scenegraph
> is usually significantly larger than 2-3x what goes into a
> typical 2D app, that shouldn't be too bad.
>

The scenegraph here is intended to provide the same visual effect (presently) as the pure-2D version; hence, the scenegraph is actually quite small: small enough I could draw it on paper, and it contains only TransformGroups, BranchGroups, and single-quad Shapes.

> WRT textures, one thing that helps is to cut back on
> image resolution for
> textures, and always use resolutions that are powers
> of 2.
> For example, if I load a 1023x1023 image in j3d, I
> can expect that single
> load to run upwards of 8 seconds on my p4. I can
> shave a second or two off
> by rounding up to 1024, but where it really flies
> (going down to a few tens
> of milliseconds) is cutting the resolution down to
> 256x256 before loading it.

Yes, all images are pre-sized to be powers of two. Unfortunately, I cannot downsize the images.

Again, though, Java2D can load them very quickly (and even cash them to VRAM if allowed), the time seems to be mostly eaten during the image -> texture conversion process.

> resizing. I also discovered
> (and no amount of profiling ever explained it to me),
> that Images created
> by Toolkit or ImageIO, will be loaded by
> TextureLoader more slowly than
> when the same Images repainted into a BufferedImage,
> and passing the
> BufferedImage to TextureLoader instead--it defies
> logic, but for many apps
> written and profiled here, its true.
>

Weird, I'll defintely have to toy with that.