r.Lumen.ScreenProbeGather.RadianceCache.NumMipmaps

r.Lumen.ScreenProbeGather.RadianceCache.NumMipmaps

#Overview

name: r.Lumen.ScreenProbeGather.RadianceCache.NumMipmaps

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.Lumen.ScreenProbeGather.RadianceCache.NumMipmaps is to control the number of mipmaps in the radiance cache used by Lumen’s screen probe gather system. This setting is part of Unreal Engine 5’s Lumen global illumination system, specifically the screen-space component.

The Lumen screen probe gather system, which is part of the rendering subsystem, relies on this setting variable. It’s used in the LumenScreenProbeGather module, as evidenced by its location in the LumenScreenProbeGather.cpp file.

The value of this variable is set through the Unreal Engine console variable system. It’s defined as an FAutoConsoleVariableRef, which means it can be changed at runtime through console commands or configuration files.

This variable interacts directly with the associated variable GRadianceCacheNumMipmaps. They share the same value, with GRadianceCacheNumMipmaps being the actual integer variable used in the code, while r.Lumen.ScreenProbeGather.RadianceCache.NumMipmaps is the console variable name used to modify it.

Developers must be aware that changing this variable affects the memory usage and performance of the Lumen screen probe gather system. Increasing the number of mipmaps can potentially improve the quality of the global illumination at the cost of increased memory usage and potentially lower performance.

Best practices when using this variable include:

  1. Carefully balancing quality and performance requirements.
  2. Testing thoroughly after changes, as it can impact both visual quality and performance.
  3. Considering the target hardware capabilities when adjusting this value.

Regarding the associated variable GRadianceCacheNumMipmaps:

The purpose of GRadianceCacheNumMipmaps is to store the actual number of radiance cache mipmaps used in the Lumen screen probe gather system. It’s used directly in the code to determine various aspects of the radiance cache functionality.

This variable is used in several key functions within the LumenScreenProbeGatherRadianceCache namespace, such as GetFinalProbeResolution() and SetupRadianceCacheInputs(). It affects calculations related to probe resolution and the final radiance atlas maximum mip level.

The value of GRadianceCacheNumMipmaps is set through the r.Lumen.ScreenProbeGather.RadianceCache.NumMipmaps console variable, allowing for runtime modification.

Developers should be aware that this variable directly impacts the behavior of the radiance cache in the Lumen system. Changes to this value will affect memory usage, performance, and potentially the visual quality of the global illumination.

Best practices for using GRadianceCacheNumMipmaps include:

  1. Understanding its impact on the radiance cache system before modifying.
  2. Coordinating changes with the r.Lumen.ScreenProbeGather.RadianceCache.NumMipmaps console variable.
  3. Monitoring performance and visual quality when adjusting this value.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenScreenProbeGather.cpp:471

Scope: file

Source code excerpt:

int32 GRadianceCacheNumMipmaps = 1;
FAutoConsoleVariableRef CVarRadianceCacheNumMipmaps(
	TEXT("r.Lumen.ScreenProbeGather.RadianceCache.NumMipmaps"),
	GRadianceCacheNumMipmaps,
	TEXT("Number of radiance cache mipmaps."),
	ECVF_RenderThreadSafe
);

int32 GRadianceCacheProbeAtlasResolutionInProbes = 128;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenScreenProbeGather.cpp:469

Scope: file

Source code excerpt:

);

int32 GRadianceCacheNumMipmaps = 1;
FAutoConsoleVariableRef CVarRadianceCacheNumMipmaps(
	TEXT("r.Lumen.ScreenProbeGather.RadianceCache.NumMipmaps"),
	GRadianceCacheNumMipmaps,
	TEXT("Number of radiance cache mipmaps."),
	ECVF_RenderThreadSafe
);

int32 GRadianceCacheProbeAtlasResolutionInProbes = 128;
FAutoConsoleVariableRef CVarRadianceCacheProbeAtlasResolutionInProbes(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenScreenProbeGather.cpp:521

Scope (from outer to inner):

file
namespace    LumenScreenProbeGatherRadianceCache
function     int32 GetFinalProbeResolution

Source code excerpt:

	int32 GetFinalProbeResolution()
	{
		return GetProbeResolution() + 2 * (1 << (GRadianceCacheNumMipmaps - 1));
	}

	FIntVector GetProbeIndirectionTextureSize()
	{
		return FIntVector(GetClipmapGridResolution() * GRadianceCacheNumClipmaps, GetClipmapGridResolution(), GetClipmapGridResolution());
	}

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenScreenProbeGather.cpp:555

Scope (from outer to inner):

file
namespace    LumenScreenProbeGatherRadianceCache
function     LumenRadianceCache::FRadianceCacheInputs SetupRadianceCacheInputs

Source code excerpt:

		Parameters.RadianceProbeResolution = FMath::Max(GetProbeResolution(), LumenRadianceCache::MinRadianceProbeResolution);
		Parameters.FinalProbeResolution = GetFinalProbeResolution();
		Parameters.FinalRadianceAtlasMaxMip = GRadianceCacheNumMipmaps - 1;
		const float LightingUpdateSpeed = FMath::Clamp(View.FinalPostProcessSettings.LumenFinalGatherLightingUpdateSpeed, .5f, 4.0f);
		const float EditingBudgetScale = View.Family->bCurrentlyBeingEdited ? 10.0f : 1.0f;
		Parameters.NumProbesToTraceBudget = FMath::RoundToInt(GRadianceCacheNumProbesToTraceBudget * LightingUpdateSpeed * EditingBudgetScale);
		Parameters.RadianceCacheStats = GRadianceCacheStats;
		return Parameters;
	}