r.Lumen.TranslucencyVolume.EndDistanceFromCamera

r.Lumen.TranslucencyVolume.EndDistanceFromCamera

#Overview

name: r.Lumen.TranslucencyVolume.EndDistanceFromCamera

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.TranslucencyVolume.EndDistanceFromCamera is to control the maximum distance from the camera at which the translucency volume lighting system in Lumen will operate. This setting is part of Unreal Engine 5’s Lumen global illumination system, specifically targeting the rendering of translucent objects.

This setting variable is primarily used in the Lumen subsystem of Unreal Engine’s rendering module. It’s referenced in the LumenTranslucencyVolumeLighting.cpp file, which is part of the Renderer source code.

The value of this variable is set through the Unreal Engine console variable system. It’s initialized with a default value of 8000 units and can be modified at runtime using console commands or through project settings.

This variable interacts directly with its associated C++ variable GTranslucencyGridEndDistanceFromCamera. They share the same value, with the console variable acting as an interface for runtime modification.

Developers should be aware that this variable affects the distance at which translucent objects receive global illumination from Lumen. Setting this value too low might result in popping or sudden changes in lighting for distant translucent objects, while setting it too high might impact performance.

Best practices when using this variable include:

  1. Adjusting it based on the scale and needs of your specific scene.
  2. Balancing it with performance considerations, as larger values may increase computational cost.
  3. Testing different values to find the optimal balance between visual quality and performance for your project.

Regarding the associated variable GTranslucencyGridEndDistanceFromCamera:

The purpose of GTranslucencyGridEndDistanceFromCamera is to store the actual value used by the engine for the translucency volume end distance. It’s the C++ representation of the console variable.

This variable is used directly in the LumenTranslucencyVolume namespace, specifically in the GetEndDistanceFromCamera function. It’s multiplied by a view distance scale factor and clamped to ensure it stays within reasonable bounds.

The value of this variable is set by the console variable system when r.Lumen.TranslucencyVolume.EndDistanceFromCamera is modified.

Developers should be aware that this variable is used in calculations that determine the extent of the translucency lighting volume. Changes to this value will directly affect how far from the camera translucent objects receive Lumen global illumination.

Best practices for this variable include:

  1. Avoid modifying it directly in code; instead, use the console variable for consistency.
  2. Consider the impact on performance when increasing this value, as it affects the size of the volume being processed.
  3. Be aware of its interaction with the view distance scale when debugging lighting issues for distant translucent objects.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenTranslucencyVolumeLighting.cpp:68

Scope: file

Source code excerpt:

float GTranslucencyGridEndDistanceFromCamera = 8000;
FAutoConsoleVariableRef CVarTranslucencyGridEndDistanceFromCamera(
	TEXT("r.Lumen.TranslucencyVolume.EndDistanceFromCamera"),
	GTranslucencyGridEndDistanceFromCamera,
	TEXT(""),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

int32 GTranslucencyVolumeSpatialFilter = 1;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenTranslucencyVolumeLighting.cpp:66

Scope: file

Source code excerpt:

);

float GTranslucencyGridEndDistanceFromCamera = 8000;
FAutoConsoleVariableRef CVarTranslucencyGridEndDistanceFromCamera(
	TEXT("r.Lumen.TranslucencyVolume.EndDistanceFromCamera"),
	GTranslucencyGridEndDistanceFromCamera,
	TEXT(""),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

int32 GTranslucencyVolumeSpatialFilter = 1;
FAutoConsoleVariableRef CVarTranslucencyVolumeSpatialFilter(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenTranslucencyVolumeLighting.cpp:257

Scope (from outer to inner):

file
namespace    LumenTranslucencyVolume
function     float GetEndDistanceFromCamera

Source code excerpt:

		//		so there isn't much point covering beyond that.  
		const float ViewDistanceScale = FMath::Clamp(View.FinalPostProcessSettings.LumenSceneViewDistance / 20000.0f, .1f, 100.0f);
		return FMath::Clamp<float>(GTranslucencyGridEndDistanceFromCamera * ViewDistanceScale, 1.0f, 100000.0f);
	}
}

namespace LumenTranslucencyVolumeRadianceCache
{
	int32 GetNumClipmaps(float DistanceToCover)