r.Lumen.Reflections.ScreenSpaceReconstruction.RoughnessScale

r.Lumen.Reflections.ScreenSpaceReconstruction.RoughnessScale

#Overview

name: r.Lumen.Reflections.ScreenSpaceReconstruction.RoughnessScale

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.ScreenSpaceReconstruction.RoughnessScale is to control the blurring of neighbor traces in Lumen’s screen space reflection reconstruction process. This setting variable is part of Unreal Engine 5’s Lumen global illumination and reflection system.

This setting variable is primarily used in the Lumen Reflections subsystem, which is part of the Renderer module in Unreal Engine 5. Based on the callsites, it’s specifically used in the screen space reconstruction process for reflections.

The value of this variable is set through the console variable system in Unreal Engine. It’s initialized with a default value of 1.0f and can be changed at runtime using console commands or through engine configuration files.

The variable interacts directly with GLumenReflectionScreenSpaceReconstructionRoughnessScale, which is the C++ variable that stores the actual value used in the rendering code.

Developers must be aware that increasing this value above 1.0 allows for more aggressive blurring of neighbor traces, which can improve performance or reduce noise in reflections, but at the cost of physical accuracy. Values below 1.0 would result in less blurring, potentially increasing accuracy but possibly introducing more noise or artifacts.

Best practices when using this variable include:

  1. Keep it at 1.0 for physically accurate results.
  2. Increase it cautiously if you need to reduce noise in reflections or improve performance.
  3. Always test thoroughly after adjusting this value, as it can significantly impact the visual quality of reflections.
  4. Consider the trade-off between visual quality and performance when adjusting this value.

Regarding the associated variable GLumenReflectionScreenSpaceReconstructionRoughnessScale:

This is the actual C++ variable that stores the value set by the console variable r.Lumen.Reflections.ScreenSpaceReconstruction.RoughnessScale. It’s used directly in the rendering code, specifically in the RenderLumenReflections function of the FDeferredShadingSceneRenderer class.

The purpose of this variable is the same as the console variable - to control the roughness scale in the screen space reconstruction process for Lumen reflections. It’s set by the console variable system and used in the actual rendering calculations.

Developers should be aware that this variable is marked as render thread safe (ECVF_RenderThreadSafe), meaning it can be safely changed at runtime without causing threading issues in the rendering system.

When working with this variable in C++ code, developers should access it directly rather than trying to read the console variable value, as the GLumenReflectionScreenSpaceReconstructionRoughnessScale variable will always contain the most up-to-date value.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReflections.cpp:182

Scope: file

Source code excerpt:

float GLumenReflectionScreenSpaceReconstructionRoughnessScale = 1.0f;
FAutoConsoleVariableRef CVarLumenReflectionScreenSpaceReconstructionRoughnessScale(
	TEXT("r.Lumen.Reflections.ScreenSpaceReconstruction.RoughnessScale"),
	GLumenReflectionScreenSpaceReconstructionRoughnessScale,
	TEXT("Values higher than 1 allow neighbor traces to be blurred together more aggressively, but is not physically correct."),
	ECVF_RenderThreadSafe
	);

float GLumenReflectionSpatialResolveTonemapStrength = 0.0f;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReflections.cpp:180

Scope: file

Source code excerpt:

	);

float GLumenReflectionScreenSpaceReconstructionRoughnessScale = 1.0f;
FAutoConsoleVariableRef CVarLumenReflectionScreenSpaceReconstructionRoughnessScale(
	TEXT("r.Lumen.Reflections.ScreenSpaceReconstruction.RoughnessScale"),
	GLumenReflectionScreenSpaceReconstructionRoughnessScale,
	TEXT("Values higher than 1 allow neighbor traces to be blurred together more aggressively, but is not physically correct."),
	ECVF_RenderThreadSafe
	);

float GLumenReflectionSpatialResolveTonemapStrength = 0.0f;
FAutoConsoleVariableRef CVarLumenReflectionSpatialResolveTonemapStrength(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReflections.cpp:1245

Scope (from outer to inner):

file
function     FRDGTextureRef FDeferredShadingSceneRenderer::RenderLumenReflections

Source code excerpt:

		PassParameters->NumSpatialReconstructionSamples = NumReconstructionSamples;
		PassParameters->SpatialReconstructionKernelRadius = GLumenReflectionScreenSpaceReconstructionKernelRadius;
		PassParameters->SpatialReconstructionRoughnessScale = GLumenReflectionScreenSpaceReconstructionRoughnessScale;
		PassParameters->SpatialResolveTonemapStrength = GLumenReflectionSpatialResolveTonemapStrength;
		PassParameters->ReflectionTracingParameters = ReflectionTracingParameters;
		PassParameters->View = View.ViewUniformBuffer;
		PassParameters->SceneTexturesStruct = SceneTextures.UniformBuffer;

		if (FrontLayerReflectionGBuffer)