r.SkinCache.DefaultBehavior

r.SkinCache.DefaultBehavior

#Overview

name: r.SkinCache.DefaultBehavior

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

This variable is created as a Console Variable (cvar).

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.SkinCache.DefaultBehavior is to control the default behavior of the GPU Skin Cache system for skeletal meshes in Unreal Engine 5. It determines whether all skeletal meshes are included in or excluded from the skin cache by default.

This setting variable is primarily used by the rendering system, specifically the GPU Skin Cache subsystem. It is part of the Engine module and affects the behavior of SkinnedMeshComponents.

The value of this variable is set through the console variable system. It is defined as a TAutoConsoleVariable with a default value of 1 (Inclusive).

The associated variable CVarDefaultGPUSkinCacheBehavior directly interacts with r.SkinCache.DefaultBehavior. They share the same value and purpose.

Developers must be aware that:

  1. This variable affects all skeletal meshes in the project by default.
  2. It has two possible values: 0 (Exclusive) and 1 (Inclusive).
  3. When set to Inclusive (1), all skeletal meshes are included in the skin cache by default, and individual meshes must opt-out if needed.
  4. When set to Exclusive (0), all skeletal meshes are excluded from the skin cache by default, and individual meshes must opt-in if needed.
  5. The setting can be overridden for individual meshes that have “Support Ray Tracing” enabled, which forces inclusive behavior for those meshes.

Best practices when using this variable include:

  1. Consider the performance implications of including all meshes in the skin cache versus excluding them.
  2. Use this global setting in conjunction with per-mesh settings for fine-grained control over which meshes use the skin cache.
  3. Be aware of how this setting interacts with ray tracing support on individual meshes.
  4. Monitor performance and adjust the setting based on the specific needs of your project.

Regarding the associated variable CVarDefaultGPUSkinCacheBehavior:

#Setting Variables

#References In INI files

Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:129, section: [/Script/Engine.RendererSettings]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GPUSkinCache.cpp:108

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarDefaultGPUSkinCacheBehavior(
	TEXT("r.SkinCache.DefaultBehavior"),
	(int32)ESkinCacheDefaultBehavior::Inclusive,
	TEXT("Default behavior if all skeletal meshes are included/excluded from the skin cache. If Support Ray Tracing is enabled on a mesh, will force inclusive behavior on that mesh.\n")
	TEXT(" Exclusive ( 0): All skeletal meshes are excluded from the skin cache. Each must opt in individually.\n")
	TEXT(" Inclusive ( 1): All skeletal meshes are included into the skin cache. Each must opt out individually. (default)")
	);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/SkinnedMeshComponent.cpp:2046

Scope (from outer to inner):

file
function     bool USkinnedMeshComponent::IsSkinCacheAllowed

Source code excerpt:

bool USkinnedMeshComponent::IsSkinCacheAllowed(int32 LodIdx) const
{
	static const IConsoleVariable* CVarDefaultGPUSkinCacheBehavior = IConsoleManager::Get().FindConsoleVariable(TEXT("r.SkinCache.DefaultBehavior"));
	const bool bGlobalDefault = CVarDefaultGPUSkinCacheBehavior && ESkinCacheDefaultBehavior(CVarDefaultGPUSkinCacheBehavior->GetInt()) == ESkinCacheDefaultBehavior::Inclusive;

	if (GetMeshDeformerInstance() != nullptr)
	{
		// Disable skin cache if a mesh deformer is in use.
		// Any animation buffers are expected to be owned by the MeshDeformer.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GPUSkinCache.cpp:207

Scope (from outer to inner):

file
function     static inline bool IsGPUSkinCacheInclusive

Source code excerpt:

static inline bool IsGPUSkinCacheInclusive(EShaderPlatform Platform)
{
	static FShaderPlatformCachedIniValue<int32> PerPlatformCVar(TEXT("r.SkinCache.DefaultBehavior"));
	return (PerPlatformCVar.Get(Platform) != 0);
}

bool ShouldWeCompileGPUSkinVFShaders(EShaderPlatform Platform, ERHIFeatureLevel::Type FeatureLevel)
{
	// If the skin cache is not available on this platform we need to compile GPU Skin VF shaders.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:7636

Scope (from outer to inner):

file
function     bool UEngine::HandleSkeletalMeshReportCommand

Source code excerpt:

	};

	static const IConsoleVariable* DefaultGPUSkinCacheBehavior = IConsoleManager::Get().FindConsoleVariable(TEXT("r.SkinCache.DefaultBehavior"));
	bool bSkinCacheGlobalDefault = DefaultGPUSkinCacheBehavior && ESkinCacheDefaultBehavior(DefaultGPUSkinCacheBehavior->GetInt()) == ESkinCacheDefaultBehavior::Inclusive;

	int32 NumMeshes = 0;
	FRHIResourceInfo ResourceInfo;
	for (TObjectIterator<USkeletalMesh> It; It; ++It)
	{

#Associated Variable and Callsites

This variable is associated with another variable named CVarDefaultGPUSkinCacheBehavior. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/SkinnedMeshComponent.cpp:2046

Scope (from outer to inner):

file
function     bool USkinnedMeshComponent::IsSkinCacheAllowed

Source code excerpt:

bool USkinnedMeshComponent::IsSkinCacheAllowed(int32 LodIdx) const
{
	static const IConsoleVariable* CVarDefaultGPUSkinCacheBehavior = IConsoleManager::Get().FindConsoleVariable(TEXT("r.SkinCache.DefaultBehavior"));
	const bool bGlobalDefault = CVarDefaultGPUSkinCacheBehavior && ESkinCacheDefaultBehavior(CVarDefaultGPUSkinCacheBehavior->GetInt()) == ESkinCacheDefaultBehavior::Inclusive;

	if (GetMeshDeformerInstance() != nullptr)
	{
		// Disable skin cache if a mesh deformer is in use.
		// Any animation buffers are expected to be owned by the MeshDeformer.
		return false;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GPUSkinCache.cpp:107

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarDefaultGPUSkinCacheBehavior(
	TEXT("r.SkinCache.DefaultBehavior"),
	(int32)ESkinCacheDefaultBehavior::Inclusive,
	TEXT("Default behavior if all skeletal meshes are included/excluded from the skin cache. If Support Ray Tracing is enabled on a mesh, will force inclusive behavior on that mesh.\n")
	TEXT(" Exclusive ( 0): All skeletal meshes are excluded from the skin cache. Each must opt in individually.\n")
	TEXT(" Inclusive ( 1): All skeletal meshes are included into the skin cache. Each must opt out individually. (default)")
	);