r.SkinCache.RecomputeTangents
r.SkinCache.RecomputeTangents
#Overview
name: r.SkinCache.RecomputeTangents
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
This option enables recomputing the vertex tangents on the GPU.\nCan be changed at runtime, requires both r.SkinCache.CompileShaders=1, r.SkinCache.Mode=1 and r.SkinCache.Allow=1\n 0: off\n 1: on, forces all skinned object to Recompute Tangents\n 2: on, only recompute tangents on skinned objects who ticked the Recompute Tangents checkbox(default)\n
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.SkinCache.RecomputeTangents is to control the recomputation of vertex tangents on the GPU for skinned objects in Unreal Engine 5. This setting is part of the GPU Skin Cache system, which is used for optimizing skinned mesh rendering.
This setting variable is primarily used by the GPU Skin Cache subsystem within Unreal Engine’s rendering module. It’s specifically related to the skinned mesh rendering and optimization systems.
The value of this variable is set through a console variable (CVarGPUSkinCacheRecomputeTangents) with a default value of 2. It can be changed at runtime through console commands or programmatically.
The associated variable GSkinCacheRecomputeTangents interacts with r.SkinCache.RecomputeTangents. They share the same value and are used interchangeably in the code.
Developers must be aware of the following when using this variable:
- It requires r.SkinCache.CompileShaders=1, r.SkinCache.Mode=1, and r.SkinCache.Allow=1 to function.
- It has three possible values:
- 0: Tangent recomputation is off
- 1: Forces all skinned objects to recompute tangents
- 2 (default): Only recomputes tangents on skinned objects that have the “Recompute Tangents” checkbox ticked
Best practices when using this variable include:
- Use the default value (2) unless you have specific performance or visual quality reasons to change it.
- Be aware that enabling this feature (values 1 or 2) may impact performance, especially on lower-end hardware.
- When developing skinned meshes, consider the implications of this setting on your asset pipeline and runtime performance.
Regarding the associated variable GSkinCacheRecomputeTangents:
The purpose of GSkinCacheRecomputeTangents is to provide a C++ accessible version of the r.SkinCache.RecomputeTangents console variable. It’s used internally by the engine to quickly check the current state of the tangent recomputation setting without having to query the console variable system.
This variable is used in the same subsystems as r.SkinCache.RecomputeTangents, primarily in the GPU Skin Cache and skinned mesh rendering systems.
The value of GSkinCacheRecomputeTangents is set based on the value of CVarGPUSkinCacheRecomputeTangents, which is updated when the console variable changes.
Developers should be aware that while they can read GSkinCacheRecomputeTangents directly in C++ code, they should not modify it directly. Instead, they should use the console variable system to change the value of r.SkinCache.RecomputeTangents.
Best practices for GSkinCacheRecomputeTangents include using it for quick checks in performance-critical code paths where querying the console variable might be too slow.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GPUSkinCache.cpp:117
Scope: file
Source code excerpt:
int32 GSkinCacheRecomputeTangents = 2;
TAutoConsoleVariable<int32> CVarGPUSkinCacheRecomputeTangents(
TEXT("r.SkinCache.RecomputeTangents"),
2,
TEXT("This option enables recomputing the vertex tangents on the GPU.\n")
TEXT("Can be changed at runtime, requires both r.SkinCache.CompileShaders=1, r.SkinCache.Mode=1 and r.SkinCache.Allow=1\n")
TEXT(" 0: off\n")
TEXT(" 1: on, forces all skinned object to Recompute Tangents\n")
TEXT(" 2: on, only recompute tangents on skinned objects who ticked the Recompute Tangents checkbox(default)\n"),
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SkeletalMeshLODRenderData.cpp:91
Scope (from outer to inner):
file
function static bool RequiresDuplicateVerticesInCook
Source code excerpt:
{
// DuplicatedVertices are cooked if we have GPUSkinCache or MeshDeformer systems for this platform.
// We always cook when GPUSkinCache is available so that we can support runtime switch of r.SkinCache.RecomputeTangents.
// For MeshDeformer we only cook if the section was marked for bRecomputeTangent.
const bool bMeshDeformersAvailable = IsMeshDeformerAvailable(InPlatform);
return (RenderSection.bRecomputeTangent && bMeshDeformersAvailable) || IsGPUSkinCacheAvailable(InPlatform);
}
static bool RequiresDuplicateVerticesInCook(const ITargetPlatform& InTargetPlatform, FSkelMeshRenderSection const& RenderSection)
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/GPUSkinCache.h:18
Scope: file
Source code excerpt:
// * fixed amount of memory per Scene (r.SkinCache.SceneMemoryLimitInMB)
// * Velocity Rendering for MotionBlur and TemporalAA (test Velocity in BasePass)
// * r.SkinCache.Mode and r.SkinCache.RecomputeTangents can be toggled at runtime
// TODO:
// * Test: Tessellation
// * Quality/Optimization: increase TANGENT_RANGE for better quality or accumulate two components in one 32bit value
// * Bug: UpdateMorphVertexBuffer needs to handle SkinCacheObjects that have been rejected by the SkinCache (e.g. because it was running out of memory)
// * Refactor: Unify the 3 compute shaders to use the same C++ setup code for the variables
#Associated Variable and Callsites
This variable is associated with another variable named CVarGPUSkinCacheRecomputeTangents
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GPUSkinCache.cpp:116
Scope: file
Source code excerpt:
int32 GSkinCacheRecomputeTangents = 2;
TAutoConsoleVariable<int32> CVarGPUSkinCacheRecomputeTangents(
TEXT("r.SkinCache.RecomputeTangents"),
2,
TEXT("This option enables recomputing the vertex tangents on the GPU.\n")
TEXT("Can be changed at runtime, requires both r.SkinCache.CompileShaders=1, r.SkinCache.Mode=1 and r.SkinCache.Allow=1\n")
TEXT(" 0: off\n")
TEXT(" 1: on, forces all skinned object to Recompute Tangents\n")
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GPUSkinCache.cpp:2306
Scope (from outer to inner):
file
function void FGPUSkinCache::CVarSinkFunction
Source code excerpt:
{
int32 NewGPUSkinCacheValue = CVarEnableGPUSkinCache.GetValueOnAnyThread() != 0;
int32 NewRecomputeTangentsValue = CVarGPUSkinCacheRecomputeTangents.GetValueOnAnyThread();
const float NewSceneMaxSizeInMb = CVarGPUSkinCacheSceneMemoryLimitInMB.GetValueOnAnyThread();
const int32 NewNumTangentIntermediateBuffers = CVarGPUSkinNumTangentIntermediateBuffers.GetValueOnAnyThread();
const bool NewSkipCompilingGPUSkinVF = CVarSkipCompilingGPUSkinVF.GetValueOnAnyThread();
if (GEnableGPUSkinCacheShaders)
{