r.HeterogeneousVolumes.MaxShadowTraceDistance

r.HeterogeneousVolumes.MaxShadowTraceDistance

#Overview

name: r.HeterogeneousVolumes.MaxShadowTraceDistance

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.MaxShadowTraceDistance is to set the maximum distance for shadow tracing in heterogeneous volumes within the Unreal Engine 5 rendering system. This setting is crucial for controlling the extent of shadow calculations in complex volumetric environments.

The Unreal Engine subsystem that relies on this setting variable is the Renderer module, specifically the HeterogeneousVolumes component. This can be seen from the file path where the variable is defined: Engine/Source/Runtime/Renderer/Private/HeterogeneousVolumes/HeterogeneousVolumes.cpp.

The value of this variable is set as a console variable using TAutoConsoleVariable. It has a default value of 30000.0 units, which can be changed at runtime through console commands or programmatically.

The associated variable CVarHeterogeneousVolumesMaxShadowTraceDistance directly interacts with r.HeterogeneousVolumes.MaxShadowTraceDistance. This C++ variable is used to access and modify the console variable’s value within the engine’s code.

Developers must be aware that this variable affects rendering performance and visual quality. A higher value will allow for longer shadow traces, potentially improving shadow quality at the cost of performance. Conversely, a lower value may improve performance but could result in shorter, less accurate shadows.

Best practices when using this variable include:

  1. Adjusting it based on the scale and requirements of your specific scene.
  2. Testing different values to find the optimal balance between visual quality and performance.
  3. Consider dynamic adjustment based on performance metrics or distance from the camera.

Regarding the associated variable CVarHeterogeneousVolumesMaxShadowTraceDistance:

The purpose of CVarHeterogeneousVolumesMaxShadowTraceDistance is to provide a programmatic interface to the r.HeterogeneousVolumes.MaxShadowTraceDistance console variable within the C++ code.

This variable is used within the Renderer module, specifically in the HeterogeneousVolumes namespace. It’s accessed through the GetMaxShadowTraceDistance() function, which retrieves the current value of the console variable on the render thread.

The value of this variable is set indirectly through the console variable r.HeterogeneousVolumes.MaxShadowTraceDistance. It doesn’t have any other variables directly interacting with it beyond its connection to the console variable.

Developers should be aware that this variable is thread-safe for render thread access, as indicated by the ECVF_RenderThreadSafe flag used in its declaration.

Best practices for using CVarHeterogeneousVolumesMaxShadowTraceDistance include:

  1. Always access its value using the GetValueOnRenderThread() method when in render thread code.
  2. Avoid frequent changes to this value, as it may impact rendering consistency.
  3. Consider caching the value if it’s accessed frequently in performance-critical sections of code.

#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:93

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarHeterogeneousVolumesMaxShadowTraceDistance(
	TEXT("r.HeterogeneousVolumes.MaxShadowTraceDistance"),
	30000.0,
	TEXT("The maximum shadow-trace distance (Default = 30000)"),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarHeterogeneousVolumesPreshading(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<float> CVarHeterogeneousVolumesMaxShadowTraceDistance(
	TEXT("r.HeterogeneousVolumes.MaxShadowTraceDistance"),
	30000.0,
	TEXT("The maximum shadow-trace distance (Default = 30000)"),
	ECVF_RenderThreadSafe
);

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

Scope (from outer to inner):

file
namespace    HeterogeneousVolumes
function     float GetMaxShadowTraceDistance

Source code excerpt:

	float GetMaxShadowTraceDistance()
	{
		return CVarHeterogeneousVolumesMaxShadowTraceDistance.GetValueOnRenderThread();
	}

	float GetStepSize()
	{
		return CVarHeterogeneousVolumesStepSize.GetValueOnRenderThread();
	}