r.HeterogeneousVolumes.Shadows.Mode

r.HeterogeneousVolumes.Shadows.Mode

#Overview

name: r.HeterogeneousVolumes.Shadows.Mode

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.Shadows.Mode is to control the shadow rendering mode for heterogeneous volumes in Unreal Engine 5’s rendering system. It allows developers to choose between two shadow rendering techniques for heterogeneous volumes: live-shading (default) or preshaded voxel grid.

This setting variable is primarily used by the Renderer module, specifically within the HeterogeneousVolumes subsystem. It’s defined and utilized in the HeterogeneousVolumes.cpp file, which is part of the rendering pipeline for handling heterogeneous volumes.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 0, which corresponds to the live-shading mode. Developers can change this value at runtime using console commands or through code.

The associated variable CVarHeterogeneousVolumesShadowMode directly interacts with r.HeterogeneousVolumes.Shadows.Mode. It’s an instance of TAutoConsoleVariable that provides an interface to get and set the value of the console variable.

Developers must be aware that this variable affects the performance and visual quality of shadow rendering for heterogeneous volumes. The choice between live-shading and preshaded voxel grid can have implications on both rendering speed and shadow quality.

Best practices when using this variable include:

  1. Testing both modes (0 and 1) to determine which provides the best balance of performance and visual quality for your specific use case.
  2. Considering the impact on performance, especially in scenes with complex heterogeneous volumes.
  3. Using the GetShadowMode() function to retrieve the current mode in code, ensuring thread-safe access on the render thread.

Regarding the associated variable CVarHeterogeneousVolumesShadowMode:

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesShadowMode(
	TEXT("r.HeterogeneousVolumes.Shadows.Mode"),
	0,
	TEXT("0: Live-Shading (Default)")
	TEXT("1: Preshaded Voxel Grid"),
	ECVF_RenderThreadSafe
);

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesShadowMode(
	TEXT("r.HeterogeneousVolumes.Shadows.Mode"),
	0,
	TEXT("0: Live-Shading (Default)")
	TEXT("1: Preshaded Voxel Grid"),
	ECVF_RenderThreadSafe
);

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

Scope (from outer to inner):

file
namespace    HeterogeneousVolumes
function     EShadowMode GetShadowMode

Source code excerpt:

	EShadowMode GetShadowMode()
	{
		return static_cast<EShadowMode>(CVarHeterogeneousVolumesShadowMode.GetValueOnRenderThread());
	}

	bool UseSparseVoxelPipeline()
	{
		return CVarHeterogeneousVolumesSparseVoxel.GetValueOnRenderThread() != 0;
	}