r.Lumen.ScreenProbeGather.ShortRangeAO.ScreenSpace.SlopeCompareToleranceScale

r.Lumen.ScreenProbeGather.ShortRangeAO.ScreenSpace.SlopeCompareToleranceScale

#Overview

name: r.Lumen.ScreenProbeGather.ShortRangeAO.ScreenSpace.SlopeCompareToleranceScale

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.ScreenProbeGather.ShortRangeAO.ScreenSpace.SlopeCompareToleranceScale is to scale the slope threshold used in screen space traces to determine whether there was a hit in the Lumen rendering system. This setting is specifically related to the Short Range Ambient Occlusion (AO) feature in Lumen’s Screen Probe Gather process.

This setting variable is primarily used in the Lumen subsystem of Unreal Engine’s rendering module. Based on the callsites, it’s clear that this variable is utilized in the screen space bent normal calculations, which are part of the Lumen global illumination system.

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

The associated variable GLumenShortRangeAOSlopeCompareToleranceScale directly interacts with this setting. They share the same value, with GLumenShortRangeAOSlopeCompareToleranceScale being the C++ variable that stores the actual value used in the rendering calculations.

Developers must be aware that this variable affects the accuracy and performance of the short-range ambient occlusion calculations in screen space. A higher value will make the system more lenient in determining hits, potentially improving performance but possibly reducing accuracy. A lower value will make the system more strict, potentially improving accuracy but at the cost of performance.

Best practices when using this variable include:

  1. Carefully balancing between performance and visual quality.
  2. Testing different values in various scenes to find the optimal setting for your specific use case.
  3. Considering the impact on different hardware configurations, as this setting can affect performance.
  4. Using this in conjunction with other Lumen settings for best results.

Regarding the associated variable GLumenShortRangeAOSlopeCompareToleranceScale:

The purpose of GLumenShortRangeAOSlopeCompareToleranceScale is to store the actual value used in the rendering calculations for the slope comparison tolerance in Lumen’s short-range ambient occlusion.

This variable is used directly in the Lumen rendering code, specifically in the screen space bent normal calculations. It’s accessed in the ComputeScreenSpaceShortRangeAO function, which is part of the Lumen screen space bent normal computation process.

The value of this variable is set by the console variable system, mirroring the value of r.Lumen.ScreenProbeGather.ShortRangeAO.ScreenSpace.SlopeCompareToleranceScale.

This variable directly interacts with the PassParameters->SlopeCompareToleranceScale in the shader pass setup, influencing how the short-range AO is calculated in screen space.

Developers should be aware that modifying this variable will have a direct impact on the rendering calculations. It’s important to understand the implications of changing this value on both visual quality and performance.

Best practices for using this variable include:

  1. Avoiding direct modification of this variable in code, instead use the console variable for configuration.
  2. Monitoring its impact on performance and visual quality when adjusting the corresponding console variable.
  3. Considering its interaction with other Lumen settings 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/LumenScreenSpaceBentNormal.cpp:14

Scope: file

Source code excerpt:

float GLumenShortRangeAOSlopeCompareToleranceScale = .5f;
FAutoConsoleVariableRef CVarLumenShortRangeAOSlopeCompareToleranceScale(
	TEXT("r.Lumen.ScreenProbeGather.ShortRangeAO.ScreenSpace.SlopeCompareToleranceScale"),
	GLumenShortRangeAOSlopeCompareToleranceScale,
	TEXT("Scales the slope threshold that screen space traces use to determine whether there was a hit."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

float GLumenShortRangeAOFoliageOcclusionStrength = .7f;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenScreenSpaceBentNormal.cpp:12

Scope: file

Source code excerpt:

#include "PixelShaderUtils.h"

float GLumenShortRangeAOSlopeCompareToleranceScale = .5f;
FAutoConsoleVariableRef CVarLumenShortRangeAOSlopeCompareToleranceScale(
	TEXT("r.Lumen.ScreenProbeGather.ShortRangeAO.ScreenSpace.SlopeCompareToleranceScale"),
	GLumenShortRangeAOSlopeCompareToleranceScale,
	TEXT("Scales the slope threshold that screen space traces use to determine whether there was a hit."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

float GLumenShortRangeAOFoliageOcclusionStrength = .7f;
FAutoConsoleVariableRef CVarLumenShortRangeAOFoliageOcclusionStrength(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenScreenSpaceBentNormal.cpp:190

Scope (from outer to inner):

file
function     FLumenScreenSpaceBentNormalParameters ComputeScreenSpaceShortRangeAO
lambda-function

Source code excerpt:

			PassParameters->FurthestHZBTexture = View.HZB;
			PassParameters->FurthestHZBTextureSampler = TStaticSamplerState<SF_Point>::GetRHI();
			PassParameters->SlopeCompareToleranceScale = GLumenShortRangeAOSlopeCompareToleranceScale;

			if (bNeedTraceHairScreen)
			{
				PassParameters->HairStrands = HairStrands::BindHairStrandsViewUniformParameters(View);
			}