r.GPUSkin.Limit2BoneInfluences
r.GPUSkin.Limit2BoneInfluences
#Overview
name: r.GPUSkin.Limit2BoneInfluences
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to use 2 bones influence instead of default 4/8 for GPU skinning. Cannot be changed at runtime.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.GPUSkin.Limit2BoneInfluences is to control the number of bone influences used in GPU skinning for character animation. It’s part of the GPU skinning system in Unreal Engine’s rendering pipeline.
This setting variable is primarily used in the Engine module, specifically within the GPU skinning vertex factory system. It affects shader compilation and the way character meshes are processed for rendering.
The value of this variable is set through a console command, likely initialized at engine startup. It’s defined as a TAutoConsoleVariable, which means it can be changed via console commands or configuration files.
The associated variable CVarGPUSkinLimit2BoneInfluences directly interacts with r.GPUSkin.Limit2BoneInfluences. They share the same value and purpose.
Developers must be aware that changing this variable causes a full shader recompile, which can be a time-consuming process. It’s also marked as ECVF_ReadOnly, indicating that it cannot be changed at runtime.
Best practices for using this variable include:
- Only change it when necessary, as it triggers a full shader recompile.
- Consider the performance implications of using 2 bone influences instead of 4 or 8.
- Use it in conjunction with other GPU skinning optimizations for best results.
Regarding the associated variable CVarGPUSkinLimit2BoneInfluences:
The purpose of CVarGPUSkinLimit2BoneInfluences is the same as r.GPUSkin.Limit2BoneInfluences - to control the number of bone influences in GPU skinning.
It’s used in the Engine module, specifically in the GPUSkinVertexFactory system. It directly affects the shader compilation environment and the way GPU skinning is performed.
The value is set when the TAutoConsoleVariable is initialized, and it’s linked to the console command r.GPUSkin.Limit2BoneInfluences.
This variable interacts with the shader compilation process, setting a define GPUSKIN_LIMIT_2BONE_INFLUENCES based on its value.
Developers should be aware that this variable is used to modify the shader compilation environment, which can have significant impacts on rendering performance and quality.
Best practices include:
- Consider the trade-off between performance and animation quality when enabling this option.
- Test thoroughly with various character models to ensure acceptable results.
- Use in combination with other GPU skinning optimizations for optimal performance.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GPUSkinVertexFactory.cpp:43
Scope: file
Source code excerpt:
// Changing this causes a full shader recompile
static TAutoConsoleVariable<int32> CVarGPUSkinLimit2BoneInfluences(
TEXT("r.GPUSkin.Limit2BoneInfluences"),
0,
TEXT("Whether to use 2 bones influence instead of default 4/8 for GPU skinning. Cannot be changed at runtime."),
ECVF_ReadOnly);
static int32 GCVarUnlimitedBoneInfluences = 0;
static FAutoConsoleVariableRef CVarUnlimitedBoneInfluences(
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/Shader.cpp:2143
Scope (from outer to inner):
file
function void ShaderMapAppendKeyString
Source code excerpt:
{
static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.GPUSkin.Limit2BoneInfluences"));
if (CVar && CVar->GetValueOnAnyThread() != 0)
{
KeyString += TEXT("_2bi");
}
}
{
#Associated Variable and Callsites
This variable is associated with another variable named CVarGPUSkinLimit2BoneInfluences
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GPUSkinVertexFactory.cpp:42
Scope: file
Source code excerpt:
// Whether to use 2 bones influence instead of default 4 for GPU skinning
// Changing this causes a full shader recompile
static TAutoConsoleVariable<int32> CVarGPUSkinLimit2BoneInfluences(
TEXT("r.GPUSkin.Limit2BoneInfluences"),
0,
TEXT("Whether to use 2 bones influence instead of default 4/8 for GPU skinning. Cannot be changed at runtime."),
ECVF_ReadOnly);
static int32 GCVarUnlimitedBoneInfluences = 0;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GPUSkinVertexFactory.cpp:586
Scope (from outer to inner):
file
function void TGPUSkinVertexFactory<BoneInfluenceType>::ModifyCompilationEnvironment
Source code excerpt:
const bool bSupportsPrimitiveIdStream = Parameters.VertexFactoryType->SupportsPrimitiveIdStream();
{
const bool bLimit2BoneInfluences = (CVarGPUSkinLimit2BoneInfluences.GetValueOnAnyThread() != 0);
OutEnvironment.SetDefine(TEXT("GPUSKIN_LIMIT_2BONE_INFLUENCES"), (bLimit2BoneInfluences ? 1 : 0));
}
OutEnvironment.SetDefine(TEXT("GPUSKIN_UNLIMITED_BONE_INFLUENCE"), BoneInfluenceType == UnlimitedBoneInfluence ? 1 : 0);
OutEnvironment.SetDefine(TEXT("GPU_SKINNED_MESH_FACTORY"), 1);