r.HairStrands.Raytracing

r.HairStrands.Raytracing

#Overview

name: r.HairStrands.Raytracing

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.Raytracing is to enable or disable hair strands raytracing geometry in Unreal Engine 5. This setting is specifically for the rendering system, particularly for hair rendering and raytracing.

This setting variable is primarily used in the Renderer module of Unreal Engine, specifically within the HairStrands subsystem. It’s part of the hair rendering and raytracing functionality.

The value of this variable is set through the console variable system in Unreal Engine. It’s initialized with a default value of 1 (enabled) but can be changed at runtime.

The associated variable CVarHairStrandsRaytracingEnable interacts directly with r.HairStrands.Raytracing. They share the same value and purpose.

Developers must be aware that this is an opt-in option per groom asset/groom instance. It’s not a global setting for all hair in the scene, but rather can be applied selectively.

Best practices when using this variable include:

  1. Only enable it for groom assets that require high-quality raytraced rendering.
  2. Be mindful of performance implications, as raytracing can be computationally expensive.
  3. Use it in conjunction with other hair rendering settings for optimal results.
  4. Test thoroughly with different values to find the best balance between visual quality and performance for your specific use case.

Regarding the associated variable CVarHairStrandsRaytracingEnable:

The purpose of CVarHairStrandsRaytracingEnable is identical to r.HairStrands.Raytracing. It’s an internal representation of the console variable used within the C++ code.

This variable is used directly in the IsHairRayTracingEnabled function, which checks if hair raytracing is enabled. This function considers both the global raytracing state and the specific hair strands raytracing setting.

The value of CVarHairStrandsRaytracingEnable is set automatically based on the r.HairStrands.Raytracing console variable.

Developers should be aware that this variable is used in rendering thread-safe contexts and is part of the scalability options. This means it can be adjusted based on different quality settings or hardware capabilities.

Best practices for CVarHairStrandsRaytracingEnable include:

  1. Use the GetValueOnAnyThread() method when accessing its value, as shown in the IsHairRayTracingEnabled function.
  2. Consider the interaction with the global raytracing state when using this variable.
  3. Be aware of its impact on scalability and adjust accordingly for different hardware targets.

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarHairStrandsRaytracingEnable(
	TEXT("r.HairStrands.Raytracing"), 1,
	TEXT("Enable/Disable hair strands raytracing geometry. This is anopt-in option per groom asset/groom instance."),
	ECVF_RenderThreadSafe | ECVF_Scalability);

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

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

DEFINE_LOG_CATEGORY_STATIC(LogHairRendering, Log, All);

static TAutoConsoleVariable<int32> CVarHairStrandsRaytracingEnable(
	TEXT("r.HairStrands.Raytracing"), 1,
	TEXT("Enable/Disable hair strands raytracing geometry. This is anopt-in option per groom asset/groom instance."),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarHairStrandsEnable(
	TEXT("r.HairStrands.Strands"), 1,

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

Scope (from outer to inner):

file
function     bool IsHairRayTracingEnabled

Source code excerpt:

	if (GIsRHIInitialized && !IsRunningCookCommandlet())
	{
		return IsRayTracingEnabled() && CVarHairStrandsRaytracingEnable.GetValueOnAnyThread();
	}
	else
	{
		return false;
	}
}