r.LumenScene.GlobalSDF.NotCoveredMinStepScale

r.LumenScene.GlobalSDF.NotCoveredMinStepScale

#Overview

name: r.LumenScene.GlobalSDF.NotCoveredMinStepScale

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.GlobalSDF.NotCoveredMinStepScale is to scale the minimum step size in regions of space that only contain Two Sided Mesh SDFs, which is used to improve performance in the Lumen global illumination system.

This setting variable is primarily used in the rendering system, specifically within the Global Distance Field functionality of Unreal Engine 5’s Lumen lighting system. It is part of the Renderer module, as evidenced by its location in the GlobalDistanceField.cpp file.

The value of this variable is set using an FAutoConsoleVariableRef, which allows it to be modified at runtime through the console or configuration files. Its default value is 4.0f.

This variable interacts closely with other Global Distance Field parameters, such as GLumenSceneGlobalSDFCoveredExpandSurfaceScale and GLumenSceneGlobalSDFNotCoveredExpandSurfaceScale. It is used in conjunction with these variables to control the behavior of the Global Distance Field calculations.

Developers should be aware that this variable affects performance and potentially visual quality in scenes where Two Sided Mesh SDFs are prevalent. Adjusting this value can help balance between performance and accuracy in these scenarios.

Best practices when using this variable include:

  1. Testing different values to find the optimal balance between performance and visual quality for your specific scene.
  2. Considering the impact on different hardware configurations, as the optimal value may vary depending on the target platform.
  3. Using it in conjunction with other Global Distance Field settings for fine-tuning the Lumen lighting system.

Regarding the associated variable GLumenSceneGlobalSDFNotCoveredMinStepScale:

This is the actual float variable that stores the value set by the console variable. It is used directly in the engine code to apply the scaling factor. The purpose and usage are the same as described for r.LumenScene.GlobalSDF.NotCoveredMinStepScale.

This variable is used in the SetupGlobalDistanceFieldParameters and SetupGlobalDistanceFieldUniformBufferParameters functions to populate shader parameters and view uniform shader parameters, respectively. This ensures that the scaling factor is properly applied in the rendering pipeline where Global Distance Field calculations are performed.

Developers should note that modifying GLumenSceneGlobalSDFNotCoveredMinStepScale directly in code is not recommended. Instead, they should use the console variable r.LumenScene.GlobalSDF.NotCoveredMinStepScale to change its value, which ensures proper synchronization and allows for runtime adjustments.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/GlobalDistanceField.cpp:238

Scope: file

Source code excerpt:

float GLumenSceneGlobalSDFNotCoveredMinStepScale = 4.0f;
FAutoConsoleVariableRef CVarLumenScenGlobalSDFNotCoveredMinStepScale(
	TEXT("r.LumenScene.GlobalSDF.NotCoveredMinStepScale"),
	GLumenSceneGlobalSDFNotCoveredMinStepScale,
	TEXT("Scales the min step size to improve performance, for regions of space that only contain Two Sided Mesh SDFs."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

float GLumenSceneGlobalSDFDitheredTransparencyStepThreshold = .5f;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/GlobalDistanceField.cpp:236

Scope: file

Source code excerpt:

	ECVF_Scalability | ECVF_RenderThreadSafe);

float GLumenSceneGlobalSDFNotCoveredMinStepScale = 4.0f;
FAutoConsoleVariableRef CVarLumenScenGlobalSDFNotCoveredMinStepScale(
	TEXT("r.LumenScene.GlobalSDF.NotCoveredMinStepScale"),
	GLumenSceneGlobalSDFNotCoveredMinStepScale,
	TEXT("Scales the min step size to improve performance, for regions of space that only contain Two Sided Mesh SDFs."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

float GLumenSceneGlobalSDFDitheredTransparencyStepThreshold = .5f;
FAutoConsoleVariableRef CVarLumenSceneGlobalSDFDitheredTransparencyStepThreshold(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/GlobalDistanceField.cpp:333

Scope (from outer to inner):

file
function     FGlobalDistanceFieldParameters2 SetupGlobalDistanceFieldParameters

Source code excerpt:

	ShaderParameters.CoveredExpandSurfaceScale = GLumenSceneGlobalSDFCoveredExpandSurfaceScale;
	ShaderParameters.NotCoveredExpandSurfaceScale = GLumenSceneGlobalSDFNotCoveredExpandSurfaceScale;
	ShaderParameters.NotCoveredMinStepScale = GLumenSceneGlobalSDFNotCoveredMinStepScale;
	ShaderParameters.DitheredTransparencyStepThreshold = GLumenSceneGlobalSDFDitheredTransparencyStepThreshold;
	ShaderParameters.DitheredTransparencyTraceThreshold = GLumenSceneGlobalSDFDitheredTransparencyTraceThreshold;
	ShaderParameters.GlobalDistanceFieldCoverageAtlasTextureSampler = TStaticSamplerState<SF_Trilinear, AM_Wrap, AM_Wrap, AM_Wrap>::GetRHI();
	ShaderParameters.GlobalDistanceFieldPageAtlasTextureSampler = TStaticSamplerState<SF_Trilinear, AM_Wrap, AM_Wrap, AM_Wrap>::GetRHI();
	ShaderParameters.GlobalDistanceFieldMipTextureSampler = TStaticSamplerState<SF_Trilinear, AM_Clamp, AM_Clamp, AM_Clamp>::GetRHI();

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/GlobalDistanceField.cpp:1361

Scope (from outer to inner):

file
function     void FViewInfo::SetupGlobalDistanceFieldUniformBufferParameters

Source code excerpt:

	ViewUniformShaderParameters.CoveredExpandSurfaceScale = GLumenSceneGlobalSDFCoveredExpandSurfaceScale;
	ViewUniformShaderParameters.NotCoveredExpandSurfaceScale = GLumenSceneGlobalSDFNotCoveredExpandSurfaceScale;
	ViewUniformShaderParameters.NotCoveredMinStepScale = GLumenSceneGlobalSDFNotCoveredMinStepScale;
	ViewUniformShaderParameters.DitheredTransparencyStepThreshold = GLumenSceneGlobalSDFDitheredTransparencyStepThreshold;
	ViewUniformShaderParameters.DitheredTransparencyTraceThreshold = GLumenSceneGlobalSDFDitheredTransparencyTraceThreshold;
}

void ReadbackDistanceFieldClipmap(FRHICommandListImmediate& RHICmdList, FGlobalDistanceFieldInfo& GlobalDistanceFieldInfo)
{