r.EnableMorphTargets

r.EnableMorphTargets

#Overview

name: r.EnableMorphTargets

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.EnableMorphTargets is to control whether morph targets are enabled or disabled in the rendering system of Unreal Engine 5. Morph targets are used for facial animations and other deformations in 3D models.

This setting variable is primarily used in the Engine module, specifically within the SkinnedMeshComponent system. It affects the rendering and processing of skinned meshes, which are commonly used for characters and other animated objects in games.

The value of this variable is set through a console variable (CVarEnableMorphTargets) with a default value of 1, meaning morph targets are enabled by default. Developers can change this value at runtime using console commands or through code.

The associated variable CVarEnableMorphTargets directly interacts with r.EnableMorphTargets. They share the same value and purpose.

Developers must be aware that disabling morph targets (by setting this variable to 0) will affect all skinned meshes in the scene. This can have a significant impact on character animations and facial expressions.

Best practices when using this variable include:

  1. Only disable morph targets if you’re sure you don’t need them in your project or for performance optimization.
  2. If disabling, ensure that your game’s visual quality isn’t negatively impacted.
  3. Consider using it for debugging or performance profiling to isolate issues related to morph target calculations.

Regarding the associated variable CVarEnableMorphTargets:

Developers should use this variable cautiously and be aware of its performance implications. Enabling or disabling morph targets can significantly affect both the visual quality of animated characters and the overall performance of the rendering system.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

	TEXT("True to draw color coded boxes for anim rate."));

static TAutoConsoleVariable<int32> CVarEnableMorphTargets(TEXT("r.EnableMorphTargets"), 1, TEXT("Enable Morph Targets"));

static TAutoConsoleVariable<int32> CVarAnimVisualizeLODs(
	TEXT("a.VisualizeLODs"),
	0,
	TEXT("Visualize SkelMesh LODs"));

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	TEXT("True to draw color coded boxes for anim rate."));

static TAutoConsoleVariable<int32> CVarEnableMorphTargets(TEXT("r.EnableMorphTargets"), 1, TEXT("Enable Morph Targets"));

static TAutoConsoleVariable<int32> CVarAnimVisualizeLODs(
	TEXT("a.VisualizeLODs"),
	0,
	TEXT("Visualize SkelMesh LODs"));

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

Scope (from outer to inner):

file
function     void USkinnedMeshComponent::CreateRenderState_Concurrent

Source code excerpt:

			if(GetSkinnedAsset()->IsValidLODIndex(ModifiedLODLevel))
			{
				const bool bMorphTargetsAllowed = CVarEnableMorphTargets.GetValueOnAnyThread(true) != 0;

				// Are morph targets disabled for this LOD?
				if (bDisableMorphTarget || !bMorphTargetsAllowed)
				{
					ActiveMorphTargets.Empty();
				}

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

Scope (from outer to inner):

file
function     void USkinnedMeshComponent::SendRenderDynamicData_Concurrent

Source code excerpt:

		if (SkelMeshRenderData && SkelMeshRenderData->LODRenderData.IsValidIndex(UseLOD))
		{
			const bool bMorphTargetsAllowed = CVarEnableMorphTargets.GetValueOnAnyThread(true) != 0;

			// Are morph targets disabled for this LOD?
			if (bDisableMorphTarget || !bMorphTargetsAllowed)
			{
				ActiveMorphTargets.Empty();
			}