r.DynamicGlobalIlluminationMethod
r.DynamicGlobalIlluminationMethod
#Overview
name: r.DynamicGlobalIlluminationMethod
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
0 - None. Global Illumination can be baked into Lightmaps but no technique will be used for Dynamic Global Illumination.\n1 - Lumen. Use Lumen Global Illumination for all lights, emissive materials casting light and SkyLight Occlusion. Requires \'Generate Mesh Distance Fields\' enabled for Software Ray Tracing and \'Support Hardware Ray Tracing\' enabled for Hardware Ray Tracing.\n2 - SSGI. Standalone Screen Space Global Illumination. Low cost, but limited by screen space information.\n3 - Plugin. Use a plugin for Global Illumination.
It is referenced in 9
C++ source files.
#Summary
#Usage in the C++ source code
I’d be happy to walk you through the r.DynamicGlobalIlluminationMethod
setting variable and its associated variable DynamicGlobalIllumination
. Let’s start with r.DynamicGlobalIlluminationMethod
:
-
Purpose of r.DynamicGlobalIlluminationMethod: This variable is used to control the method of dynamic global illumination in Unreal Engine 5. It’s primarily for the rendering system, specifically for managing global illumination techniques.
-
Subsystems/plugins/modules relying on this variable: Based on the callsites, this variable is used in the Renderer module, the Engine module, and the ICVFXTesting plugin. It’s primarily used in rendering-related systems.
-
Where the value is set: The value can be set in the project settings, specifically in the DefaultEngine.ini file under the [/Script/Engine.RendererSettings] section. It’s also configurable via the console variable system.
-
Interacting variables: This variable interacts closely with
r.ReflectionMethod
, especially when Lumen is used for global illumination. -
Special considerations: Developers should be aware that changing this setting can have significant impacts on rendering performance and visual quality. The choice of method depends on the project’s requirements for visual fidelity and performance.
-
Best practices:
- Consider the performance implications of each method.
- If using Lumen (value 1), ensure that ‘Generate Mesh Distance Fields’ is enabled for Software Ray Tracing and ‘Support Hardware Ray Tracing’ is enabled for Hardware Ray Tracing.
- Be aware that changing to Lumen might automatically enable Lumen Reflections as well.
Now, let’s look at the associated variable DynamicGlobalIllumination
:
-
Purpose: This is the UProperty version of the
r.DynamicGlobalIlluminationMethod
console variable, used within the URendererSettings class. -
Where it’s used: It’s primarily used in the Engine module, specifically in the RendererSettings class.
-
How it’s set: It can be set through the project settings in the Unreal Editor, which will update the DefaultEngine.ini file.
-
Interacting variables: It interacts closely with the
Reflections
property in the URendererSettings class. -
Special considerations: Changing this property through the editor will trigger the
PostEditChangeProperty
function, which includes logic to automatically enable Lumen Reflections if Lumen Global Illumination is selected. -
Best practices:
- Use this property when you need to access or modify the global illumination method in C++ code within the engine.
- Be aware of the automatic changes to reflection methods when modifying this property.
- Consider the implications on forward shading, as this property cannot be edited when forward shading is enabled.
Both these variables work together to control the global illumination method in Unreal Engine 5, with r.DynamicGlobalIlluminationMethod
being the console variable and DynamicGlobalIllumination
being its UProperty counterpart in the renderer settings.
#Setting Variables
#References In INI files
Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:117, section: [/Script/Engine.RendererSettings]
- INI Section:
/Script/Engine.RendererSettings
- Raw value:
1
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/RendererSettings.h:478
Scope (from outer to inner):
file
class class URendererSettings : public UDeveloperSettings
Source code excerpt:
UPROPERTY(config, EditAnywhere, Category = GlobalIllumination, meta=(
ConsoleVariable="r.DynamicGlobalIlluminationMethod",DisplayName="Dynamic Global Illumination Method",
ToolTip="Dynamic Global Illumination Method"))
TEnumAsByte<EDynamicGlobalIlluminationMethod::Type> DynamicGlobalIllumination;
UPROPERTY(config, EditAnywhere, Category=Reflections, meta=(
ConsoleVariable="r.ReflectionMethod",DisplayName="Reflection Method",
ToolTip="Reflection Method"))
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/IndirectLightRendering.cpp:35
Scope: file
Source code excerpt:
// Note: Default for new projects set by GameProjectUtils
static TAutoConsoleVariable<int32> CVarDynamicGlobalIlluminationMethod(
TEXT("r.DynamicGlobalIlluminationMethod"), 0,
TEXT("0 - None. Global Illumination can be baked into Lightmaps but no technique will be used for Dynamic Global Illumination.\n")
TEXT("1 - Lumen. Use Lumen Global Illumination for all lights, emissive materials casting light and SkyLight Occlusion. Requires 'Generate Mesh Distance Fields' enabled for Software Ray Tracing and 'Support Hardware Ray Tracing' enabled for Hardware Ray Tracing.\n")
TEXT("2 - SSGI. Standalone Screen Space Global Illumination. Low cost, but limited by screen space information.\n")
TEXT("3 - Plugin. Use a plugin for Global Illumination."),
ECVF_RenderThreadSafe);
#Loc: <Workspace>/Engine/Plugins/VirtualProduction/ICVFXTesting/Source/ICVFXTesting/Public/ICVFXTestControllerBase.h:76
Scope (from outer to inner):
file
class class UICVFXTestControllerBase : public UGauntletTestController
Source code excerpt:
TEXT("r.ScreenPercentage"),
TEXT("r.RayTracing"),
TEXT("r.DynamicGlobalIlluminationMethod"),
TEXT("r.ReflectionMethod"),
TEXT("r.Lumen"),
TEXT("FX.AllowGPUParticles"),
TEXT("r.Shadow.Virtual.Enable")};
uint32 RunCount;
#Loc: <Workspace>/Engine/Source/Editor/GameProjectGeneration/Private/GameProjectUtils.cpp:108
Scope (from outer to inner):
file
namespace anonymous
function void AddLumenConfigValues
Source code excerpt:
ConfigValues.Emplace(TEXT("DefaultEngine.ini"),
TEXT("/Script/Engine.RendererSettings"),
TEXT("r.DynamicGlobalIlluminationMethod"),
TEXT("1"),
true /* ShouldReplaceExistingValue */);
// Enable Lumen Reflections by default
ConfigValues.Emplace(TEXT("DefaultEngine.ini"),
TEXT("/Script/Engine.RendererSettings"),
TEXT("r.ReflectionMethod"),
TEXT("1"),
true /* ShouldReplaceExistingValue */);
}
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/EngineTypes.h:420
Scope: file
Source code excerpt:
}
// Note: Must match r.DynamicGlobalIlluminationMethod, this is used in URendererSettings
UENUM()
namespace EDynamicGlobalIlluminationMethod
{
enum Type : int
{
/** No dynamic Global Illumination method will be used. Global Illumination can still be baked into lightmaps. */
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SceneView.cpp:1999
Scope (from outer to inner):
file
function void FSceneView::StartFinalPostprocessSettings
Source code excerpt:
{
static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DynamicGlobalIlluminationMethod"));
FinalPostProcessSettings.DynamicGlobalIlluminationMethod = (EDynamicGlobalIlluminationMethod::Type)CVar->GetValueOnGameThread();
}
{
static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.ReflectionMethod"));
FinalPostProcessSettings.ReflectionMethod = (EReflectionMethod::Type)CVar->GetValueOnGameThread();
#Associated Variable and Callsites
This variable is associated with another variable named DynamicGlobalIllumination
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/RendererSettings.h:480
Scope (from outer to inner):
file
class class URendererSettings : public UDeveloperSettings
Source code excerpt:
ConsoleVariable="r.DynamicGlobalIlluminationMethod",DisplayName="Dynamic Global Illumination Method",
ToolTip="Dynamic Global Illumination Method"))
TEnumAsByte<EDynamicGlobalIlluminationMethod::Type> DynamicGlobalIllumination;
UPROPERTY(config, EditAnywhere, Category=Reflections, meta=(
ConsoleVariable="r.ReflectionMethod",DisplayName="Reflection Method",
ToolTip="Reflection Method"))
TEnumAsByte<EReflectionMethod::Type> Reflections;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/RendererSettings.cpp:209
Scope (from outer to inner):
file
function void URendererSettings::PostEditChangeProperty
Source code excerpt:
}
if (PropertyChangedEvent.Property->GetFName() == GET_MEMBER_NAME_CHECKED(URendererSettings, DynamicGlobalIllumination)
&& DynamicGlobalIllumination == EDynamicGlobalIlluminationMethod::Lumen)
{
if (Reflections != EReflectionMethod::Lumen)
{
FMessageDialog::Open(EAppMsgType::Ok, LOCTEXT("Lumen Reflections automatically enabled", "Lumen Reflections are designed to work with Lumen Global Illumination, and have been automatically enabled."));
Reflections = EReflectionMethod::Lumen;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/RendererSettings.cpp:364
Scope (from outer to inner):
file
function bool URendererSettings::CanEditChange
Source code excerpt:
}
if (InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(URendererSettings, DynamicGlobalIllumination)
|| InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(URendererSettings, Reflections)
|| InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(URendererSettings, ShadowMapMethod))
{
return !bForwardShading;
}