r.AOStepExponentScale

r.AOStepExponentScale

#Overview

name: r.AOStepExponentScale

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.AOStepExponentScale is to control the distribution of Ambient Occlusion (AO) samples along a cone direction in the Distance Field Ambient Occlusion system of Unreal Engine 5.

This setting variable is primarily used in the rendering system, specifically in the Distance Field Ambient Occlusion (DFAO) subsystem. It is part of the Renderer module, as evidenced by its location in the DistanceFieldAmbientOcclusion.cpp file.

The value of this variable is set through the console variable system, using the FAutoConsoleVariableRef. This allows for runtime modification of the value, which is useful for tweaking and debugging.

The r.AOStepExponentScale variable interacts directly with the GAOStepExponentScale variable. They share the same value, with GAOStepExponentScale being the actual float variable used in the code, while r.AOStepExponentScale is the console variable name used to modify it.

Developers should be aware that this variable affects the quality and performance of the Ambient Occlusion effect. A higher value will concentrate samples closer to the origin of the cone, potentially providing more accurate results for nearby occlusion but potentially missing far-field occlusion. A lower value will distribute samples more evenly along the cone.

Best practices when using this variable include:

  1. Experimenting with different values to find the right balance between quality and performance for your specific scene.
  2. Considering the scale of your environments when setting this value.
  3. Using it in conjunction with other AO settings for optimal results.
  4. Testing the impact of changes across a variety of scenes and lighting conditions.

Regarding the associated variable GAOStepExponentScale:

The purpose of GAOStepExponentScale is to serve as the actual float variable that stores the value set by r.AOStepExponentScale.

This variable is used directly in the rendering calculations, specifically in the SetupAOShaderParameters function of the DistanceField namespace. It’s used to calculate the AOStepScale and is directly assigned to the AOStepExponentScale member of the FAOParameters struct.

The value of GAOStepExponentScale is set initially to 0.5f and can be modified at runtime through the r.AOStepExponentScale console variable.

GAOStepExponentScale interacts with other variables in the AO system, such as AOLargestSampleOffset and GAONumConeSteps, to determine the distribution of AO samples.

Developers should be aware that modifying GAOStepExponentScale directly in the code is not recommended, as it will be overwritten by the console variable system. Always use the r.AOStepExponentScale console variable to modify this value.

Best practices for GAOStepExponentScale are the same as for r.AOStepExponentScale, as they represent the same value in different contexts within the engine.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

float GAOStepExponentScale = .5f;
FAutoConsoleVariableRef CVarAOStepExponentScale(
	TEXT("r.AOStepExponentScale"),
	GAOStepExponentScale,
	TEXT("Exponent used to distribute AO samples along a cone direction."),
	ECVF_RenderThreadSafe
	);

float GAOMaxViewDistance = 20000;

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	);

float GAOStepExponentScale = .5f;
FAutoConsoleVariableRef CVarAOStepExponentScale(
	TEXT("r.AOStepExponentScale"),
	GAOStepExponentScale,
	TEXT("Exponent used to distribute AO samples along a cone direction."),
	ECVF_RenderThreadSafe
	);

float GAOMaxViewDistance = 20000;
FAutoConsoleVariableRef CVarAOMaxViewDistance(

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

Scope (from outer to inner):

file
function     FAOParameters DistanceField::SetupAOShaderParameters

Source code excerpt:

	FAOParameters ShaderParameters;
	ShaderParameters.AOObjectMaxDistance = Parameters.ObjectMaxOcclusionDistance;
	ShaderParameters.AOStepScale = AOLargestSampleOffset / FMath::Pow(2.0f, GAOStepExponentScale * (GAONumConeSteps - 1));
	ShaderParameters.AOStepExponentScale = GAOStepExponentScale;
	ShaderParameters.AOMaxViewDistance = GetMaxAOViewDistance();
	ShaderParameters.AOGlobalMaxOcclusionDistance = Parameters.GlobalMaxOcclusionDistance;

	return ShaderParameters;
}