Sps and skeleton

I’d like to use a mesh with its own skeleton in an SPS. Every solid particle will use the same skeleton. To keep things simple, each solid particle is identical to source mesh except for position/rotation/scale. When sps.beginAnimation is called, all the particles will run said animation.

Is this possible ? Or should I just wait for webGPU instead ?

There’s no support about bones in the SPS currently if it’s what you’re talking about.
If you still want to use solid particles, you have to use the particle parenting then.

erm, I’m not sure what you mean by particle parenting here. Is there a doc or example PG ? Does particle parenting allow for skeleton animations? I’m aware there’s no support for bones in SPS currently, I would like that added or I can submit PR for it. The question here is whether its feasible in the first place. If not possible, what/where is the bottleneck ?


You might be better of using instances, which I believe support skeletons. Search this form for instances skeleton for further thoughts on this.

1 Like

Thanks, I see it now. Afraid that particle parenting isn’t possible for my use case. I have tested with instances and getting fps degradation due to the large number of meshes in the scene.

I found that SPS supports custom vertex functions, and although it doesn’t support bones, one can grab the position of the animated mesh (Get vertex position of animated mesh) and pump it via SPS.updateParticleVertex.

sample PG here: Babylon.js Playground

I have not extensively tested it since I do not need large particle count. If there was an easier way to avoid recomputing the positions of the animated mesh, I think the perf would improve. So I guess food for thought or for some coder better than me. :wink:

Which means this feature request is not really needed anymore, which is a good thing. Feel free to close, thank you!!! :slight_smile:

1 Like

Due to some request in this forum, there will be probably a little breaking change soon in the passed vertex parameter.

\\ vertex properties

may become


so could be added, as requested :


and probably also

// or vertex.uv.u and vertex.uv.v, 
// but I prefer .x and .y 
// so it supports all Vector2 operations natively, not sure
1 Like

Ok, thks for the heads-up. :+1:

edit: nvm, my bad

So after more testing, I’ve come to an interesting conclusion. Not sure if its a bug or not. Nevertheless, this is not the best place to post so I’ll make this brief. When the sps particle count is high and SPS1.setParticles() is called every frame even without updating the custom vertex function and even if said function is deregistered from scene, there is a perf hit. PG: https://www.babylonjs-playground.com/#KTL0DN#3

On my rig:
with line 80 commented out: hit 60fps, no issue
with line 80 uncommented: hit only 40fps on chrome fullscreen, hit only 30fps on ffox.

From the code, setParticles shouldn’t be doing much. Don’t understand why it is behaving this way but if anyone is looking to use skeletons with SPS, just note this. Hope it helps.

The SPS performance is directly related to the global amount of vertices when updated each frame.
Moreover, if you enable the vertex update, your custom vertex function will be called on each vertex.

To improve the performance, you may :

  • update only the needed particles only on the needed frames : sps.setParticles(start, end)
  • update only the needed vertices of the needed particles :
sps.updateParticle = function(particle) {
    sps.computeParticleVertex = false;
    if (mustUpdateThisParticleVertices) {
        sps.computeParticleVertex = true;
// the function updateParticleVertex() will then be called 
// only for this particle
1 Like

Thanks, good to know.

If you check the PG (https://www.babylonjs-playground.com/#KTL0DN#3), the custom vertex function is not called at all. The SPS is static. Only SPS1.setParticles() is called every frame, after the single shot anim is completed, setParticles() should have deregistered from scene yet there is still fps drop.

*scratch head