playcanvas / playcanvas-spine

Plugin component for PlayCanvas which enables support for Spine animations.
MIT License
48 stars 18 forks source link

I found that there was a performance problem! #19

Closed gameatp closed 3 years ago

gameatp commented 5 years ago

I found that there was a performance problem, spine. js 'rebuildMeshes' method was frequently called. image

Mesh will be created and released frequently

willeastcott commented 5 years ago

If the draw order of meshes changes, the vertex/index buffers must be rebuilt. For the example character (the knight) shown animated on the homepage of the repo, rebuildMeshes is never called.

However, I can see that there is probably a good opportunity here for optimization for Spine characters/objects that do frequently cause calls to rebuildMeshes. Using pc.createMeshes is probably a bad idea. A single pc.Mesh should be created once, and the vertex/index buffers should only be recreated if the overall number of vertices changes (which presumably shouldn't happen in the case of a reorder of character parts).

Instead, the vertex/index buffers should just be refilled.

gameatp commented 5 years ago

If the draw order of meshes changes, the vertex/index buffers must be rebuilt. For the example character (the knight) shown animated on the homepage of the repo, rebuildMeshes is never called.

However, I can see that there is probably a good opportunity here for optimization for Spine characters/objects that do frequently cause calls to rebuildMeshes. Using pc.createMeshes is probably a bad idea. A single pc.Mesh should be created once, and the vertex/index buffers should only be recreated if the overall number of vertices changes (which presumably shouldn't happen in the case of a reorder of character parts).

Instead, the vertex/index buffers should just be refilled.

That's what I think. I tried to do it, but it didn't work. Maybe I wrote something wrong.

e-strokov commented 5 years ago

Spine plugin rebuilds meshes only if there are multiple atlases assigned to attachments and depth-order of those attachments changes. So, I can recommend to minimise the number of textures or align attachments corresponding to texture to avoid reordering. And unfortunately number of vertices is not constant.

gameatp commented 5 years ago

Spine plugin rebuilds meshes only if there are multiple atlases assigned to attachments and depth-order of those attachments changes. So, I can recommend to minimise the number of textures or align attachments corresponding to texture to avoid reordering. And unfortunately number of vertices is not constant.

But,There's probably more than one texture for animation.

gameatp commented 5 years ago

I feel that rebuild has a high probability. Is there a better way, for example, to create a buffer mesh list and take it out?

------------------ 原始邮件 ------------------ 发件人: "e-strokov"notifications@github.com; 发送时间: 2019年6月3日(星期一) 下午5:56 收件人: "playcanvas/playcanvas-spine"playcanvas-spine@noreply.github.com; 抄送: "zz"442739441@qq.com;"Author"author@noreply.github.com; 主题: Re: [playcanvas/playcanvas-spine] I found that there was aperformance problem! (#19)

Spine plugin rebuilds meshes only if there are multiple atlases assigned to attachments and depth-order of those attachments changes. So, I can recommend to minimise the number of textures or align attachments corresponding to texture to avoid reordering. And unfortunately number of vertices is not constant.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

mvaligursky commented 3 years ago

I'll close this as the rendering system i question has been completely rewritten since then, and should perform a lot better overall.