r.RayTracing.Geometry.SkeletalMeshes

r.RayTracing.Geometry.SkeletalMeshes

#Overview

name: r.RayTracing.Geometry.SkeletalMeshes

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.RayTracing.Geometry.SkeletalMeshes is to control the inclusion of skeletal meshes in ray tracing effects within Unreal Engine 5. This setting variable is primarily used in the rendering system, specifically for ray tracing functionality.

Based on the provided callsites, this variable is utilized in the Engine module, particularly within the SkeletalMesh component. The ray tracing subsystem relies on this setting to determine whether skeletal meshes should be included in ray tracing calculations.

The value of this variable is set using a console variable (CVar) system. It is initialized with a default value of 1, which means skeletal meshes are enabled in ray tracing by default.

The associated variable CVarRayTracingSkeletalMeshes directly interacts with r.RayTracing.Geometry.SkeletalMeshes. They share the same value and purpose.

Developers must be aware that this variable affects the performance and visual quality of ray tracing in scenes containing skeletal meshes. Enabling this feature (value set to 1) will include skeletal meshes in ray tracing calculations, potentially improving visual fidelity but at the cost of increased computational overhead.

Best practices when using this variable include:

  1. Consider the performance impact of enabling skeletal meshes in ray tracing, especially for scenes with many complex skeletal meshes.
  2. Use this setting in conjunction with other ray tracing settings to achieve the desired balance between visual quality and performance.
  3. Test the impact of enabling/disabling this feature in various scenarios to understand its effect on your specific project.

Regarding the associated variable CVarRayTracingSkeletalMeshes:

The purpose of CVarRayTracingSkeletalMeshes is identical to r.RayTracing.Geometry.SkeletalMeshes. It is the actual console variable implementation that controls the inclusion of skeletal meshes in ray tracing effects.

This variable is used in the Engine module, specifically within the SkeletalMesh component and the ray tracing subsystem.

The value of CVarRayTracingSkeletalMeshes is set using the TAutoConsoleVariable template, initialized with a default value of 1.

CVarRayTracingSkeletalMeshes directly interacts with r.RayTracing.Geometry.SkeletalMeshes, as they represent the same setting.

Developers should be aware that this variable is checked in the render thread, as seen in the GetDynamicRayTracingInstances function. This means that changes to this variable will affect ray tracing behavior in real-time.

Best practices for using CVarRayTracingSkeletalMeshes include:

  1. Use this variable for runtime toggling of skeletal mesh ray tracing if needed.
  2. Be cautious when changing this value during gameplay, as it may impact performance and visual consistency.
  3. Consider exposing this setting in your game’s graphics options menu to allow users to optimize performance on their systems.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarRayTracingSkeletalMeshes(
	TEXT("r.RayTracing.Geometry.SkeletalMeshes"),
	1,
	TEXT("Include skeletal meshes in ray tracing effects (default = 1 (skeletal meshes enabled in ray tracing))"));

static TAutoConsoleVariable<int32> CVarSkeletalMeshLODMaterialReference(
	TEXT("r.SkeletalMesh.LODMaterialReference"),
	1,

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

FCustomVersionRegistration GRegisterSkeletalMeshCustomVersion(FSkeletalMeshCustomVersion::GUID, FSkeletalMeshCustomVersion::LatestVersion, TEXT("SkeletalMeshVer"));

static TAutoConsoleVariable<int32> CVarRayTracingSkeletalMeshes(
	TEXT("r.RayTracing.Geometry.SkeletalMeshes"),
	1,
	TEXT("Include skeletal meshes in ray tracing effects (default = 1 (skeletal meshes enabled in ray tracing))"));

static TAutoConsoleVariable<int32> CVarSkeletalMeshLODMaterialReference(
	TEXT("r.SkeletalMesh.LODMaterialReference"),

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

Scope (from outer to inner):

file
function     void FSkeletalMeshSceneProxy::GetDynamicRayTracingInstances

Source code excerpt:

void FSkeletalMeshSceneProxy::GetDynamicRayTracingInstances(FRayTracingMaterialGatheringContext & Context, TArray<struct FRayTracingInstance>& OutRayTracingInstances)
{
	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)