r.Lumen.Reflections.DistantScreenTraces

r.Lumen.Reflections.DistantScreenTraces

#Overview

name: r.Lumen.Reflections.DistantScreenTraces

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.Lumen.Reflections.DistantScreenTraces is to control whether to perform a linear screen trace starting where the Lumen Scene ends to handle distant reflections in Unreal Engine 5’s Lumen lighting system.

This setting variable is primarily used in the Lumen reflection system, which is part of Unreal Engine 5’s global illumination and reflection rendering subsystem. Based on the callsites, it’s specifically used in the LumenReflectionTracing module.

The value of this variable is set through the console variable system, as indicated by the FAutoConsoleVariableRef declaration. It can be changed at runtime or set in configuration files.

The associated variable GLumenReflectionsDistantScreenTraces directly interacts with r.Lumen.Reflections.DistantScreenTraces. They share the same value, with GLumenReflectionsDistantScreenTraces being the C++ variable used in the code logic.

Developers should be aware that:

  1. This variable is marked with ECVF_Scalability, meaning it can affect performance and visual quality.
  2. It’s also marked as ECVF_RenderThreadSafe, indicating it’s safe to modify on the render thread.

Best practices when using this variable include:

  1. Consider the performance impact when enabling distant screen traces, especially on lower-end hardware.
  2. Use in conjunction with other Lumen reflection settings for optimal results.
  3. Test thoroughly in various scenarios to ensure the desired visual quality and performance balance.

Regarding the associated variable GLumenReflectionsDistantScreenTraces:

Its purpose is to store the actual value used in the C++ code logic for controlling distant screen traces in Lumen reflections.

It’s used in the Lumen reflection tracing system, specifically in the TraceReflections function of the LumenReflectionTracing module.

The value is set by the console variable system and can be modified at runtime.

It interacts directly with the r.Lumen.Reflections.DistantScreenTraces console variable and is used in conjunction with other Lumen reflection settings.

Developers should be aware that this variable’s value determines whether distant screen traces are performed, which can impact both visual quality and performance.

Best practices include:

  1. Use this variable in combination with other Lumen reflection settings for fine-tuning.
  2. Monitor its impact on performance, especially in scenes with many distant reflections.
  3. Consider exposing this setting to end-users for performance optimization if appropriate for your project.

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

Scope: file

Source code excerpt:

int32 GLumenReflectionsDistantScreenTraces = 1;
FAutoConsoleVariableRef CVarLumenReflectionsDistantScreenTraces(
	TEXT("r.Lumen.Reflections.DistantScreenTraces"),
	GLumenReflectionsDistantScreenTraces,
	TEXT("Whether to do a linear screen trace starting where Lumen Scene ends to handle distant reflections."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

float GLumenReflectionDistantScreenTraceSlopeCompareTolerance = 2.0f;

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

int32 GLumenReflectionsDistantScreenTraces = 1;
FAutoConsoleVariableRef CVarLumenReflectionsDistantScreenTraces(
	TEXT("r.Lumen.Reflections.DistantScreenTraces"),
	GLumenReflectionsDistantScreenTraces,
	TEXT("Whether to do a linear screen trace starting where Lumen Scene ends to handle distant reflections."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

float GLumenReflectionDistantScreenTraceSlopeCompareTolerance = 2.0f;
FAutoConsoleVariableRef GVarLumenReflectionDistantScreenTraceDepthThreshold(

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

Scope (from outer to inner):

file
function     void TraceReflections

Source code excerpt:

	const bool bScreenTraces = GLumenReflectionScreenTraces != 0 && View.Family->EngineShowFlags.LumenScreenTraces && View.FinalPostProcessSettings.LumenReflectionsScreenTraces;
	const bool bSampleSceneColorAtHit = (GLumenReflectionsSampleSceneColorAtHit != 0 && bScreenTraces) || GLumenReflectionsSampleSceneColorAtHit == 2;
	const bool bDistantScreenTraces = GLumenReflectionsDistantScreenTraces && bScreenTraces;

	if (bScreenTraces)
	{
		FReflectionTraceScreenTexturesCS::FParameters* PassParameters = GraphBuilder.AllocParameters<FReflectionTraceScreenTexturesCS::FParameters>();

		PassParameters->HZBScreenTraceParameters = SetupHZBScreenTraceParameters(GraphBuilder, View, SceneTextures);