r.Lumen.Reflections.MaxRoughnessToTraceClamp

r.Lumen.Reflections.MaxRoughnessToTraceClamp

#Overview

name: r.Lumen.Reflections.MaxRoughnessToTraceClamp

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.MaxRoughnessToTraceClamp is to control the maximum roughness value for which Lumen traces dedicated reflection rays. It serves as a scalability clamp for the rendering system, specifically for Lumen reflections.

This setting variable is primarily used in the Lumen reflection system, which is part of Unreal Engine’s rendering module. It’s referenced in the LumenReflections.cpp file, indicating its importance in the Lumen reflections subsystem.

The value of this variable is set through a console variable (CVarLumenReflectionMaxRoughnessToTraceClamp) with a default value of 1.0f. It can be modified at runtime through console commands or project settings.

This variable interacts with the View.FinalPostProcessSettings.LumenMaxRoughnessToTraceReflections value. The actual value used in the rendering process is the minimum of these two values, as seen in the SetupCompositeParameters function.

Developers must be aware that this variable affects performance and visual quality. Higher values allow for more detailed reflections on rougher surfaces but may impact performance. Lower values can improve performance but might reduce reflection quality on rougher materials.

Best practices when using this variable include:

  1. Adjusting it based on the target hardware and desired performance/quality balance.
  2. Testing different values to find the optimal setting for your specific project.
  3. Considering using it in conjunction with other Lumen settings for overall reflection quality control.

Regarding the associated variable CVarLumenReflectionMaxRoughnessToTraceClamp:

This is the actual console variable that controls the r.Lumen.Reflections.MaxRoughnessToTraceClamp setting. It’s defined in the same file (LumenReflections.cpp) and serves as the programmatic interface for the setting.

The purpose of this variable is identical to r.Lumen.Reflections.MaxRoughnessToTraceClamp, as they represent the same setting.

This console variable is used directly in the Lumen reflections subsystem of the rendering module. It’s accessed in the SetupCompositeParameters function to determine the final MaxRoughnessToTrace value.

The value is set when the console variable is initialized, but it can be changed at runtime through console commands or programmatically.

Developers should be aware that this variable has the ECVF_Scalability and ECVF_RenderThreadSafe flags, meaning it’s intended for scalability adjustments and is safe to modify on the render thread.

Best practices for using this variable include:

  1. Using it for dynamic adjustment of reflection quality in response to performance metrics.
  2. Considering it as part of a broader scalability strategy for Lumen reflections.
  3. Being cautious when modifying it at runtime, as it can have immediate impacts on rendering performance and quality.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReflections.cpp:74

Scope: file

Source code excerpt:


TAutoConsoleVariable<float> CVarLumenReflectionMaxRoughnessToTraceClamp(
	TEXT("r.Lumen.Reflections.MaxRoughnessToTraceClamp"),
	1.0f,
	TEXT("Scalability clamp for max roughness value for which Lumen still traces dedicated reflection rays. Project and Post Process Volumes settings are clamped to this value. Useful for scalability."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

TAutoConsoleVariable<float> CVarLumenReflectionsMaxRoughnessToTraceForFoliage(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReflections.cpp:73

Scope: file

Source code excerpt:

);

TAutoConsoleVariable<float> CVarLumenReflectionMaxRoughnessToTraceClamp(
	TEXT("r.Lumen.Reflections.MaxRoughnessToTraceClamp"),
	1.0f,
	TEXT("Scalability clamp for max roughness value for which Lumen still traces dedicated reflection rays. Project and Post Process Volumes settings are clamped to this value. Useful for scalability."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReflections.cpp:316

Scope (from outer to inner):

file
function     void LumenReflections::SetupCompositeParameters

Source code excerpt:

void LumenReflections::SetupCompositeParameters(const FViewInfo& View, LumenReflections::FCompositeParameters& OutParameters)
{
	OutParameters.MaxRoughnessToTrace = FMath::Min(View.FinalPostProcessSettings.LumenMaxRoughnessToTraceReflections, CVarLumenReflectionMaxRoughnessToTraceClamp.GetValueOnRenderThread());
	OutParameters.InvRoughnessFadeLength = 1.0f / FMath::Clamp(GLumenReflectionRoughnessFadeLength, 0.001f, 1.0f);
	OutParameters.MaxRoughnessToTraceForFoliage = CVarLumenReflectionsMaxRoughnessToTraceForFoliage.GetValueOnRenderThread();

	if (CVarLumenReflectionMaxRoughnessToTrace.GetValueOnRenderThread() >= 0.0f)
	{
		OutParameters.MaxRoughnessToTrace = CVarLumenReflectionMaxRoughnessToTrace.GetValueOnRenderThread();