r.ManyLights.HairVoxelTraces

r.ManyLights.HairVoxelTraces

#Overview

name: r.ManyLights.HairVoxelTraces

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.ManyLights.HairVoxelTraces is to control whether hair voxels are traced in the Many Lights rendering system of Unreal Engine 5. This setting is specifically related to the rendering of hair strands using voxel-based techniques.

This setting variable is primarily used in the Renderer module of Unreal Engine, specifically within the Many Lights ray tracing subsystem. It’s defined and used in the ManyLightsRayTracing.cpp file, which suggests it’s part of the ray tracing pipeline for the Many Lights rendering technique.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1, meaning hair voxel tracing is enabled by default. Developers can change this value at runtime using console commands or through project settings.

The associated variable CVarManyLightsHairVoxelTraces directly interacts with r.ManyLights.HairVoxelTraces. They share the same value and purpose.

Developers must be aware that this variable affects the rendering of hair strands in scenes with many lights. Enabling or disabling this feature can impact both performance and visual quality, especially in scenes with complex hair rendering.

Best practices when using this variable include:

  1. Consider the performance impact of enabling hair voxel tracing, especially on lower-end hardware.
  2. Test the visual difference between enabled and disabled states to determine if the quality improvement justifies any potential performance cost.
  3. Use this in conjunction with other hair rendering settings for optimal results.
  4. Be aware that changes to this setting may require adjustments to other lighting and hair rendering parameters for best results.

Regarding the associated variable CVarManyLightsHairVoxelTraces:

The purpose of CVarManyLightsHairVoxelTraces is identical to r.ManyLights.HairVoxelTraces. It’s the actual console variable that controls the hair voxel tracing feature in the Many Lights system.

This variable is defined and used in the same Renderer module, specifically in the ManyLightsRayTracing.cpp file. It’s part of the ray tracing pipeline for the Many Lights rendering technique.

The value of CVarManyLightsHairVoxelTraces is set when the engine initializes the console variables. It can be modified at runtime through console commands or engine configuration files.

CVarManyLightsHairVoxelTraces directly controls the behavior of the hair voxel tracing feature. It’s checked in the rendering code to determine whether to perform hair voxel tracing.

Developers should be aware that this is a scalability option (ECVF_Scalability flag), meaning it can be adjusted based on the target hardware capabilities. It’s also render thread safe (ECVF_RenderThreadSafe flag), allowing for safe modifications during rendering.

Best practices for using CVarManyLightsHairVoxelTraces include:

  1. Use it in conjunction with other hair rendering and lighting settings for optimal results.
  2. Consider exposing this option in user-facing graphics settings for performance tuning.
  3. Profile the performance impact of enabling/disabling this feature in your specific use case.
  4. Be cautious when changing this value dynamically, as it may cause visual inconsistencies if not properly managed.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ManyLights/ManyLightsRayTracing.cpp:88

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarManyLightsHairVoxelTraces(
	TEXT("r.ManyLights.HairVoxelTraces"),
	1,
	TEXT("Whether to trace hair voxels."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

namespace ManyLights

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ManyLights/ManyLightsRayTracing.cpp:87

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarManyLightsHairVoxelTraces(
	TEXT("r.ManyLights.HairVoxelTraces"),
	1,
	TEXT("Whether to trace hair voxels."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ManyLights/ManyLightsRayTracing.cpp:551

Scope (from outer to inner):

file
function     void ManyLights::RayTraceLightSamples

Source code excerpt:

	const bool bHairVoxelTraces = HairStrands::HasViewHairStrandsData(View)
		&& HairStrands::HasViewHairStrandsVoxelData(View)
		&& CVarManyLightsHairVoxelTraces.GetValueOnRenderThread() != 0;

	FHairVoxelTraceParameters HairVoxelTraceParameters;
	if (bHairVoxelTraces)
	{
		HairVoxelTraceParameters.HairStrands = HairStrands::BindHairStrandsViewUniformParameters(View);
		HairVoxelTraceParameters.VirtualVoxel = HairStrands::BindHairStrandsVoxelUniformParameters(View);