r.LocalFogVolume.GlobalStartDistance

r.LocalFogVolume.GlobalStartDistance

#Overview

name: r.LocalFogVolume.GlobalStartDistance

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.LocalFogVolume.GlobalStartDistance is to control the start distance from which local fog volumes begin to appear in the rendering system. It is specifically used for local fog volume rendering in Unreal Engine 5.

This setting variable is primarily utilized by the Renderer module of Unreal Engine, specifically within the local fog volume rendering subsystem. This can be inferred from its usage in the LocalFogVolumeRendering.cpp file.

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

The associated variable CVarLocalFogVolumeGlobalStartDistance directly interacts with r.LocalFogVolume.GlobalStartDistance. They share the same value and purpose.

Developers must be aware that this variable affects the rendering performance and visual quality of local fog volumes. Adjusting this value will change the distance at which local fog volumes start to appear, which can impact both performance and visual fidelity.

Best practices when using this variable include:

  1. Carefully balancing performance and visual quality when adjusting the value.
  2. Testing the impact of different values in various scenes to find the optimal setting for your specific game or application.
  3. Consider the scale of your game world when setting this value, as 2000 centimeters (20 meters) might be appropriate for some scenes but not others.
  4. Be aware that this setting is render thread safe, meaning it can be changed at runtime without causing threading issues.

Regarding the associated variable CVarLocalFogVolumeGlobalStartDistance:

This is the actual console variable that controls the r.LocalFogVolume.GlobalStartDistance setting. It is defined using the TAutoConsoleVariable template, which is a part of Unreal Engine’s console variable system.

The purpose and usage of CVarLocalFogVolumeGlobalStartDistance are identical to r.LocalFogVolume.GlobalStartDistance. It’s used internally by the engine to access and modify the global start distance for local fog volumes.

Developers should note that when they want to programmatically access or modify this value, they should use the CVarLocalFogVolumeGlobalStartDistance variable. The GetLocalFogVolumeGlobalStartDistance() function provides a safe way to access this value on the render thread, ensuring a minimum value of 10.0f.

When working with this variable, it’s important to use the appropriate thread-safe methods for accessing its value, such as GetValueOnRenderThread(), to avoid potential race conditions or undefined behavior.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LocalFogVolumeRendering.cpp:63

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarLocalFogVolumeGlobalStartDistance(
	TEXT("r.LocalFogVolume.GlobalStartDistance"), 2000.0f,
	TEXT("The start distance in centimeter from which local fog volumes starts to appear."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarLocalFogVolumeUseHZB(
	TEXT("r.LocalFogVolume.UseHZB"), 1,
	TEXT("Use the HZB to cull loca lfog volume away.\n"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LocalFogVolumeRendering.cpp:62

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarLocalFogVolumeGlobalStartDistance(
	TEXT("r.LocalFogVolume.GlobalStartDistance"), 2000.0f,
	TEXT("The start distance in centimeter from which local fog volumes starts to appear."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarLocalFogVolumeUseHZB(
	TEXT("r.LocalFogVolume.UseHZB"), 1,

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LocalFogVolumeRendering.cpp:137

Scope (from outer to inner):

file
function     float GetLocalFogVolumeGlobalStartDistance

Source code excerpt:

float GetLocalFogVolumeGlobalStartDistance()
{
	return FMath::Max(10.0f, CVarLocalFogVolumeGlobalStartDistance.GetValueOnRenderThread());
}

bool IsLocalFogVolumeHalfResolution()
{
	return CVarLocalFogVolumeHalfResolution.GetValueOnRenderThread() > 0;
}