r.HeterogeneousVolumes.LightingCache.BoundsCulling

r.HeterogeneousVolumes.LightingCache.BoundsCulling

#Overview

name: r.HeterogeneousVolumes.LightingCache.BoundsCulling

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.HeterogeneousVolumes.LightingCache.BoundsCulling is to control bounds culling when populating the lighting cache for heterogeneous volumes in Unreal Engine 5’s rendering system.

This setting variable is primarily used by the Renderer module, specifically within the heterogeneous volumes rendering subsystem. It’s referenced in the HeterogeneousVolumesLiveShadingPipeline.cpp file, which suggests it’s part of the live shading pipeline for heterogeneous volumes.

The value of this variable is set using a console variable (CVar) system. It’s initialized with a default value of 1, meaning bounds culling is enabled by default.

The associated variable CVarHeterogeneousLightingCacheBoundsCulling directly interacts with this setting. It’s defined as a TAutoConsoleVariable, which allows it to be modified at runtime through console commands.

Developers must be aware that this variable affects the performance and accuracy of the lighting cache population for heterogeneous volumes. Enabling bounds culling (default behavior) can improve performance by reducing unnecessary calculations, but may potentially impact the accuracy of lighting in some edge cases.

Best practices when using this variable include:

  1. Keeping it enabled (value 1) for better performance in most scenarios.
  2. Disabling it (value 0) only if you notice lighting artifacts in heterogeneous volumes that may be caused by overly aggressive culling.
  3. Profiling the rendering performance with and without bounds culling to determine the optimal setting for your specific use case.

Regarding the associated variable CVarHeterogeneousLightingCacheBoundsCulling:

When working with this variable, developers should ensure that any changes are made on the render thread to avoid potential race conditions or inconsistent behavior across frames.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/HeterogeneousVolumes/HeterogeneousVolumesLiveShadingPipeline.cpp:18

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarHeterogeneousLightingCacheBoundsCulling(
	TEXT("r.HeterogeneousVolumes.LightingCache.BoundsCulling"),
	1,
	TEXT("Enables bounds culling when populating the lighting cache (Default = 1)"),
	ECVF_RenderThreadSafe
);

namespace HeterogeneousVolumes

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/HeterogeneousVolumes/HeterogeneousVolumesLiveShadingPipeline.cpp:17

Scope: file

Source code excerpt:

#include "BlueNoise.h"

static TAutoConsoleVariable<int32> CVarHeterogeneousLightingCacheBoundsCulling(
	TEXT("r.HeterogeneousVolumes.LightingCache.BoundsCulling"),
	1,
	TEXT("Enables bounds culling when populating the lighting cache (Default = 1)"),
	ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/HeterogeneousVolumes/HeterogeneousVolumesLiveShadingPipeline.cpp:28

Scope (from outer to inner):

file
namespace    HeterogeneousVolumes
function     bool ShouldBoundsCull

Source code excerpt:

	bool ShouldBoundsCull()
	{
		return CVarHeterogeneousLightingCacheBoundsCulling.GetValueOnRenderThread() != 0;
	}
}

//-OPT: Remove duplicate bindings
// At the moment we need to bind the mesh draw parameters as they will be applied and on some RHIs this will crash if the texture is nullptr
// We have the same parameters in the loose FParameters shader structure that are applied after the mesh draw.