Skinned Mesh Repositioning Causes Lag Due to UpdateInvalidatedFastClusters

Positioning a skinned mesh far away and back causes severe lag, showing up in the micro-profiler under UpdateInvalidatedFastClusters. My use-case for repositioning a skinned mesh far away and back is to create a custom LOD system for skinned mesh characters for a game that will have a large numbers of npc soldiers.

Here’s a demonstration that replicates the issue:
TestSkinnedMesh.rbxl (76.4 KB)

In the demonstration 1,000 skinned meshes are spawned in and moved at a slow pace. Then based on distance to camera some of the meshes are swapped with an LOD version. Note that this swapping involves a separate model altogether, this isn’t instances within the same model being swapped or having their transparencies changed.

The behavior of the test can be modified by changing the attributes of the “CONFIG” variable in the LocalScript under StarterPlayerScripts. Note that right now it’s only set to doing one LOD swap per frame, and yet this still results in severe lag. If you change it to 0 to test out no swapping (or set TestType to “LOD_ONLY” or “BASE_ONLY”) you’ll see that all the lag goes away, so this isolates all of that lag to a simple repositioning far away/back.

Expected behavior

I would expect the cost of swapping out models via repositioning to be equivalent or close to how it is for non-skinned mesh models.

This can be tested in the .rbxl by setting the “BaseFolder” attribute of the config to “Normal” which will use the meshes from the Normal folder in ReplicatedStorage. When swapping normal models there’s no significant lag.

2 Likes

Recreating this, I experienced poor performance with skinned meshes with the MaxSwitchesPerFrame set to 1.


And here’s the frames per second I experienced in-game when testing this:

I then tested with the skinned meshes again, but with MaxSwitchesPerFrame set to 0, so no skinned meshes were being switched with LOD skinned meshes.


And the frames per second in-game:

So, much better performance.

I then tested it out with the normal meshes, not skinned ones, with the MaxSwitchesPerFrame set to 1. I recolored the base model to red, and the LOD model to green to help differentiate the two.


And here’s the frames per second in-game:

The performance was fine using this LOD model swap method with the normal meshes.

It does appear to be a problem specifically with swapping out skinned meshes, evident from how much the performance drops. If it worked as expected, then this would be a great method to reduce lag, but unfortunately it increases it by a lot. I’d like to see a fix to this if it’s possible!

4 Likes

This is a feature, and is actually well documented on the Creator Docs (see link provided). The work around Roblox provides is to simply add a humanoid into the Model that contains the skinned mesh.

Skinned MeshParts that are part of a Model without a Humanoid are grouped using spatially-organized FastClusters. When these MeshParts move, they must be continually added to and removed from these spatial clusters, forcing the clusters to be rebuilt and impacting performance.
https://create.roblox.com/docs/performance-optimization/improve

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.