r.Lumen.DiffuseIndirect.MeshSDF.AverageCulledCount

r.Lumen.DiffuseIndirect.MeshSDF.AverageCulledCount

#Overview

name: r.Lumen.DiffuseIndirect.MeshSDF.AverageCulledCount

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.DiffuseIndirect.MeshSDF.AverageCulledCount is to control the average number of culled Mesh SDF (Signed Distance Field) objects in Lumen’s diffuse indirect lighting system. This setting is part of Unreal Engine 5’s Lumen global illumination system, specifically for the rendering and culling of mesh SDFs.

This setting variable is primarily used in the Lumen subsystem of Unreal Engine’s rendering module. Based on the callsites, it’s clear that this variable is utilized in the LumenMeshSDFCulling.cpp file, which is responsible for culling mesh SDFs in the Lumen lighting system.

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 adjusted at runtime through console commands or configuration files.

The associated variable GMeshSDFAverageCulledCount directly interacts with this setting. They share the same value, with GMeshSDFAverageCulledCount being the actual integer variable used in the code.

Developers should be aware that this variable affects the performance and quality trade-off in Lumen’s indirect lighting calculations. A higher value may result in more accurate lighting but could impact performance, while a lower value might improve performance at the cost of potential lighting artifacts.

Best practices when using this variable include:

  1. Adjusting it based on the complexity of your scene and the target hardware.
  2. Monitoring performance impacts when changing this value.
  3. Balancing it with other Lumen settings for optimal results.

Regarding the associated variable GMeshSDFAverageCulledCount:

The purpose of GMeshSDFAverageCulledCount is to store the actual value used in the code for the average number of culled Mesh SDF objects. It’s directly linked to the console variable r.Lumen.DiffuseIndirect.MeshSDF.AverageCulledCount.

This variable is used in the Lumen subsystem, specifically in the mesh SDF culling process. It’s utilized to determine the maximum number of culled objects per grid cell in the culling system.

The value of GMeshSDFAverageCulledCount is set by the console variable system when r.Lumen.DiffuseIndirect.MeshSDF.AverageCulledCount is modified.

It interacts directly with the culling system, affecting the size of buffers created for storing culled object indices.

Developers should be aware that changing this value affects memory usage and potentially performance, as it determines the size of certain buffers in the culling system.

Best practices include:

  1. Monitoring memory usage when adjusting this value.
  2. Balancing it with scene complexity and available hardware resources.
  3. Testing different values to find the optimal balance between performance and lighting quality for your specific use case.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenMeshSDFCulling.cpp:17

Scope: file

Source code excerpt:

int32 GMeshSDFAverageCulledCount = 512;
FAutoConsoleVariableRef CVarMeshSDFAverageCulledCount(
	TEXT("r.Lumen.DiffuseIndirect.MeshSDF.AverageCulledCount"),
	GMeshSDFAverageCulledCount,
	TEXT(""),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

float GMeshSDFRadiusThreshold = 30;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenMeshSDFCulling.cpp:15

Scope: file

Source code excerpt:

#include "LumenTracingUtils.h"

int32 GMeshSDFAverageCulledCount = 512;
FAutoConsoleVariableRef CVarMeshSDFAverageCulledCount(
	TEXT("r.Lumen.DiffuseIndirect.MeshSDF.AverageCulledCount"),
	GMeshSDFAverageCulledCount,
	TEXT(""),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

float GMeshSDFRadiusThreshold = 30;
FAutoConsoleVariableRef CVarMeshSDFRadiusThreshold(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenMeshSDFCulling.cpp:370

Scope (from outer to inner):

file
function     void InitObjectCullingContext

Source code excerpt:

{
	Context.NumCullGridCells = NumCullGridCells;
	Context.MaxNumberOfCulledObjects = NumCullGridCells * GMeshSDFAverageCulledCount;

	Context.NumGridCulledMeshSDFObjects = GraphBuilder.CreateBuffer(FRDGBufferDesc::CreateBufferDesc(sizeof(uint32), NumCullGridCells), TEXT("Lumen.NumGridCulledMeshSDFObjects"));
	Context.NumGridCulledHeightfieldObjects = GraphBuilder.CreateBuffer(FRDGBufferDesc::CreateBufferDesc(sizeof(uint32), NumCullGridCells), TEXT("Lumen.NumGridCulledHeightfieldObjects"));

	Context.GridCulledMeshSDFObjectIndicesArray = GraphBuilder.CreateBuffer(FRDGBufferDesc::CreateBufferDesc(sizeof(uint32), Context.MaxNumberOfCulledObjects), TEXT("Lumen.GridCulledMeshSDFObjectIndicesArray"));
	Context.GridCulledHeightfieldObjectIndicesArray = GraphBuilder.CreateBuffer(FRDGBufferDesc::CreateBufferDesc(sizeof(uint32), Context.MaxNumberOfCulledObjects), TEXT("Lumen.GridCulledHeightfieldObjectIndicesArray"));