Hi Team I was wondering what the current state of GPU skinning in playcanvas? I’m currently doing an investigation to lots of animated objects on screen and adding lod support etc but currently I’m finding 80% of the cpu time is spent doing cpu skinning even though its using gpu skinning. I’m probably misunderstanding but is it reasonably I might be able to move these matrix calculations to the gpu instead? Its spending all its time running mulAffine2.
Also I found that it running skinning on every model whether its visible or not but that was easily fixed by moving it till after culling (which helps loads) did seem to obviously break anything so far…
The mulAffine2 prepares the matrices for the skeleton, which are then uploaded to the GPU for skinning. The cpu basically flattens the bone hierarchy. I believe this takes place only for visible meshes.
For performance reasons, it’s good to set custom AABB on the render component though, that can make the culling a bit faster, as otherwise bones are used per frame to evaluate more precise AABB. See RenderComponent | PlayCanvas API Reference
But this part is still missing: Expose option to disable animation playback on invisible characters · Issue #3563 · playcanvas/engine · GitHub
Unfortunately it does run the skinning the whole time, even when not visible as seen here but I’ve patched my own copy to not do that.
so my question is, anything stopping use from running that on the gpu also. its very expensive, would probably be okay if there were some reliable way to do occlusion culling. Do you know of any tools to simplify the bones or is that a manual job? I’m not even using animations in this case which makes it even worse (so presumably stopping animations when stopped wont help here)
As I said, set up customAabb on the render component, and then bones don’t get updated unless the mesh is visible - and so updateCpuSkinMatrices should be gone from the profiler. They get updated to generate precise Aabb based on bones.
if you target only newer devices (for example desktop only), where bones are stored in a float texture, that could be done on the GPU. If you target older devices, where bones could be done using uniform arrays, that is not likely doable on GPU with good performance, as you’d need to read them back to upload as uniforms. And you’d likely not even have float textures in that case.
Thanks man thats good to know I’ll give the custom aabb another go and so what that does
updateCpuSkinMatrices is gone true, but its replaced by an idential updateGpuSkinMatrices which does exactly the same thing lol. Looking into the model itself (a ready player me avatar) its clear they are just too complex so I’ll probably get more success sooner by trying to get a simpler version of it (they have 67 bones each!) with less bones if thats possible