r.Lumen.Reflections.HairStrands.VoxelTrace

r.Lumen.Reflections.HairStrands.VoxelTrace

#Overview

name: r.Lumen.Reflections.HairStrands.VoxelTrace

This variable is created as a Console Variable (cvar).

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Lumen.Reflections.HairStrands.VoxelTrace is to control whether hair voxel structures are traced for hair casting shadows onto opaque surfaces in Lumen reflections. This setting variable is part of the Lumen reflection system in Unreal Engine 5.

The Lumen reflection system, which is part of the rendering module, relies on this setting variable. It is used in conjunction with the hair strands rendering system to determine if hair voxel tracing should be performed during reflection calculations.

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

This variable interacts closely with GLumenReflectionHairStrands_VoxelTrace, which is the internal C++ representation of the console variable. They share the same value and are used interchangeably in the code.

Developers should be aware that:

  1. This feature is only relevant when hair strands are present in the scene and have voxel data.
  2. Enabling this feature may have performance implications, especially in scenes with complex hair rendering.
  3. The effect of this variable is dependent on the overall Lumen reflection system being enabled and configured correctly.

Best practices when using this variable include:

  1. Only enable it when hair strand voxel data is actually needed for reflections.
  2. Monitor performance impact when enabling this feature, especially on lower-end hardware.
  3. Consider disabling it for performance optimization if the visual impact is negligible in your specific use case.

Regarding the associated variable GLumenReflectionHairStrands_VoxelTrace: This is the internal C++ representation of the console variable. It is used directly in the code to check if hair voxel tracing should be performed. It is set to the same value as the console variable and is used in various parts of the Lumen reflection system to conditionally include hair voxel tracing in the reflection calculations. The same considerations and best practices apply to this variable as to the console variable it represents.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReflectionTracing.cpp:55

Scope: file

Source code excerpt:

int32 GLumenReflectionHairStrands_VoxelTrace = 1;
FAutoConsoleVariableRef GVarLumenReflectionHairStrands_VoxelTrace(
	TEXT("r.Lumen.Reflections.HairStrands.VoxelTrace"),
	GLumenReflectionHairStrands_VoxelTrace,
	TEXT("Whether to trace against hair voxel structure for hair casting shadow onto opaques."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

int32 GLumenReflectionHairStrands_ScreenTrace = 1;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReflectionHardwareRayTracing.cpp:476

Scope (from outer to inner):

file
function     void RenderLumenHardwareRayTracingReflections

Source code excerpt:

	const bool bInlineRayTracing = Lumen::UseHardwareInlineRayTracing(*View.Family) && !bIsHitLightingForceEnabled;
	const bool bUseFarFieldForReflections = LumenReflections::UseFarField(*View.Family);
	extern int32 GLumenReflectionHairStrands_VoxelTrace;
	const bool bNeedTraceHairVoxel = HairStrands::HasViewHairStrandsVoxelData(View) && GLumenReflectionHairStrands_VoxelTrace > 0;
	const bool bTraceTranslucent = bUseHitLighting && LumenReflections::UseTranslucentRayTracing(View);

	checkf(ComputePassFlags != ERDGPassFlags::AsyncCompute || bInlineRayTracing, TEXT("Async Lumen HWRT is only supported for inline ray tracing"));

	const FIntPoint BufferSize = ReflectionTracingParameters.ReflectionTracingBufferSize;
	const int32 RayCount = BufferSize.X * BufferSize.Y;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReflectionTracing.cpp:53

Scope: file

Source code excerpt:

);

int32 GLumenReflectionHairStrands_VoxelTrace = 1;
FAutoConsoleVariableRef GVarLumenReflectionHairStrands_VoxelTrace(
	TEXT("r.Lumen.Reflections.HairStrands.VoxelTrace"),
	GLumenReflectionHairStrands_VoxelTrace,
	TEXT("Whether to trace against hair voxel structure for hair casting shadow onto opaques."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

int32 GLumenReflectionHairStrands_ScreenTrace = 1;
FAutoConsoleVariableRef GVarLumenReflectionHairStrands_ScreenTrace(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReflectionTracing.cpp:941

Scope (from outer to inner):

file
function     void TraceReflections

Source code excerpt:

	}
	
	bool bNeedTraceHairVoxel = HairStrands::HasViewHairStrandsVoxelData(View) && GLumenReflectionHairStrands_VoxelTrace > 0;

	if (Lumen::UseHardwareRayTracedReflections(*View.Family))
	{
		RenderLumenHardwareRayTracingReflections(
			GraphBuilder,
			SceneTextures,

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenVisualizeHardwareRayTracing.cpp:521

Scope: file

Source code excerpt:

#endif // RHI_RAYTRACING

extern int32 GLumenReflectionHairStrands_VoxelTrace;

void LumenVisualize::VisualizeHardwareRayTracing(
	FRDGBuilder& GraphBuilder,
	const FScene* Scene,
	const FSceneTextureParameters& SceneTextures,
	const FViewInfo& View,

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenVisualizeHardwareRayTracing.cpp:541

Scope: file

Source code excerpt:

	bool bForceHitLighting = LumenVisualize::IsHitLightingForceEnabled(View, bLumenGIEnabled);
	bool bInlineRayTracing = Lumen::UseHardwareInlineRayTracing(*View.Family);
	const bool bNeedTraceHairVoxel = HairStrands::HasViewHairStrandsVoxelData(View) && GLumenReflectionHairStrands_VoxelTrace > 0;
	const bool bTraceTranslucent = LumenReflections::UseTranslucentRayTracing(View);

	// Reflection scene view uses reflection setup
	if (VisualizeParameters.VisualizeMode == VISUALIZE_MODE_REFLECTION_VIEW)
	{
		bTraceFarField = LumenReflections::UseFarField(*View.Family);