r.Lumen.Reflections.ScreenSpaceReconstruction.NumSamples

r.Lumen.Reflections.ScreenSpaceReconstruction.NumSamples

#Overview

name: r.Lumen.Reflections.ScreenSpaceReconstruction.NumSamples

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.NumSamples is to control the number of samples used for screen space BRDF reweighting reconstruction in Lumen’s reflection system. This setting 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 rendering module in Unreal Engine 5. The code referencing this variable is located in the LumenReflections.cpp file, which is responsible for rendering reflections using the Lumen system.

The value of this variable is set through the console variable system (CVarLumenReflectionScreenSpaceReconstructionNumSamples). It’s initialized with a default value of 5 but can be changed at runtime.

This variable interacts with the View.FinalPostProcessSettings.LumenReflectionQuality setting. The actual number of reconstruction samples used is calculated by multiplying these two values and clamping the result between the base value and 64.

Developers should be aware that increasing this value will improve the quality of reflections but at the cost of performance. It’s particularly important when fine-tuning the balance between visual quality and performance in scenes with many reflective surfaces.

Best practices for using this variable include:

  1. Start with the default value and adjust based on specific scene requirements.
  2. Consider the target hardware when setting this value, as higher values may impact performance on less powerful devices.
  3. Use in conjunction with other Lumen reflection settings for optimal results.

Regarding the associated variable GLumenReflectionScreenSpaceReconstructionNumSamples:

This is an internal integer variable that directly stores the value set by the console variable. It’s used in the actual rendering code to determine the number of samples for reconstruction. The purpose and usage considerations are the same as for the console variable. Developers working directly with the engine source code might interact with this variable, but for most use cases, adjusting the console variable is sufficient.

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

Scope: file

Source code excerpt:

int32 GLumenReflectionScreenSpaceReconstructionNumSamples = 5;
FAutoConsoleVariableRef CVarLumenReflectionScreenSpaceReconstructionNumSamples(
	TEXT("r.Lumen.Reflections.ScreenSpaceReconstruction.NumSamples"),
	GLumenReflectionScreenSpaceReconstructionNumSamples,
	TEXT("Number of samples to use for the screen space BRDF reweighting reconstruction"),
	ECVF_RenderThreadSafe
	);

float GLumenReflectionScreenSpaceReconstructionKernelRadius = 8.0;

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	);

int32 GLumenReflectionScreenSpaceReconstructionNumSamples = 5;
FAutoConsoleVariableRef CVarLumenReflectionScreenSpaceReconstructionNumSamples(
	TEXT("r.Lumen.Reflections.ScreenSpaceReconstruction.NumSamples"),
	GLumenReflectionScreenSpaceReconstructionNumSamples,
	TEXT("Number of samples to use for the screen space BRDF reweighting reconstruction"),
	ECVF_RenderThreadSafe
	);

float GLumenReflectionScreenSpaceReconstructionKernelRadius = 8.0;
FAutoConsoleVariableRef CVarLumenReflectionScreenSpaceReconstructionKernelScreenWidth(

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

Scope (from outer to inner):

file
function     FRDGTextureRef FDeferredShadingSceneRenderer::RenderLumenReflections

Source code excerpt:

	FRDGTextureRef ResolveVariance = GraphBuilder.CreateTexture(ResolveVarianceDesc, TEXT("Lumen.Reflections.ResolveVariance"));

	const int32 NumReconstructionSamples = FMath::Clamp(FMath::RoundToInt(View.FinalPostProcessSettings.LumenReflectionQuality * GLumenReflectionScreenSpaceReconstructionNumSamples), GLumenReflectionScreenSpaceReconstructionNumSamples, 64);
	const bool bUseSpatialReconstruction = bDenoise && GLumenReflectionScreenSpaceReconstruction != 0;
	const bool bUseBilaterialFilter = bDenoise && GLumenReflectionBilateralFilter != 0;

	{
		FReflectionResolveCS::FParameters* PassParameters = GraphBuilder.AllocParameters<FReflectionResolveCS::FParameters>();
		PassParameters->RWSpecularIndirect = GraphBuilder.CreateUAV(FRDGTextureUAVDesc(ResolvedSpecularIndirect));