ShowFlag.GlobalIllumination

ShowFlag.GlobalIllumination

#Overview

name: ShowFlag.GlobalIllumination

This variable is created as a Console Variable (cvar).

It is referenced in 7 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of ShowFlag.GlobalIllumination is to control the visibility of global illumination effects in the Unreal Engine rendering system. This setting is part of the engine’s show flags, which are used to toggle various rendering features on and off.

This setting variable is primarily used in the rendering system of Unreal Engine 5. Based on the callsites, it’s utilized in several subsystems and modules, including:

  1. The main rendering module (DeferredShadingRenderer.cpp)
  2. The Lumen global illumination system (LumenDiffuseIndirect.cpp)
  3. The path tracing system (PathTracing.cpp)
  4. The volumetric fog system (VolumetricFog.cpp)

The value of this variable is typically set through the engine’s show flags system, which can be controlled via the editor UI or programmatically.

This variable interacts with several other variables and systems:

  1. It’s closely associated with the GlobalIllumination variable, which shares the same value.
  2. It’s used in conjunction with other lighting-related show flags like Lighting and LumenGlobalIllumination.
  3. It affects the behavior of indirect lighting, ambient occlusion, and other lighting-related post-processing effects.

Developers should be aware that:

  1. This flag is always accessible, even in shipping builds, as indicated by the SHOWFLAG_ALWAYS_ACCESSIBLE macro.
  2. It’s needed by the G-Buffer rendering system, which is a crucial part of the deferred rendering pipeline.
  3. Disabling this flag can significantly change the appearance of a scene by turning off indirect lighting effects.

Best practices when using this variable include:

  1. Use it for debugging or performance optimization purposes, as it allows isolating global illumination effects from other rendering features.
  2. Be cautious when disabling it in shipping builds, as it may dramatically alter the intended visual appearance of the game.
  3. Consider the interaction with other lighting-related flags and settings when modifying this value.

Regarding the associated variable GlobalIllumination:

The purpose of GlobalIllumination is the same as ShowFlag.GlobalIllumination. It’s an alternative way to access the same functionality, likely provided for convenience or compatibility reasons.

This variable is used in the same subsystems and modules as ShowFlag.GlobalIllumination. It’s set and accessed through the engine’s show flags system, just like ShowFlag.GlobalIllumination.

The main thing developers should be aware of is that modifying either ShowFlag.GlobalIllumination or GlobalIllumination will have the same effect on the rendering system. They should choose whichever is more convenient or fits better with their existing codebase when they need to check or modify this setting.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:43

Scope: file

Source code excerpt:

SHOWFLAG_FIXED_IN_SHIPPING(1, LensFlares, SFG_PostProcess, NSLOCTEXT("UnrealEd", "LensFlaresSF", "Lens Flares"))
/** show indirect lighting component, for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's needed by r.GBuffer */
SHOWFLAG_ALWAYS_ACCESSIBLE(GlobalIllumination, SFG_LightingComponents, NSLOCTEXT("UnrealEd", "GlobalIlluminationSF", "Global Illumination"))
/** Darkens the screen borders (Camera artifact and artistic effect) */
SHOWFLAG_ALWAYS_ACCESSIBLE(Vignette, SFG_PostProcess, NSLOCTEXT("UnrealEd", "VignetteSF", "Vignette"))
/** Fine film grain */
SHOWFLAG_FIXED_IN_SHIPPING(1, Grain, SFG_PostProcess, NSLOCTEXT("UnrealEd", "GrainSF", "Grain"))
/** Screen Space Ambient Occlusion, for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture */
SHOWFLAG_ALWAYS_ACCESSIBLE(AmbientOcclusion, SFG_LightingComponents, NSLOCTEXT("UnrealEd", "AmbientOcclusionSF", "Ambient Occlusion"))

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SceneView.cpp:2271

Scope (from outer to inner):

file
function     void FSceneView::EndFinalPostprocessSettings

Source code excerpt:

	}

	if (!Family->EngineShowFlags.Lighting || !Family->EngineShowFlags.GlobalIllumination)
	{
		FinalPostProcessSettings.IndirectLightingColor = FLinearColor(0,0,0,0);
		FinalPostProcessSettings.IndirectLightingIntensity = 0.0f;
	}

	if (AllowDebugViewmodes())

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:43

Scope: file

Source code excerpt:

SHOWFLAG_FIXED_IN_SHIPPING(1, LensFlares, SFG_PostProcess, NSLOCTEXT("UnrealEd", "LensFlaresSF", "Lens Flares"))
/** show indirect lighting component, for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's needed by r.GBuffer */
SHOWFLAG_ALWAYS_ACCESSIBLE(GlobalIllumination, SFG_LightingComponents, NSLOCTEXT("UnrealEd", "GlobalIlluminationSF", "Global Illumination"))
/** Darkens the screen borders (Camera artifact and artistic effect) */
SHOWFLAG_ALWAYS_ACCESSIBLE(Vignette, SFG_PostProcess, NSLOCTEXT("UnrealEd", "VignetteSF", "Vignette"))
/** Fine film grain */
SHOWFLAG_FIXED_IN_SHIPPING(1, Grain, SFG_PostProcess, NSLOCTEXT("UnrealEd", "GrainSF", "Grain"))
/** Screen Space Ambient Occlusion, for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture */
SHOWFLAG_ALWAYS_ACCESSIBLE(AmbientOcclusion, SFG_LightingComponents, NSLOCTEXT("UnrealEd", "AmbientOcclusionSF", "Ambient Occlusion"))

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DeferredShadingRenderer.cpp:2814

Scope (from outer to inner):

file
function     void FDeferredShadingSceneRenderer::Render

Source code excerpt:

				//@todo - integrate RenderRayTracingSkyLight into RenderDiffuseIndirectAndAmbientOcclusion
				&& GetViewPipelineState(Views[0]).DiffuseIndirectMethod != EDiffuseIndirectMethod::Lumen
				&& ViewFamily.EngineShowFlags.GlobalIllumination)
			{
				FRDGTextureRef SkyLightTexture = nullptr;
				FRDGTextureRef SkyLightHitDistanceTexture = nullptr;
				RenderRayTracingSkyLight(GraphBuilder, SceneTextures.Color.Target, SkyLightTexture, SkyLightHitDistanceTexture);
				CompositeRayTracingSkyLight(GraphBuilder, SceneTextures, SkyLightTexture, SkyLightHitDistanceTexture);
			}

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

Scope (from outer to inner):

file
function     bool ShouldRenderLumenDiffuseGI

Source code excerpt:

		&& View.FinalPostProcessSettings.DynamicGlobalIlluminationMethod == EDynamicGlobalIlluminationMethod::Lumen
		&& CVarLumenGlobalIllumination.GetValueOnAnyThread()
		&& View.Family->EngineShowFlags.GlobalIllumination 
		&& View.Family->EngineShowFlags.LumenGlobalIllumination
		&& !View.Family->EngineShowFlags.PathTracing
		&& (bSkipTracingDataCheck || Lumen::UseHardwareRayTracedScreenProbeGather(*View.Family) || Lumen::IsSoftwareRayTracingSupported());
}

bool ShouldRenderLumenDirectLighting(const FScene* Scene, const FSceneView& View)

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:695

Scope (from outer to inner):

file
function     static void PreparePathTracingData

Source code excerpt:

	}
	PathTracingData.EnabledIndirectLightingContributions = 0;
	if (ShowFlags.GlobalIllumination != 0)
	{
		const int EnableEmissiveCVar = CVarPathTracingEnableEmissive.GetValueOnRenderThread();
		const bool bEnableEmissive = EnableEmissiveCVar < 0 ? PPV.PathTracingEnableEmissiveMaterials : EnableEmissiveCVar != 0;
		PathTracingData.EnabledIndirectLightingContributions |= (bEnableEmissive                                                       ) ? PATHTRACER_CONTRIBUTION_EMISSIVE : 0;
		PathTracingData.EnabledIndirectLightingContributions |= (PPV.PathTracingIncludeIndirectDiffuse  != 0 && ShowFlags.Diffuse  != 0) ? PATHTRACER_CONTRIBUTION_DIFFUSE  : 0;
		PathTracingData.EnabledIndirectLightingContributions |= (PPV.PathTracingIncludeIndirectSpecular != 0 && ShowFlags.Specular != 0) ? PATHTRACER_CONTRIBUTION_SPECULAR : 0;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:1601

Scope (from outer to inner):

file
function     void FSceneRenderer::ComputeVolumetricFog

Source code excerpt:


			float StaticLightingScatteringIntensityValue = 0;
			if (View.Family->EngineShowFlags.GlobalIllumination && View.Family->EngineShowFlags.VolumetricLightmap)
			{
				StaticLightingScatteringIntensityValue = FogInfo.VolumetricFogStaticLightingScatteringIntensity;
			}
			PassParameters->StaticLightingScatteringIntensity = StaticLightingScatteringIntensityValue;

			PassParameters->PhaseG = FogInfo.VolumetricFogScatteringDistribution;