r.AOGlobalDFStartDistance

r.AOGlobalDFStartDistance

#Overview

name: r.AOGlobalDFStartDistance

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.AOGlobalDFStartDistance is to control the distance at which the rendering system switches from using object distance fields to the global distance field when performing ambient occlusion calculations.

This setting variable is primarily used in the Renderer module of Unreal Engine, specifically in the Global Distance Field and Ambient Occlusion subsystems.

The value of this variable is set through the console variable system, allowing it to be adjusted at runtime. It’s defined as an FAutoConsoleVariableRef, which means it can be modified through console commands or configuration files.

The associated variable GAOGlobalDFStartDistance directly interacts with r.AOGlobalDFStartDistance. They share the same value, with GAOGlobalDFStartDistance being the actual float variable used in the code.

Developers must be aware that this variable affects the trade-off between visual quality and performance in ambient occlusion calculations. A larger value will hide the low-resolution nature of the global distance field but may result in slower cone tracing.

Best practices when using this variable include:

  1. Adjusting it based on the scale of your scene and the desired balance between quality and performance.
  2. Testing different values to find the optimal setting for your specific use case.
  3. Considering scalability options, as this variable is marked with ECVF_Scalability flag.

Regarding the associated variable GAOGlobalDFStartDistance:

The purpose of GAOGlobalDFStartDistance is to store the actual float value used in the distance field ambient occlusion calculations.

It is used in the DistanceFieldAmbientOcclusion and GlobalDistanceField systems within the Renderer module.

The value of GAOGlobalDFStartDistance is set through the r.AOGlobalDFStartDistance console variable.

This variable interacts with other distance field-related variables, such as GAOGlobalDistanceField, to determine the maximum occlusion distances for objects and global calculations.

Developers should be aware that GAOGlobalDFStartDistance directly affects the distance at which the rendering system transitions from object-based to global distance field calculations.

Best practices include:

  1. Considering this variable when optimizing ambient occlusion performance and quality.
  2. Understanding its relationship with other distance field variables for comprehensive ambient occlusion tuning.
  3. Using it in conjunction with r.AOGlobalDFStartDistance for fine-tuning ambient occlusion behavior.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

float GAOGlobalDFStartDistance = 100;
FAutoConsoleVariableRef CVarAOGlobalDFStartDistance(
	TEXT("r.AOGlobalDFStartDistance"),
	GAOGlobalDFStartDistance,
	TEXT("World space distance along a cone trace to switch to using the global distance field instead of the object distance fields.\n")
	TEXT("This has to be large enough to hide the low res nature of the global distance field, but smaller values result in faster cone tracing."),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldAmbientOcclusion.cpp:150

Scope (from outer to inner):

file
function     FDistanceFieldAOParameters::FDistanceFieldAOParameters

Source code excerpt:

	if (GAOGlobalDistanceField != 0)
	{
		extern float GAOGlobalDFStartDistance;
		ObjectMaxOcclusionDistance = FMath::Min(InOcclusionMaxDistance, GAOGlobalDFStartDistance);
		GlobalMaxOcclusionDistance = InOcclusionMaxDistance >= GAOGlobalDFStartDistance ? InOcclusionMaxDistance : 0;
	}
	else
	{
		ObjectMaxOcclusionDistance = InOcclusionMaxDistance;
		GlobalMaxOcclusionDistance = 0;
	}

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

Scope: file

Source code excerpt:

	);

float GAOGlobalDFStartDistance = 100;
FAutoConsoleVariableRef CVarAOGlobalDFStartDistance(
	TEXT("r.AOGlobalDFStartDistance"),
	GAOGlobalDFStartDistance,
	TEXT("World space distance along a cone trace to switch to using the global distance field instead of the object distance fields.\n")
	TEXT("This has to be large enough to hide the low res nature of the global distance field, but smaller values result in faster cone tracing."),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

int32 GAOGlobalDistanceFieldRepresentHeightfields = 1;