Unable to play png animations on loads of quads

I'm creating about a 100 quads that are all displaying an animation. At the moment  there are 3 different

animations, each consisting out of 40 images. These images are png, with an alpha channel, not sized to

the power of 2. One picture is about 500 X 600 pixels.



The program changes textures 24 times a second, per quad. Preloading textures and setting these textures in

the TextureState works fine, but I'm unable to load enough images. The loading on runtime, clearing the

TextureState, loading a new Texture from a file, and setting the Texture into the TextureState, works,

but goes horribly slow.



Is there way to change Textures on a lot of quads (about a 100), and having a decent framerate (atleast 24 fps)?

One thing that would help is to use a texture atlas for each animation instead of individual textures.  Basically you'd place each texture onto a "grid" in a larger image and use a vector translation to shift around the texture when you use it.  Then the renderer would not have to constantly shift in and out textures from video memory.



The second thing you should do is consider if you actually need 500x600 images.  If the quads never or rarely get as large as full screen, then you could probably cut that down by half.



There's lot of other things you could try, like using sub image commands to replace the contents of a single texture rather than swapping things out.  Also, using SharedMesh could help.

bolke what are you working on? new video renderer of sorts?  :wink:

You got the ultimate recipe for slow performance there… A few tips:


  • Use DXT compression in DDS files instead of slow PNG compression

  • Update the quads that are visible on the screen only

  • Use Power-of-two textures (you can resize them to the correct aspect inside the app)

  • Use some sort of frame queuing if possible

  • Increase available Java memory with -Xmx128m -Xms128m commands



There's probably a lot of other stuff you can do.. Benchmark your app.

Renanse is there an example of this "texture atlas" in JME?

Particles use the concept for texture animations, but no there's no specific test showing it off.

If I’m correct, Renanse is talking about a really old trick, which works quite well. I used this technique in a 2D video game I made in an applet for my final semester project 2 years ago.



Here’s the Texture Atlas Wikipedia page



Here’s a really lame example of a Texture Atlas



From far away it looks like a collage, but there are ways you can select just part of the picture. For instance, in my little space-shooter applet, I had 5 different colors of ships. My Texture Atlas was 500 x 100, composed of 5 100x100 blocks. Each 100x100 block was a color of spaceship, and to apply the textures I would simply select the coordinates of the ship I needed.



So say my Texture Atlas was like: Red Ship, Blue Ship, White Ship, Green Ship, Black Ship



I need to get the green ship, so I would select the image from 300, 0 to 400,100 and I would have the entirity of the green ship.



This saves a lot of time because you’re manipulating points on the same texture, not loading textures back and forth.

Mindgamer said:

bolke what are you working on? new video renderer of sorts?  ;)


Nop, school project. End product is supposed to look something like a square filled with people,
all looking at the camera. And all people are moving animations, billboarding towards the camera.
Hence the load of textures. (plus some other stuff, not 3d related)