r.Lumen.DiffuseIndirect.MinSampleRadius

r.Lumen.DiffuseIndirect.MinSampleRadius

#Overview

name: r.Lumen.DiffuseIndirect.MinSampleRadius

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.DiffuseIndirect.MinSampleRadius is to set the minimum sample radius for Lumen’s diffuse indirect lighting calculations. This setting is part of Unreal Engine 5’s Lumen global illumination system, which is a key component of the rendering subsystem.

This setting variable is primarily used in the Lumen module of Unreal Engine’s rendering system. Based on the callsites, it’s clear that this variable is utilized in the LumenDiffuseIndirect.cpp file, which is part of the Renderer module.

The value of this variable is set through the Unreal Engine console variable system. It’s initialized with a default value of 10 and can be modified at runtime using the console command “r.Lumen.DiffuseIndirect.MinSampleRadius”.

The variable interacts directly with GLumenDiffuseMinSampleRadius, which is the C++ variable that stores the actual value. It’s also used in conjunction with other Lumen settings, such as GLumenDiffuseMinTraceDistance and GDiffuseTraceStepFactor, to configure the diffuse indirect lighting calculations.

Developers must be aware that this variable affects the quality and performance of Lumen’s diffuse indirect lighting. A smaller radius may provide more accurate results but at the cost of performance, while a larger radius might improve performance but potentially reduce quality.

Best practices when using this variable include:

  1. Adjusting it in conjunction with other Lumen settings for optimal balance between quality and performance.
  2. Testing different values in various scenes to find the best setting for your specific use case.
  3. Being mindful of its impact on different hardware configurations.

Regarding the associated variable GLumenDiffuseMinSampleRadius:

The purpose of GLumenDiffuseMinSampleRadius is to store the actual value of the minimum sample radius for Lumen’s diffuse indirect lighting calculations in the C++ code.

This variable is used directly in the Lumen module of the rendering system, specifically in the SetupLumenDiffuseTracingParameters function.

The value of GLumenDiffuseMinSampleRadius is set by the console variable system when r.Lumen.DiffuseIndirect.MinSampleRadius is modified.

It interacts with the FLumenIndirectTracingParameters structure, where its value is clamped between 0.01 and 100.0 before being assigned to the MinSampleRadius parameter.

Developers should be aware that this variable is used in performance-critical code and its value is clamped to ensure it stays within a reasonable range.

Best practices for GLumenDiffuseMinSampleRadius include:

  1. Avoid modifying it directly in code; instead, use the console variable system.
  2. Be aware of its clamped range when setting values through the console variable.
  3. Consider its impact on performance and quality when adjusting related Lumen settings.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenDiffuseIndirect.cpp:48

Scope: file

Source code excerpt:

float GLumenDiffuseMinSampleRadius = 10;
FAutoConsoleVariableRef CVarLumenDiffuseMinSampleRadius(
	TEXT("r.Lumen.DiffuseIndirect.MinSampleRadius"),
	GLumenDiffuseMinSampleRadius,
	TEXT("."),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

float GLumenDiffuseMinTraceDistance = 0;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenDiffuseIndirect.cpp:46

Scope: file

Source code excerpt:

	);

float GLumenDiffuseMinSampleRadius = 10;
FAutoConsoleVariableRef CVarLumenDiffuseMinSampleRadius(
	TEXT("r.Lumen.DiffuseIndirect.MinSampleRadius"),
	GLumenDiffuseMinSampleRadius,
	TEXT("."),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

float GLumenDiffuseMinTraceDistance = 0;
FAutoConsoleVariableRef CVarLumenDiffuseMinTraceDistance(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenDiffuseIndirect.cpp:302

Scope (from outer to inner):

file
function     void SetupLumenDiffuseTracingParameters

Source code excerpt:

	OutParameters.StepFactor = FMath::Clamp(GDiffuseTraceStepFactor, .1f, 10.0f);
	
	OutParameters.MinSampleRadius = FMath::Clamp(GLumenDiffuseMinSampleRadius, .01f, 100.0f);
	OutParameters.MinTraceDistance = FMath::Clamp(GLumenDiffuseMinTraceDistance, .01f, 1000.0f);
	OutParameters.MaxTraceDistance = Lumen::GetMaxTraceDistance(View);
	if (!View.IsPerspectiveProjection() && CVarOrthoOverrideMeshDFTraceDistances.GetValueOnAnyThread())
	{
		float TraceSDFDistance = FMath::Clamp(View.ViewMatrices.GetOrthoDimensions().GetMax(), OutParameters.MinTraceDistance, OutParameters.MaxTraceDistance);
		OutParameters.MaxMeshSDFTraceDistance = TraceSDFDistance;