Author Topic: animation performance  (Read 5614 times)

Offline lancew

  • byte
  • *
  • Posts: 11
    • View Profile
animation performance
« on: February 02, 2012, 09:43:35 pm »
Before committing to this engine I needed to verify that it could handle 22 uniquely animated meshes (same base model) concurrently.    Here's the setup code:

Code: [Select]
models = new Object3D[22];
for(int i = 0; i < 22; i++)
{
models[i] = new Object3D(model, false);
        //spread them out in a line for viewing them all at once
        models[i].translate(i*30, 0 0);
models[i].build();
world.addObject(models[i]);
}

I also have the app setup with a Primitive Plane representing the ground:

Code: [Select]
Object3D ground = Primitives.getPlane(10, 200);
ground.build();
ground.setTexture("grass");
ground.calcTextureWrap();
//function from http://www.jpct.net/wiki/index.php/Advanced_example
tileTexture(ground, .5f);
//rotate by 90 degrees to put it on the x-z plane
ground.rotateX(0.0174532925f * 90f);

world.addObject(ground);

as well as the exact skydome model and code from http://www.jpct.net/wiki/index.php/Advanced_example

and then later in the render function:

Code: [Select]
//repeat the animation every 5 seconds
float anim = (float)(System.currentTimeMillis() % 5000)/5000;

for(int i = 0; i < 22; i++)
{
        //set them all to a slightly different key frame
float index = anim + (float)(i*5)/1000;
if(index > 1f)
index -= 1f;
models[i].animate(index);
models[i].build();
}

The compiled app comes out at 488kb.

When all the animations are visible I am getting ~6-10 fps.  With only 1 animation running, it runs at 58-60 fps.  My phone is http://www.htc.com/us/support/aria-att/tech-specs/
Is this low fps what you would expect, or might I have some other problem going on?

The animation I am using is attached (i got it from http://jpct.de/download/mesh/quake2_models.7z)

[attachment deleted by admin]
« Last Edit: February 02, 2012, 09:54:33 pm by lancew »

Offline lancew

  • byte
  • *
  • Posts: 11
    • View Profile
Re: animation performance
« Reply #1 on: February 02, 2012, 10:08:39 pm »
re-sizing the texture to 64x64 showed no improvement.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: animation performance
« Reply #2 on: February 02, 2012, 10:48:38 pm »
Well, the engine can handle this easily...but your phone can't. You have an Android 2.1 based phone with a 600Mhz low end Qualcomm MSM7227 soc/cpu and an Adreno 200 graphics chipset that is more than 1.5 years old. It's not exactly a power horse...and it will suffer greatly from the fact that Android 2.1 has no JIT (Just in time compiler) for the VM, which can speedup things up to 4 times.

On my device, which isn't particularly fast either for today's standards (Nexus S, Android 4.0 (not faster than 2.3.x when it comes to the VM) and a 1Ghz single core cpu), i can render 77 individual instances of your model @ around 30 fps.

So if you are targetting for phones in the range of yours, then no...it can't handle it. But you won't be able to find any engine that can. If you are targetting for more current devices, then yes, it can handle this.

Proof:
« Last Edit: February 02, 2012, 11:18:21 pm by EgonOlsen »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: animation performance
« Reply #3 on: February 02, 2012, 11:09:37 pm »
I did a quick check on my old Galaxy, which is less powerful than your phone (same cpu clock, but no fpu) with Android 1.6 but using a VM with a JIT: It can display 22 models @ 13 fps in my test case. Maybe your performance penalty comes from something else like the rest of your test case? If you want to test animation performance, maybe you should focus on that for now and skip the terrain and such.

Offline lancew

  • byte
  • *
  • Posts: 11
    • View Profile
Re: animation performance
« Reply #4 on: February 02, 2012, 11:11:43 pm »
Thanks for the quick and detailed reply.  I did update my phone to android 2.2, but I'm not sure how much benefit that would provide.

I figured the fact that my phone is 1.5 years old was making a difference (especially since it was the low-end, free with contract phone), but I couldn't be sure exactly how much. 

I'm going to test this on a friends newer phone, and if what you say proves to be true, then this engine meets my needs perfectly =P
« Last Edit: February 02, 2012, 11:18:12 pm by lancew »

Offline lancew

  • byte
  • *
  • Posts: 11
    • View Profile
Re: animation performance
« Reply #5 on: February 02, 2012, 11:14:10 pm »
I did a quick check on my old Galaxy, which is less powerful than your phone (same cpu clock, but no fpu) with Android 1.6 but using a VM with a JIT: It can display 22 models @ 13 fps in my test case. Maybe your performance penalty comes from something else like the rest of your test case? If you want to test animation performance, maybe you should focus on that for now and skip the terrain and such.

Well, the problem with that is that my end product won't be just the animations.  There will be other static models that need to be taken into account.

btw, I'm not intending to use that md2.  It is just for testing purposes, with about the same complexity as I think the models in my product should have.
« Last Edit: February 02, 2012, 11:17:19 pm by lancew »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: animation performance
« Reply #6 on: February 02, 2012, 11:20:48 pm »
Of course...but if something isn't up to the performance that you would expect, it might help to check each aspect individually. Because sometimes, the problem is something that you would have never thought of...been there, done that... ;)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: animation performance
« Reply #7 on: February 02, 2012, 11:22:30 pm »
You might give this a try, albeit i doubt that it'll help much if anything: http://www.jpct.net/wiki/index.php/JPCT-AE_and_libgdx

Offline lancew

  • byte
  • *
  • Posts: 11
    • View Profile
Re: animation performance
« Reply #8 on: February 03, 2012, 08:56:01 pm »
After further testing it seems that 22 animations is very doable.

10fps on HTC Aria (old phone), 18-26fps on LG Optimus (newer but bargain phone), 36-38 on htc inspire,58-60 fps on samsung galaxy nexus (very high end phone), 60 fps on samsung tablet,