r.RayTracing.Geometry.SupportSkeletalMeshes

r.RayTracing.Geometry.SupportSkeletalMeshes

#Overview

name: r.RayTracing.Geometry.SupportSkeletalMeshes

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

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.RayTracing.Geometry.SupportSkeletalMeshes is to control whether the project supports skeletal meshes in ray tracing effects. This setting is part of Unreal Engine’s ray tracing system, specifically for handling skeletal mesh geometry.

This setting variable is primarily used in the Engine module, particularly in the ray tracing and skeletal mesh rendering subsystems. The main C++ files that reference this variable are SkeletalMesh.cpp, GPUSkinCache.cpp, and SkeletalRender.cpp.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1 (enabled) and is marked as read-only at runtime, meaning it cannot be changed during gameplay.

This variable interacts closely with other ray tracing and skeletal mesh-related variables. For example, it’s used in conjunction with IsRayTracingAllowed() and GEnableGPUSkinCache in the GPUSkinCache system to determine if GPU skin cache ray tracing is supported.

Developers must be aware that:

  1. This setting is read-only at runtime, so it should be set before the game starts.
  2. Disabling this feature will save GPU memory and processing time, but at the cost of not supporting skeletal meshes in ray tracing effects.
  3. This setting affects the creation of all skeletal mesh ray tracing GPU resources.

Best practices when using this variable include:

  1. Only enable it if your project requires ray tracing for skeletal meshes.
  2. Consider the performance implications, especially for projects targeting lower-end hardware.
  3. Test your project thoroughly with both enabled and disabled states to ensure it functions correctly in both scenarios.

Regarding the associated variable CVarRayTracingSupportSkeletalMeshes:

This is the actual console variable object that controls the r.RayTracing.Geometry.SupportSkeletalMeshes setting. It’s defined in SkeletalMesh.cpp and is used to create and access the console variable.

The purpose of CVarRayTracingSupportSkeletalMeshes is to provide a programmatic way to access and check the value of the r.RayTracing.Geometry.SupportSkeletalMeshes setting within the engine’s C++ code.

This variable is used in the Engine module, specifically in the skeletal mesh rendering and ray tracing systems. It’s referenced in functions related to dynamic ray tracing instances for skeletal meshes.

The value of this variable is set when the console variable is created, with a default value of 1. It can be accessed using GetValueOnRenderThread() method.

Developers should be aware that:

  1. This is the actual variable used in the code to check the setting’s value.
  2. It’s marked as ECVF_ReadOnly, reinforcing that it shouldn’t be changed at runtime.

Best practices for using this variable include:

  1. Use GetValueOnRenderThread() when checking its value in render thread code.
  2. Remember that changes to this variable will affect all skeletal mesh ray tracing in the project.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SkeletalMesh.cpp:118

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarRayTracingSupportSkeletalMeshes(
	TEXT("r.RayTracing.Geometry.SupportSkeletalMeshes"),
	1,
	TEXT("Whether the project supports skeletal meshes in ray tracing effects. ")
	TEXT("Turning this off disables creation of all skeletal mesh ray tracing GPU resources, saving GPU memory and time. ")
	TEXT("This setting is read-only at runtime. (default: 1)"),
	ECVF_ReadOnly);

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

Scope (from outer to inner):

file
function     bool FGPUSkinCache::IsGPUSkinCacheRayTracingSupported

Source code excerpt:

{
#if RHI_RAYTRACING
	static const auto CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.RayTracing.Geometry.SupportSkeletalMeshes"));
	static const bool SupportSkeletalMeshes = CVar->GetInt() != 0;
	return IsRayTracingAllowed() && SupportSkeletalMeshes && GEnableGPUSkinCache;
#else
	return false;
#endif
}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SkeletalRender.cpp:46

Scope (from outer to inner):

file
function     static bool IsSkeletalMeshRayTracingSupported

Source code excerpt:

static bool IsSkeletalMeshRayTracingSupported()
{
	static const auto CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.RayTracing.Geometry.SupportSkeletalMeshes"));
	static const bool SupportSkeletalMeshes = CVar->GetInt() != 0;
	return SupportSkeletalMeshes;
}
#endif // RHI_RAYTRACING

static TAutoConsoleVariable<bool> CVarSkeletalMeshClothBlendEnabled(TEXT("r.SkeletalMeshClothBlend.Enabled"), true, TEXT("Enable the use of the cloth blend weight value set by the skeletal mesh component. When disabled all cloth blend weight will become 0."));

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SkeletalMesh.cpp:117

Scope: file

Source code excerpt:

	TEXT("Whether a material needs to be referenced by at least one unstripped mesh LOD to be considered as used."));

static TAutoConsoleVariable<int32> CVarRayTracingSupportSkeletalMeshes(
	TEXT("r.RayTracing.Geometry.SupportSkeletalMeshes"),
	1,
	TEXT("Whether the project supports skeletal meshes in ray tracing effects. ")
	TEXT("Turning this off disables creation of all skeletal mesh ray tracing GPU resources, saving GPU memory and time. ")
	TEXT("This setting is read-only at runtime. (default: 1)"),
	ECVF_ReadOnly);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SkeletalMesh.cpp:6930

Scope (from outer to inner):

file
function     void FSkeletalMeshSceneProxy::GetDynamicRayTracingInstances

Source code excerpt:

{
	if (!CVarRayTracingSkeletalMeshes.GetValueOnRenderThread()
		|| !CVarRayTracingSupportSkeletalMeshes.GetValueOnRenderThread())
	{
		return;
	}

	// GetRayTracingGeometry()->IsInitialized() is checked as a workaround for UE-92634. FSkeletalMeshSceneProxy's resources may have already been released, but proxy has not removed yet)
	if (MeshObject->GetRayTracingGeometry() && MeshObject->GetRayTracingGeometry()->IsInitialized())