r.LumenScene.Radiosity.MaxRayIntensity

r.LumenScene.Radiosity.MaxRayIntensity

#Overview

name: r.LumenScene.Radiosity.MaxRayIntensity

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.LumenScene.Radiosity.MaxRayIntensity is to control the maximum intensity of rays in Lumen’s radiosity calculations for scene lighting. This setting is part of Unreal Engine 5’s Lumen global illumination system, specifically the radiosity component.

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

The value of this variable is set through the Unreal Engine console variable system. It’s initialized with a default value of 40.0f and can be modified at runtime.

The associated variable GLumenRadiosityMaxRayIntensity directly interacts with this console variable. They share the same value, with GLumenRadiosityMaxRayIntensity being the C++ variable that’s used in the actual rendering code.

Developers should be aware that this variable clamps the radiosity trace intensity relative to the current view exposure. While it’s useful for reducing artifacts from small bright emissive sources, it can also result in energy loss and add view dependence to the lighting calculations.

Best practices when using this variable include:

  1. Carefully adjusting the value to balance artifact reduction and energy preservation.
  2. Testing the impact of changes across various lighting scenarios in the game.
  3. Being mindful of the performance implications, as it’s marked with ECVF_Scalability.

Regarding the associated variable GLumenRadiosityMaxRayIntensity:

The purpose of GLumenRadiosityMaxRayIntensity is to store the actual value used in the radiosity calculations within the C++ code.

This variable is used directly in the Lumen radiosity rendering passes, both for hardware ray tracing and distance field tracing.

Its value is set by the r.LumenScene.Radiosity.MaxRayIntensity console variable.

The variable is used in parameter setting for radiosity passes, where it’s clamped between 0.0f and 1000000.0f for safety.

Developers should be aware that this variable directly affects the intensity of light rays in the radiosity calculations, which can significantly impact the overall lighting quality and performance.

Best practices include:

  1. Monitoring this value during performance profiling of lighting calculations.
  2. Considering its impact when debugging lighting artifacts or inconsistencies.
  3. Understanding that changes to this value may require re-balancing of other lighting parameters for optimal results.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenRadiosity.cpp:89

Scope: file

Source code excerpt:

float GLumenRadiosityMaxRayIntensity = 40.0f;
FAutoConsoleVariableRef CVarLumenRadiosityMaxRayIntensity(
	TEXT("r.LumenScene.Radiosity.MaxRayIntensity"),
	GLumenRadiosityMaxRayIntensity,
	TEXT("Clamps Radiosity trace intensity, relative to current view exposure.  Useful for reducing artifacts from small bright emissive sources, but loses energy and adds view dependence."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

float GLumenRadiosityDistanceFieldSurfaceBias = 10.0f;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenRadiosity.cpp:87

Scope: file

Source code excerpt:

);

float GLumenRadiosityMaxRayIntensity = 40.0f;
FAutoConsoleVariableRef CVarLumenRadiosityMaxRayIntensity(
	TEXT("r.LumenScene.Radiosity.MaxRayIntensity"),
	GLumenRadiosityMaxRayIntensity,
	TEXT("Clamps Radiosity trace intensity, relative to current view exposure.  Useful for reducing artifacts from small bright emissive sources, but loses energy and adds view dependence."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

float GLumenRadiosityDistanceFieldSurfaceBias = 10.0f;
FAutoConsoleVariableRef CVarLumenRadiositySurfaceBias(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenRadiosity.cpp:785

Scope: file

Source code excerpt:

		PassParameters->SurfaceBias = FMath::Clamp(GLumenRadiosityHardwareRayTracingSurfaceSlopeBias, 0.0f, 1000.0f);
		PassParameters->HeightfieldSurfaceBias = Lumen::GetHeightfieldReceiverBias();
		PassParameters->MaxRayIntensity = FMath::Clamp(GLumenRadiosityMaxRayIntensity, 0.0f, 1000000.0f);
		PassParameters->MinTraceDistance = FMath::Clamp(GLumenRadiosityHardwareRayTracingSurfaceBias, 0.0f, 1000.0f);
		PassParameters->MaxTraceDistance = Lumen::GetMaxTraceDistance(View);
		PassParameters->MaxTraversalIterations = LumenHardwareRayTracing::GetMaxTraversalIterations();
		PassParameters->MinTraceDistanceToSampleSurfaceCache = LumenHardwareRayTracing::GetMinTraceDistanceToSampleSurfaceCache();

		FLumenRadiosityHardwareRayTracing::FPermutationDomain PermutationVector;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenRadiosity.cpp:848

Scope: file

Source code excerpt:

			PassParameters->IndirectTracingParameters.MinTraceDistance = FMath::Clamp(GLumenRadiosityDistanceFieldSurfaceBias, 0.0f, 1000.0f);
			PassParameters->IndirectTracingParameters.MaxTraceDistance = Lumen::GetMaxTraceDistance(View);
			PassParameters->MaxRayIntensity = FMath::Clamp(GLumenRadiosityMaxRayIntensity, 0.0f, 1000000.0f);

			FLumenRadiosityDistanceFieldTracingCS::FPermutationDomain PermutationVector;
			PermutationVector.Set<FLumenRadiosityDistanceFieldTracingCS::FThreadGroupSize32>(Lumen::UseThreadGroupSize32());
			PermutationVector.Set<FLumenRadiosityDistanceFieldTracingCS::FTraceGlobalSDF>(Lumen::UseGlobalSDFTracing(*View.Family));
			PermutationVector.Set<FLumenRadiosityDistanceFieldTracingCS::FSimpleCoverageBasedExpand>(Lumen::UseGlobalSDFTracing(*View.Family) && Lumen::UseGlobalSDFSimpleCoverageBasedExpand());
			auto ComputeShader = GlobalShaderMap->GetShader<FLumenRadiosityDistanceFieldTracingCS>(PermutationVector);