r.Lumen.DiffuseIndirect.SSAO

r.Lumen.DiffuseIndirect.SSAO

#Overview

name: r.Lumen.DiffuseIndirect.SSAO

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.Lumen.DiffuseIndirect.SSAO is to control whether Screen Space Ambient Occlusion (SSAO) should be rendered and applied to Lumen Global Illumination (GI) in specific circumstances within the Unreal Engine 5 rendering system.

This setting variable is primarily used by the Lumen subsystem, which is part of Unreal Engine 5’s rendering module. It specifically affects the diffuse indirect lighting calculations in Lumen.

The value of this variable is set through the console variable system in Unreal Engine. It’s defined as an integer with a default value of 0, meaning it’s disabled by default.

This variable interacts closely with another setting, r.Lumen.ScreenProbeGather.ShortRangeAO. The SSAO is only applied when ShortRangeAO is disabled, providing an alternative method for short-range occlusion.

Developers must be aware that this setting is part of the scalability options and is render thread safe. When enabled, it uses the user’s post-process settings for SSAO parameters like screen radius, which might not be optimized for Lumen GI specifically.

Best practices when using this variable include:

  1. Only enable it when r.Lumen.ScreenProbeGather.ShortRangeAO is disabled and you need short-range occlusion.
  2. Be mindful of the performance impact, as rendering SSAO can be costly.
  3. Carefully tune the SSAO post-process settings to work well with Lumen GI.

Regarding the associated variable GLumenDiffuseIndirectApplySSAO:

The purpose of GLumenDiffuseIndirectApplySSAO is to serve as the internal representation of the r.Lumen.DiffuseIndirect.SSAO setting within the engine’s C++ code.

This variable is used directly in the rendering code, specifically in the Lumen diffuse indirect lighting calculations. It’s checked in the ShouldRenderAOWithLumenGI() function to determine if SSAO should be applied with Lumen GI.

The value of this variable is set by the console variable system when r.Lumen.DiffuseIndirect.SSAO is modified.

GLumenDiffuseIndirectApplySSAO interacts with GLumenShortRangeAmbientOcclusion in the ShouldRenderAOWithLumenGI() function to determine the final behavior.

Developers should be aware that this variable is used in render thread code and should not be modified directly, but rather through the console variable system.

Best practices include using the console variable r.Lumen.DiffuseIndirect.SSAO to modify this setting rather than changing GLumenDiffuseIndirectApplySSAO directly in code.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenDiffuseIndirect.cpp:159

Scope: file

Source code excerpt:

int32 GLumenDiffuseIndirectApplySSAO = 0;
FAutoConsoleVariableRef CVarLumenDiffuseIndirectApplySSAO(
	TEXT("r.Lumen.DiffuseIndirect.SSAO"),
	GLumenDiffuseIndirectApplySSAO,
	TEXT("Whether to render and apply SSAO to Lumen GI, only when r.Lumen.ScreenProbeGather.ShortRangeAO is disabled.  This is useful for providing short range occlusion when Lumen's Screen Bent Normal is disabled due to scalability, however SSAO settings like screen radius come from the user's post process settings."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

int32 GLumenShouldUseStereoOptimizations = 1;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenDiffuseIndirect.cpp:157

Scope: file

Source code excerpt:

);

int32 GLumenDiffuseIndirectApplySSAO = 0;
FAutoConsoleVariableRef CVarLumenDiffuseIndirectApplySSAO(
	TEXT("r.Lumen.DiffuseIndirect.SSAO"),
	GLumenDiffuseIndirectApplySSAO,
	TEXT("Whether to render and apply SSAO to Lumen GI, only when r.Lumen.ScreenProbeGather.ShortRangeAO is disabled.  This is useful for providing short range occlusion when Lumen's Screen Bent Normal is disabled due to scalability, however SSAO settings like screen radius come from the user's post process settings."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

int32 GLumenShouldUseStereoOptimizations = 1;
FAutoConsoleVariableRef CVarLumenShouldUseStereoOptimizations(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenDiffuseIndirect.cpp:290

Scope (from outer to inner):

file
function     bool ShouldRenderAOWithLumenGI

Source code excerpt:

{
	extern int32 GLumenShortRangeAmbientOcclusion;
	return GLumenDiffuseIndirectApplySSAO != 0 && GLumenShortRangeAmbientOcclusion == 0;
}

bool ShouldUseStereoLumenOptimizations()
{
	return GLumenShouldUseStereoOptimizations != 0;
}