• Runtimes
  • Pixi.js runtime calculates meshes and ffd anims on GPU

Related Discussions
...

F YEAH, that patch moves all vertex calculations to the shader.

https://github.com/pixijs/pixi-spine/blob/gpupatch/gpupatch/SkinnedMeshPatch.js

Some shader code:

void main(void){,
   vec2 ffd[4];
   ffd[0] = aFfd11.xy * ffdAlpha[0] + aFfd21.xy * ffdAlpha[1] + aFfd31.xy * ffdAlpha[2] + aFfd41.xy * ffdAlpha[3];
   ffd[1] = aFfd11.zw * ffdAlpha[0] + aFfd21.zw * ffdAlpha[1] + aFfd31.zw * ffdAlpha[2] + aFfd41.zw * ffdAlpha[3];
   ffd[2] = aFfd12.xy * ffdAlpha[0] + aFfd22.xy * ffdAlpha[1] + aFfd32.xy * ffdAlpha[2] + aFfd42.xy * ffdAlpha[3];
   ffd[3] = aFfd12.zw * ffdAlpha[0] + aFfd22.zw * ffdAlpha[1] + aFfd32.zw * ffdAlpha[2] + aFfd42.zw * ffdAlpha[3];
   vec3 skinned = vec3( 0 );
   skinned += boneGlobalMatrices[ int(aSkin0[0]) ] * vec3(aSkin0[1] + ffd[0].x, aSkin0[2] + ffd[0].y, 1.0) * aSkin0[3]; 
   skinned += boneGlobalMatrices[ int(aSkin1[0]) ] * vec3(aSkin1[1] + ffd[1].x, aSkin1[2] + ffd[1].y, 1.0) * aSkin1[3]; 
   skinned += boneGlobalMatrices[ int(aSkin2[0]) ] * vec3(aSkin2[1] + ffd[2].x, aSkin2[2] + ffd[2].y, 1.0) * aSkin2[3]; 
   skinned += boneGlobalMatrices[ int(aSkin3[0]) ] * vec3(aSkin3[1] + ffd[3].x, aSkin3[2] + ffd[3].y, 1.0) * aSkin3[3]; 
   gl_Position = vec4(projectionMatrix * skinned, 1.0);
   vTextureCoord = aTextureCoord;
}

I opened a game that uses a lot of spine animations, pasted it into console and got 60 FPS instead of 30.

You can try to port it in other runtimes, I've noticed that people are complaining about performance in Unity.

There're no benchmarks yet, but I'll make them soon.

P.S. Is there anyway to get a discount on spine prof. version just because I'm awesome?

We just put this in our game.

One of our devs WAS getting 12-20 fps. NOW, with no other optimization other than adding this script, he's getting 40-47!!!

I'm getting a rock solid 60fps!!

Thank you Hackerham for making this!


Hackerham :

P.S. Is there anyway to get a discount on spine prof.

Wait .. what? You did all of this and you don't even have a copy of Spine?

Who do we talk to to make this happen? This guy deserves a copy for his contributions! 🙂