r.ManyLights.MaxShadingTilesPerGridCell

r.ManyLights.MaxShadingTilesPerGridCell

#Overview

name: r.ManyLights.MaxShadingTilesPerGridCell

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.ManyLights.MaxShadingTilesPerGridCell is to control the maximum number of shading tiles per grid cell in the Many Lights rendering system of Unreal Engine 5.

This setting variable is primarily used in the rendering system, specifically in the Many Lights module. The Many Lights system is a part of Unreal Engine’s deferred shading pipeline, designed to efficiently handle scenes with a large number of light sources.

Based on the Callsites section, this variable is utilized in the Renderer module, specifically in the ManyLights.cpp file. It’s part of the deferred shading scene renderer, which suggests it’s crucial for the engine’s lighting and rendering pipeline.

The value of this variable is set as a console variable (CVar) with a default value of 32. It can be modified at runtime through the console or configuration files.

The associated variable CVarManyLightsMaxShadingTilesPerGridCell directly interacts with r.ManyLights.MaxShadingTilesPerGridCell. They share the same value and purpose.

Developers must be aware that this variable affects the rendering performance and quality. A higher value may provide more accurate lighting at the cost of performance, while a lower value might improve performance but potentially reduce lighting quality.

Best practices when using this variable include:

  1. Adjusting it based on the specific needs of your scene and target hardware.
  2. Profiling the performance impact when modifying this value.
  3. Considering the trade-off between lighting quality and performance.

Regarding the associated variable CVarManyLightsMaxShadingTilesPerGridCell:

The purpose of CVarManyLightsMaxShadingTilesPerGridCell is identical to r.ManyLights.MaxShadingTilesPerGridCell. It’s an internal representation of the console variable within the engine’s C++ code.

This variable is used in the Renderer module, specifically in the Many Lights system. It’s defined and used in the ManyLights.cpp file.

The value is set when the engine initializes the console variable system. It can be modified at runtime through the console or configuration files.

CVarManyLightsMaxShadingTilesPerGridCell directly interacts with r.ManyLights.MaxShadingTilesPerGridCell, as they represent the same setting.

Developers should be aware that this is the actual variable used in the C++ code to retrieve the current value of the setting. It’s accessed using the GetValueOnRenderThread() method.

Best practices include using this variable consistently throughout the codebase when referencing the maximum shading tiles per grid cell, and ensuring thread-safety when accessing its value, as demonstrated by the use of GetValueOnRenderThread().

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ManyLights/ManyLights.cpp:26

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarManyLightsMaxShadingTilesPerGridCell(
	TEXT("r.ManyLights.MaxShadingTilesPerGridCell"),
	32,
	TEXT("Maximum number of shading tiles per grid cell."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<float> CVarManyLightsSamplingMinWeight(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ManyLights/ManyLights.cpp:25

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarManyLightsMaxShadingTilesPerGridCell(
	TEXT("r.ManyLights.MaxShadingTilesPerGridCell"),
	32,
	TEXT("Maximum number of shading tiles per grid cell."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ManyLights/ManyLights.cpp:669

Scope (from outer to inner):

file
function     void FDeferredShadingSceneRenderer::RenderManyLights

Source code excerpt:

	const int32 MaxCompositeTiles = MaxShadingTiles;

	const int32 MaxShadingTilesPerGridCell = FMath::Max(CVarManyLightsMaxShadingTilesPerGridCell.GetValueOnRenderThread(), 0);

	FRDGTextureRef DownsampledSceneDepth = GraphBuilder.CreateTexture(
		FRDGTextureDesc::Create2D(DownsampledBufferSize, PF_R32_FLOAT, FClearValueBinding::Black, TexCreate_ShaderResource | TexCreate_UAV),
		TEXT("ManyLights.DownsampledSceneDepth"));

	FRDGTextureRef DownsampledSceneWorldNormal = GraphBuilder.CreateTexture(