r.TranslucencyLightingVolumeOuterDistance

r.TranslucencyLightingVolumeOuterDistance

#Overview

name: r.TranslucencyLightingVolumeOuterDistance

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.TranslucencyLightingVolumeOuterDistance is to control the distance from the camera at which the second volume cascade of the translucency lighting volume should end. This setting is primarily used in the rendering system, specifically for managing translucent lighting effects.

This setting variable is relied upon by the Unreal Engine’s renderer subsystem, particularly in the translucency lighting and Lumen modules. It’s used in the following files:

  1. TranslucentLighting.cpp
  2. LumenTranslucencyVolumeLighting.cpp

The value of this variable is set through a console variable (CVar) system, which allows for runtime modification. It’s initialized with a default value of 5000.0f units.

The associated variable CVarTranslucencyLightingVolumeOuterDistance interacts directly with r.TranslucencyLightingVolumeOuterDistance, as they share the same value. This CVar is used to retrieve the current value of the setting in the render thread.

Developers must be aware that:

  1. This variable affects the range of translucency lighting effects, which can impact both visual quality and performance.
  2. It’s used in conjunction with CVarTranslucencyLightingVolumeInnerDistance to define the bounds of translucency lighting volumes.
  3. The value is used in calculations for Lumen’s translucency volume lighting, affecting the end distance from the camera for certain lighting calculations.

Best practices when using this variable include:

  1. Carefully balancing the value to achieve the desired visual quality without unnecessarily extending the lighting volume and impacting performance.
  2. Consider the relationship between this value and other related settings, such as CVarTranslucencyLightingVolumeInnerDistance and LumenSceneViewDistance.
  3. Use the console variable system to experiment with different values during development and fine-tune the setting for optimal results.

Regarding the associated variable CVarTranslucencyLightingVolumeOuterDistance:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/TranslucentLighting.cpp:109

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarTranslucencyLightingVolumeOuterDistance(
	TEXT("r.TranslucencyLightingVolumeOuterDistance"),
	5000.0f,
	TEXT("Distance from the camera that the second volume cascade should end"),
	ECVF_RenderThreadSafe | ECVF_Scalability);

/** Function returning current translucency lighting volume dimensions. */
int32 GetTranslucencyLightingVolumeDim()

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

Scope (from outer to inner):

file
namespace    LumenTranslucencyVolume
function     float GetEndDistanceFromCamera

Source code excerpt:

	float GetEndDistanceFromCamera(const FViewInfo& View)
	{
		// Ideally we'd use LumenSceneViewDistance directly, but direct shadowing via translucency lighting volume only covers 5000.0f units by default (r.TranslucencyLightingVolumeOuterDistance), 
		//		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);
	}
}

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/TranslucentLighting.cpp:108

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<float> CVarTranslucencyLightingVolumeOuterDistance(
	TEXT("r.TranslucencyLightingVolumeOuterDistance"),
	5000.0f,
	TEXT("Distance from the camera that the second volume cascade should end"),
	ECVF_RenderThreadSafe | ECVF_Scalability);

/** Function returning current translucency lighting volume dimensions. */

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/TranslucentLighting.cpp:126

Scope (from outer to inner):

file
function     void FViewInfo::CalcTranslucencyLightingVolumeBounds

Source code excerpt:

	{
		double InnerDistance = CVarTranslucencyLightingVolumeInnerDistance.GetValueOnRenderThread();
		double OuterDistance = CVarTranslucencyLightingVolumeOuterDistance.GetValueOnRenderThread();

		const double FrustumStartDistance = CascadeIndex == 0 ? 0 : InnerDistance;
		const double FrustumEndDistance = CascadeIndex == 0 ? InnerDistance : OuterDistance;

		double FieldOfView = DOUBLE_PI / 4.0;
		double AspectRatio = 1.0;