r.Lumen.Reflections.SampleSceneColorNormalTreshold

r.Lumen.Reflections.SampleSceneColorNormalTreshold

#Overview

name: r.Lumen.Reflections.SampleSceneColorNormalTreshold

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.SampleSceneColorNormalTreshold is to control the threshold for sampling scene color in Lumen reflections based on the angle between the ray hit normal and the screen normal. This setting is part of Unreal Engine 5’s Lumen global illumination system, specifically for the reflection component.

This setting variable is primarily used in the Lumen reflection tracing subsystem of Unreal Engine 5’s rendering module. Based on the callsites, it’s implemented in the LumenReflectionTracing.cpp file, which is part of the Renderer module.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 85.0 degrees but can be changed at runtime or through configuration files.

The associated variable CVarLumenReflectionsSampleSceneColorNormalTreshold interacts directly with r.Lumen.Reflections.SampleSceneColorNormalTreshold. They share the same value and purpose.

Developers must be aware that this variable affects the quality and performance of Lumen reflections. A lower value (closer to 0) will result in more accurate but potentially noisier reflections, while a higher value (closer to 180) will allow for smoother but potentially less accurate reflections.

Best practices when using this variable include:

  1. Adjusting it based on the specific needs of your scene. Scenes with many complex reflective surfaces might benefit from a lower value for accuracy.
  2. Balancing it with other Lumen settings for optimal performance and visual quality.
  3. Testing different values to find the sweet spot between reflection accuracy and performance for your specific use case.

Regarding the associated variable CVarLumenReflectionsSampleSceneColorNormalTreshold:

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarLumenReflectionsSampleSceneColorNormalTreshold(
	TEXT("r.Lumen.Reflections.SampleSceneColorNormalTreshold"),
	85.0f,
	TEXT("Normal threshold in degrees that controls how close ray hit normal and screen normal have to be, before sampling SceneColor is allowed. 0 - only exactly matching normals allowed. 180 - all normals allowed."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarLumenReflectionsMaxBounces(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<float> CVarLumenReflectionsSampleSceneColorNormalTreshold(
	TEXT("r.Lumen.Reflections.SampleSceneColorNormalTreshold"),
	85.0f,
	TEXT("Normal threshold in degrees that controls how close ray hit normal and screen normal have to be, before sampling SceneColor is allowed. 0 - only exactly matching normals allowed. 180 - all normals allowed."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

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

Scope (from outer to inner):

file
function     float LumenReflections::GetSampleSceneColorNormalTreshold

Source code excerpt:

float LumenReflections::GetSampleSceneColorNormalTreshold()
{
	const float Radians = FMath::DegreesToRadians(FMath::Clamp(CVarLumenReflectionsSampleSceneColorNormalTreshold.GetValueOnRenderThread(), 0.0f, 180.0f));
	return FMath::Cos(Radians);
}

uint32 LumenReflections::GetMaxReflectionBounces(const FViewInfo& View)
{
	int32 MaxBounces = CVarLumenReflectionsMaxBounces.GetValueOnRenderThread();