r.HairStrands.Cards

r.HairStrands.Cards

#Overview

name: r.HairStrands.Cards

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.Cards is to enable or disable hair cards rendering in the Unreal Engine 5 rendering system. This setting variable is specifically related to the hair rendering subsystem, which is part of the larger graphics and rendering module in Unreal Engine.

The Unreal Engine subsystem that relies on this setting variable is the Hair Strands rendering system, which is part of the Renderer module. This can be seen from the file path where the variable is defined: Engine/Source/Runtime/Renderer/Private/HairStrands/HairStrandsInterface.cpp.

The value of this variable is set as a console variable using TAutoConsoleVariable. It is initialized with a default value of 1, meaning hair cards rendering is enabled by default. The value can be changed at runtime through the console or programmatically.

This variable interacts with other hair rendering-related variables, specifically CVarHairStrandsEnable and CVarHairMeshesEnable. These variables together control different aspects of hair rendering in the engine.

Developers must be aware that this variable needs to be set when the engine starts, as indicated by the comment in the code. 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 is set appropriately at engine startup for the desired hair rendering behavior.
  2. Consider performance implications when enabling or disabling hair cards rendering.
  3. Use in conjunction with other hair rendering variables for a comprehensive hair rendering setup.

Regarding the associated variable CVarHairCardsEnable:

The purpose of CVarHairCardsEnable is to provide programmatic access to the r.HairStrands.Cards console variable within the C++ code. It allows the engine to query the current state of hair cards rendering.

This variable is used in the IsHairStrandsEnabled function to determine if hair cards rendering is enabled. It’s queried using the GetValueOnAnyThread() method, which suggests that its value can be safely accessed from multiple threads.

Developers should be aware that changes to r.HairStrands.Cards will be reflected in CVarHairCardsEnable, and vice versa. When making programmatic decisions about hair rendering, it’s best to use CVarHairCardsEnable.GetValueOnAnyThread() rather than directly accessing the console variable.

Best practices for using CVarHairCardsEnable include:

  1. Use it for runtime checks of the hair cards rendering state.
  2. Be aware of potential performance implications of frequent checks in performance-critical code paths.
  3. Consider caching the value if it’s accessed frequently and doesn’t need to reflect real-time changes.

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

Scope: file

Source code excerpt:


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."),
	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."),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	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."),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarHairMeshesEnable(
	TEXT("r.HairStrands.Meshes"), 1,

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

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;