r.HairStrands.Strands

r.HairStrands.Strands

#Overview

name: r.HairStrands.Strands

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

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.Strands is to enable or disable hair strands rendering in Unreal Engine 5. This setting variable is part of the hair rendering system within the engine’s renderer module.

The Unreal Engine subsystem that relies on this setting variable is the renderer, specifically the hair strands rendering component. This can be seen from the file location (Renderer/Private/HairStrands/HairStrandsInterface.cpp) where the variable is defined and used.

The value of this variable is set as a console variable using TAutoConsoleVariable. It is initialized with a default value of 1 (enabled) and can be changed at runtime through the console or configuration files.

This variable interacts with other hair-related variables, such as r.HairStrands.Cards and r.HairStrands.Meshes (represented by CVarHairCardsEnable and CVarHairMeshesEnable in the code). These variables together control different aspects of hair rendering in the engine.

Developers must be aware that this variable affects the performance and visual quality of hair rendering in their game. Enabling hair strands rendering (value set to 1) will provide more detailed and realistic hair, but may have a performance impact.

Best practices when using this variable include:

  1. Consider the target hardware and performance requirements when deciding whether to enable or disable hair strands rendering.
  2. Use this in conjunction with other hair rendering settings for optimal results.
  3. Test the visual and performance impact of enabling/disabling this feature in various scenarios.

Regarding the associated variable CVarHairStrandsEnable:

The purpose of CVarHairStrandsEnable is to provide programmatic access to the r.HairStrands.Strands console variable within the C++ code.

This variable is used in the renderer module, specifically in the hair strands rendering system.

The value of CVarHairStrandsEnable is set by the console variable r.HairStrands.Strands. It’s accessed in the code using GetValueOnAnyThread() method.

CVarHairStrandsEnable interacts with other similar variables like CVarHairCardsEnable and CVarHairMeshesEnable to determine which aspects of hair rendering are enabled.

Developers should be aware that this variable is used to check if hair strands rendering is enabled in the IsHairStrandsEnabled function, which likely controls whether hair strands-related code paths are executed.

Best practices for using CVarHairStrandsEnable include:

  1. Use it to conditionally execute hair strands-related code.
  2. Be aware of its thread-safety implications, as indicated by the ECVF_RenderThreadSafe flag.
  3. Consider its impact on scalability, as indicated by the ECVF_Scalability flag.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/Android/AndroidEngine.ini:86, section: [ConsoleVariables]

Location: <Workspace>/Engine/Config/IOS/BaseIOSEngine.ini:56, section: [ConsoleVariables]

#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:28

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarHairStrandsEnable(
	TEXT("r.HairStrands.Strands"), 1,
	TEXT("Enable/Disable hair strands rendering"),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarHairCardsEnable(
	TEXT("r.HairStrands.Cards"), 1,
	TEXT("Enable/Disable hair cards rendering. This variable needs to be turned on when the engine starts."),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarHairStrandsEnable(
	TEXT("r.HairStrands.Strands"), 1,
	TEXT("Enable/Disable hair strands rendering"),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarHairCardsEnable(
	TEXT("r.HairStrands.Cards"), 1,

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

Scope (from outer to inner):

file
function     bool IsHairStrandsEnabled

Source code excerpt:

	if (!HairStrandsGlobalEnable) return false;

	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;