r.AOUpdateGlobalDistanceField

r.AOUpdateGlobalDistanceField

#Overview

name: r.AOUpdateGlobalDistanceField

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.AOUpdateGlobalDistanceField is to control whether the global distance field should be updated. This setting is primarily used for the rendering system, specifically for Ambient Occlusion (AO) calculations and global distance field management.

This setting variable is primarily used in the Renderer module of Unreal Engine 5, as evidenced by its location in the “Runtime/Renderer/Private/GlobalDistanceField.cpp” file.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1 (enabled) and can be changed at runtime using console commands or through configuration files.

The r.AOUpdateGlobalDistanceField variable interacts directly with its associated C++ variable GAOUpdateGlobalDistanceField. They share the same value, as the console variable is bound to the C++ variable using FAutoConsoleVariableRef.

Developers should be aware that this variable is marked with ECVF_Scalability and ECVF_RenderThreadSafe flags. This means it can affect performance scaling and is safe to modify from the render thread.

Best practices when using this variable include:

  1. Use it for debugging purposes, as indicated in the comment.
  2. Be cautious when disabling it (setting to 0) in production, as it may affect the accuracy of ambient occlusion and other rendering features that rely on the global distance field.
  3. Consider the performance implications of frequent updates to the global distance field.

Regarding the associated variable GAOUpdateGlobalDistanceField:

The purpose of GAOUpdateGlobalDistanceField is to serve as the C++ representation of the r.AOUpdateGlobalDistanceField console variable.

It’s used within the Renderer module, specifically in the global distance field update logic.

Its value is set by the console variable system and can be read directly in C++ code.

It interacts primarily with r.AOUpdateGlobalDistanceField, as they are directly linked.

Developers should be aware that modifying this variable directly in C++ code may not reflect in the console variable system, and vice versa.

Best practices include using the console variable (r.AOUpdateGlobalDistanceField) for runtime modifications and relying on GAOUpdateGlobalDistanceField for compile-time checks or performance-critical code paths.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/GlobalDistanceField.cpp:55

Scope: file

Source code excerpt:

int32 GAOUpdateGlobalDistanceField = 1;
FAutoConsoleVariableRef CVarAOUpdateGlobalDistanceField(
	TEXT("r.AOUpdateGlobalDistanceField"),
	GAOUpdateGlobalDistanceField,
	TEXT("Whether to update the global distance field, useful for debugging."),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

int32 GAOGlobalDistanceFieldCacheMostlyStaticSeparately = 1;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/GlobalDistanceField.cpp:53

Scope: file

Source code excerpt:

);

int32 GAOUpdateGlobalDistanceField = 1;
FAutoConsoleVariableRef CVarAOUpdateGlobalDistanceField(
	TEXT("r.AOUpdateGlobalDistanceField"),
	GAOUpdateGlobalDistanceField,
	TEXT("Whether to update the global distance field, useful for debugging."),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

int32 GAOGlobalDistanceFieldCacheMostlyStaticSeparately = 1;
FAutoConsoleVariableRef CVarAOGlobalDistanceFieldCacheMostlyStaticSeparately(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/GlobalDistanceField.cpp:1093

Scope (from outer to inner):

file
function     static void ComputeUpdateRegionsAndUpdateViewState

Source code excerpt:

				|| GDFReadbackRequest != nullptr;

			const bool bUpdateRequested = GAOUpdateGlobalDistanceField != 0 && ShouldUpdateClipmapThisFrame(ClipmapIndex, NumClipmaps, GlobalDistanceFieldData.UpdateIndex);

			if (bUpdateRequested && !bUpdatedThisFrame)
			{
				NumClipmapUpdateRequests++;
			}