r.LumenScene.Radiosity.HardwareRayTracing.SlopeSurfaceBias

r.LumenScene.Radiosity.HardwareRayTracing.SlopeSurfaceBias

#Overview

name: r.LumenScene.Radiosity.HardwareRayTracing.SlopeSurfaceBias

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.LumenScene.Radiosity.HardwareRayTracing.SlopeSurfaceBias is to control the surface slope bias for hardware ray tracing in Lumen’s radiosity calculations. This setting is part of Unreal Engine 5’s Lumen global illumination system, specifically for the radiosity component when using hardware ray tracing.

This setting variable is primarily used in the Lumen rendering subsystem, which is part of Unreal Engine 5’s advanced lighting and global illumination features. It’s specifically utilized in the radiosity calculations when hardware ray tracing is enabled.

The value of this variable is set through the Unreal Engine console variable system. It’s defined as a float with a default value of 0.2f, and it can be modified at runtime.

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

Developers must be aware that this variable affects the precision and performance of radiosity calculations in hardware ray tracing scenarios. Adjusting this value can impact the visual quality and performance of the global illumination system.

Best practices when using this variable include:

  1. Only modify it if you’re experiencing specific issues with radiosity calculations or visual artifacts.
  2. Test thoroughly after making changes, as it can affect both visual quality and performance.
  3. Keep the value within a reasonable range; the code clamps it between 0.0f and 1000.0f.

Regarding the associated variable GLumenRadiosityHardwareRayTracingSurfaceSlopeBias:

This is the actual C++ variable used in the rendering code. It’s initialized with the same value as the console variable and is used directly in the radiosity calculations.

The variable is used in setting up pass parameters for the radiosity hardware ray tracing render graph, specifically for the SurfaceBias parameter. It’s clamped to ensure it stays within a valid range.

Developers should be aware that this variable is used in performance-critical rendering code, so any changes to its value can have direct impacts on rendering performance and quality. It’s also used in conjunction with other parameters like HeightfieldSurfaceBias and MinTraceDistance, so changes might need to be balanced with adjustments to these other parameters for optimal results.

Best practices for this variable are similar to those for the console variable, with an additional note that any direct modifications to this variable in code should be done carefully and with consideration for the entire rendering pipeline.

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

Scope: file

Source code excerpt:

float GLumenRadiosityHardwareRayTracingSurfaceSlopeBias = 0.2f;
FAutoConsoleVariableRef CVarLumenRadiosityHardwareRayTracingSlopeSurfaceBias(
	TEXT("r.LumenScene.Radiosity.HardwareRayTracing.SlopeSurfaceBias"),
	GLumenRadiosityHardwareRayTracingSurfaceSlopeBias,
	TEXT("."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarLumenRadiosityHardwareRayTracing(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

float GLumenRadiosityHardwareRayTracingSurfaceSlopeBias = 0.2f;
FAutoConsoleVariableRef CVarLumenRadiosityHardwareRayTracingSlopeSurfaceBias(
	TEXT("r.LumenScene.Radiosity.HardwareRayTracing.SlopeSurfaceBias"),
	GLumenRadiosityHardwareRayTracingSurfaceSlopeBias,
	TEXT("."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarLumenRadiosityHardwareRayTracing(
	TEXT("r.LumenScene.Radiosity.HardwareRayTracing"),

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

Scope: file

Source code excerpt:

		const uint32 NumThreadsToDispatch = GRHIPersistentThreadGroupCount * FLumenRadiosityHardwareRayTracingRGS::GetGroupSize();
		PassParameters->NumThreadsToDispatch = NumThreadsToDispatch;
		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();