Really slow after adding animated models

Hi,

I have an animated character model which is currently ~2100 polys using a standard Max skeleton and the FPS drops like crazy when adding them to the screen. This is with nothing else happening or in the scene, as soon as I add any logic or anything else it gets even worse.

iPad 4 (desktop sits in the 50s, typically closer to 60, until adding 8 or more);
0 - 60 fps
1 - 50-55 fps
2 - 50-53 fps
3 - 35-40 fps
4 - 30 fps
5 - 30 fps
6 - 30 fps
7 - 26 fps
8 - 20 fps
9 - 20 fps
10 - 20 fps

Is there something I can do to get this working better ?

I was hoping to have the main characters a few other characters and a bunch of cubes, simple environment, on screen at once; but I can’t even have a few character models without too much slow down.

Have you run the profiling tools in Safari? It would be good to know if this is CPU or GPU bound?

1 Like

How would I go about testing that and getting the info you need ?

Connect your iPad to your computer and enable remote debugging in safarii

In the webkit inspector in Safari you should be able to create a profile: https://developer.apple.com/library/ios/documentation/AppleApplications/Conceptual/Safari_Developer_Guide/Instruments/Instruments.html
which will tell you what is taking the time.

It’s easier to do this in Chrome on the desktop, and you might get similar results. But it may be a different area causing the slowness on the ipad, so it’s worth trying it on the device if possible.

1 Like

Hmm, I’m not really seeing anything, after the loading is done and the SplashScreen is removed there doesn’t seem to be any info showing up in the inspector.

(http://i.imgur.com/FqVVj74.jpg) - The end of the marks in Layout & Rendering and JavaScript & Events is when the game finished loading and actually showed the scene with the characters standing there animating.

Even just having a few blocks (made up of 1 - 4 cube meshes) falling using this.entity.translate on a parent entity (so all the cubes move together) causes the framerate to go up and down and run kinda slow.

Note that after adding a couple characters it will often immediately drop to a solid 30fps (from about 50) for the next few, maybe there’s something in WebGL that may be causing the fps to be capped/throttled or something ?

Sounds like Vsync. On my computer things run at binary fractions of 60FPS: 60, 30, 15, 7.5…
I don’t think you can get around this.

Maybe I’m just old, but in my opinion, this is probably too many. You aren’t running on gaming quality hardware and this isn’t a native game engine. It’s running in a web-browser.
Animated things tend to use a lot of processing power per polygon, particularly if you have a lot of bones. Inverse Kinematics (IK) also uses a fair chunk.
So try use fewer polies and instead introduce some normal maps.

1 Like

[quote]Sounds like Vsync. On my computer things run at binary fractions of 60FPS: 60, 30, 15, 7.5…
I don’t think you can get around this.[/quote]
Hmm, it only seems to really lock to 60 or 30, other than that it seems to be whatever. It jumps around so much it’s hard to tell though.

[quote]Maybe I’m just old, but in my opinion, this is probably too many. You aren’t running on gaming quality hardware and this isn’t a native game engine. It’s running in a web-browser.
Animated things tend to use a lot of processing power per polygon, particularly if you have a lot of bones. Inverse Kinematics (IK) also uses a fair chunk.
So try use fewer polies and instead introduce some normal maps.[/quote]
The artist and animator will not like that. haha. But I guess we have no other choice; even when removing the skeleton all together to just have the model I can’t even get to 10 without big performance hits.

2100 triangles for a character model sounds reasonable for a PlayCanvas game running on mobile.

There are two possibilities for the performance drops you describe.

  1. You are CPU bound.
  2. You are GPU bound.

You can become CPU bound if you submit too many draw calls to the hardware. In PlayCanvas, a draw calls is a ‘mesh instance’. This is essentially a collection of triangles with the same material in a model. (Note that CPU cost is not per-polyon!) For a typical mobile game using PlayCanvas, you probably want to keep the number of draw calls down to about 200 or fewer.

You can become GPU bound by either maxing out the vertex transform or pixel fill capability of the GPU. Typically, it’s rare to see the GPU bottlenecked on vertex transform. It’s far more likely the GPU is struggling to fill the screen’s pixels with the fragment programs used by your scene’s shaders.

I suggest you create and link a simple public project that exhibits performance characteristics that you do not expect or cannot explain and I’ll take a look.

2 Likes

Once the loading is done. Select Javascript & Events. Clear this panel. Then click the Red dot to record some profiling information. You should see a set of events one for each frame.

You can expand out each function and see how long each one took. You can also sort by Total Time to put the most expensive at the top.

This should give you rough overview of what is taking up time. e.g. if your update is taking longer than render. Then your scripts are doing something slow.

1 Like

Hmm, that could explain the slow down after only a couple then. I checked and each character is using 34 draw calls, and each block 1. So it seems like the character has too many meshes ? (I’m not an artist by any means, so I’ll need to pass info along to the modeller).

OK, I’ll take a look there and see what I find.

Thanks guys.

Hmm. It seems as though ammo is taking way too long. As soon as I add any of my kinematic rigidbodies it slows down and ammo is using pretty much all the time … Any idea why ?

All I’m doing is duplicating one of my “prefab” shapes that consist of 1-4 cubes each with a kinematic rigidbody which I listen for collisionstart events (removing those listeners didn’t really change anything) and then move then every frame using entity.translate on their parent entity (so they all move together).

Sorry about all the questions, just getting started here. But you guys have been great :slight_smile:

Artist got me a version of the character reduced to only 2 meshes and that is no longer an issue. Thanks for the help.