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 ?
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.
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.
Which means this feature request is not really needed anymore, which is a good thing. Feel free to close, thank you!!!
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
}
}
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.