r.HairStrands.Meshes

r.HairStrands.Meshes

#Overview

name: r.HairStrands.Meshes

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.HairStrands.Meshes is to enable or disable hair meshes rendering in Unreal Engine 5’s hair strands system. This setting variable is part of the rendering system, specifically for hair rendering.

This setting variable is primarily used in the Renderer module of Unreal Engine 5, particularly in the HairStrands subsystem. It’s defined and used within the HairStrandsInterface.cpp file.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1 (enabled) but can be changed at runtime through console commands or configuration files.

The r.HairStrands.Meshes variable interacts with other hair-related variables such as r.HairStrands.Strands and r.HairStrands.Cards. Together, these variables control different aspects of the hair rendering system.

Developers must be aware that this variable needs to be turned on when the engine starts for hair meshes to render properly. Changing this value at runtime may not have an immediate effect on all hair rendering systems.

Best practices when using this variable include:

  1. Ensure it’s enabled at engine startup if hair mesh rendering is required.
  2. Use it in conjunction with other hair-related variables for comprehensive hair rendering control.
  3. Be cautious when changing its value at runtime, as it may not affect all hair rendering systems immediately.

Regarding the associated variable CVarHairMeshesEnable:

The purpose of CVarHairMeshesEnable is to serve as the internal representation of the r.HairStrands.Meshes console variable within the C++ code.

This variable is used directly in the Renderer module, specifically in the HairStrands subsystem. It’s accessed in the IsHairStrandsEnabled function to determine if hair mesh rendering should be enabled.

The value of CVarHairMeshesEnable is set automatically by the CVar system when r.HairStrands.Meshes is changed.

CVarHairMeshesEnable interacts with other similar variables like CVarHairStrandsEnable and CVarHairCardsEnable to control different aspects of hair rendering.

Developers should be aware that this is an internal variable and should generally not be modified directly. Instead, they should use the r.HairStrands.Meshes console variable to control hair mesh rendering.

Best practices include using the GetValueOnAnyThread() method to safely access the current value of this variable from any thread, as demonstrated in the IsHairStrandsEnabled function.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/HairStrands/HairStrandsInterface.cpp:38

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarHairMeshesEnable(
	TEXT("r.HairStrands.Meshes"), 1,
	TEXT("Enable/Disable hair meshes rendering. This variable needs to be turned on when the engine starts."),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarHairStrandsBinding(
	TEXT("r.HairStrands.Binding"), 1,
	TEXT("Enable/Disable hair binding, i.e., hair attached to skeletal meshes."),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/HairStrands/HairStrandsInterface.cpp:37

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarHairMeshesEnable(
	TEXT("r.HairStrands.Meshes"), 1,
	TEXT("Enable/Disable hair meshes rendering. This variable needs to be turned on when the engine starts."),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarHairStrandsBinding(
	TEXT("r.HairStrands.Binding"), 1,

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/HairStrands/HairStrandsInterface.cpp:189

Scope (from outer to inner):

file
function     bool IsHairStrandsEnabled

Source code excerpt:

	const int32 HairStrandsEnable = CVarHairStrandsEnable.GetValueOnAnyThread();
	const int32 HairCardsEnable   = CVarHairCardsEnable.GetValueOnAnyThread();
	const int32 HairMeshesEnable  = CVarHairMeshesEnable.GetValueOnAnyThread();
	switch (Type)
	{
	case EHairStrandsShaderType::Strands:	return HairStrandsEnable > 0 && (Platform != EShaderPlatform::SP_NumPlatforms ? IsHairStrandsGeometrySupported(Platform) : true);
	case EHairStrandsShaderType::Cards:		return HairCardsEnable > 0;
	case EHairStrandsShaderType::Meshes:	return HairMeshesEnable > 0;
#if PLATFORM_DESKTOP && PLATFORM_WINDOWS