• Runtimes
  • FPS Drop when using 10 Characters in cocos2d-x

Hi,

I am very new to spine, and I am using the latest spine runtime 3.4 in cocos2d-x and when i use 3 characters the game is at 60fps, but when i add few more characters, (about 10-12 characters in total) the FPS drops to 30, i'm using a one plus three to test, and hence hardware cannot be the issue here,

What can i do to optimize this? Cos my game can potentially have 20 characters at once in the scene and this performance is becoming the major problem.
Please let me know what are the usual steps taken towards optimization which i might have missed as this is the first time im using spine for my games.

Thanks

Related Discussions
...

Thanks for replying,


Attached as requested, and this is the only animation i have in my entire game, i am only changing the atlas files for different character, but even if i use the same atlas, the result is the same in terms of FPS

Thanks


I also observed that each character is increasing the GL Verts number of cocos2dx debug text by 3800 exactly

Those numbers show a reasonably complex skeleton. It's not too bad for 1, but multiply them all by 20 and the numbers are pretty big. It could be that 40,000 vertex transforms are using too much CPU, but you would have to profile your actual application to see where the most time is being spent. Without doing this, you will be very much in the dark about what optimizations are appropriate. Profile your app and identify hotspots. Read this page and at least narrow down if your problem is CPU, fill rate, draw calls, or something else.
Metrics - Spine User Guide

That said, some general advice is that using fewer weights, fewer bones, and fewer vertices will reduce the work needed to render your skeleton. The easiest thing to try is to use the Prune button on the Weights view. Prune as much as you can without wrecking your meshes.
Weights - Spine User Guide

3800 sounds too high based on the Metrics view. Do you have the same attachments visible in the editor and when you measure 3800 vertices/skeleton?

Thanks for the reply again,

Yes I did profile my game and the findings are as follows,
spAnimation_apply takes about 12% of the time,
spVertexAttachment_computeWorldVertices1 takes about 18%,
and lastly cocos2d::Renderer::drawBatchedTriangles takes 19%
and the last one is mostly because of the increased gl_Verts if i am not wrong.

These three are the major contributors, (about 40% of the processing is right here)

Yes i will try pruning like you suggested, and to answer your question of attachments,
I am just playing the idle animation which contains all the bones and attachments in the editor, also the way i measured 3800 is with the help of the debug text shown in cocos2dx, every removal/addition of the spine character modifies the GL Verts value by that much.

I will update the numbers after pruning, but even otherwise with the very basic idle animation i have, it should not be this performance intensive, is there any guide to improve performance using spine on an overall level?
Some default practices which has to be followed or some sort? I am just worried that if this might be a bottleneck in smaller/cheap devices.

Thank you

Just playing 20 idle animations is actually computing over 40,000 vertex positions on the CPU, drawing 25,000 triangles, etc.

See the link I posted about the metrics view, which discusses performance issues.

The percentages from your profiling are with how many skeletons?

spAnimation_apply applies the timelines. Each timeline is quite cheap, but many can add up. Fewer timelines will do less work. If you use the latest version of Spine, it will show more metrics, such as the number of timelines in your animation. You can change back to the older version of Spine after looking at the metrics view, just don't save your project else you can't open it in the old Spine version. You could also use the Spine trial (which always runs the latest version) to open your project and look at the metrics view.

spVertexAttachment_computeWorldVertices1 does vertex transforms. Prune will help, potentially a lot.

drawBatchedTriangles can be reduced by using fewer vertices in your meshes, if possible. However, if cocos2dx reports the skeleton as having 3800 vertices, that sounds too high based on your metrics view. 84920=17,000 while 380020=76,000. It would be worth figuring out why they don't agree. You could pare down your skeleton, or maybe try a new skeleton with just 4 vertices, and see what cocos2dx says versus what the metrics view says.