Can I force GPU Skinning?

CPU or GPU skinning, how does the Engine decide which one to use?

I found that for some of my skeletal meshes, unreal is using GPU skinning while for others, it is using CPU.
More specifically, UE4 seems to be using CPU skinning for meshes with higher vert count, which seems weird to me and is causing performance issues for my game.

So, why is the Ungine doing this and is there a setting somewhere to force GPU skinning?

Thanks!

(UE 4.18)

In the editor

If you look around the source code:

bool UDebugSkelMeshComponent::ShouldCPUSkin(){ 
    return bCPUSkinning || bDrawBoneInfluences || 
             bDrawNormals || bDrawTangents || 
             bDrawBinormals || bDrawMorphTargetVerts;
}

(you could hardcode return false as an extreme measure)

In terms of UI in your content browser double click/open a skeletal mesh asset, then go to the Mesh editor

330994-mesh-editor-1.png

In “Show” → “Advanced” → enable “CPU Skinning” and voila!

330995-cpu-skinning-1.png

You’ll notice that if you enable normals, tangents or binormals it will enable CPU skinning as well.


Now on the C++ side

In the code there is a function:

void USkinnedMeshComponent::GetCPUSkinnedVertices(TArray& OutVertices, int32 InLODIndex)

that will allow you to copy skeletal mesh vertices to CPU. Looking at the implementation you’ll deduce that to enable CPU skinning of a USkinnedMeshComponent you need to do:

USkinnedMeshComponent* ptr;
Ptr-> USkinnedMeshComponent::bCPUSkinning = true; 
Ptr->UActorComponent::RecreateRenderState_Concurrent();
FlushRenderingCommands(); // from #include “RenderingThread.h”

Ref: [Get Access to SkeletalMesh Vertices in UE4 | Noah Zuo's Blog][3]


(UE 4.24)

That being said since 4.24 USkinnedMeshComponent::bCPUSkinning is deprecated and the more straightforward USkinnedMeshComponent::SetCPUSkinningEnabled() was introduced.

UI also changed, when I tested it in 4.26 it was still in the viewport menu but under the “Character” menu this time:

330996-cpu-skinning-ue-424-1.png


Bonus: to draw a bone’s skinning weight, go to “Character → Mesh → Selected Bone Weight”
As expected it will automatically enable CPU skinning too:

1 Like