ShowFlag.DeferredLighting

ShowFlag.DeferredLighting

#Overview

name: ShowFlag.DeferredLighting

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

It is referenced in 16 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of ShowFlag.DeferredLighting is to control the execution of deferred lighting passes in Unreal Engine’s rendering pipeline. This setting is part of the engine’s rendering system and is used for debugging and visualization purposes.

Regarding the associated variable DeferredLighting:

The purpose of DeferredLighting is essentially the same as ShowFlag.DeferredLighting. It’s used in various parts of the engine to control the execution of deferred lighting passes.

In both cases, these variables are crucial for controlling the deferred lighting system in Unreal Engine, and should be handled with care to maintain the desired visual output and performance.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

SHOWFLAG_ALWAYS_ACCESSIBLE(Lighting, SFG_Hidden, NSLOCTEXT("UnrealEd", "LightingSF", "Lighting"))
/** Execute the deferred light passes, can be disabled for debugging, for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture */
SHOWFLAG_ALWAYS_ACCESSIBLE(DeferredLighting, SFG_Advanced, NSLOCTEXT("UnrealEd", "DeferredLightingSF", "DeferredLighting"))
/** Special: Allows to hide objects in the editor, is evaluated per primitive */
SHOWFLAG_FIXED_IN_SHIPPING(0, Editor, SFG_Hidden, NSLOCTEXT("UnrealEd", "EditorSF", "Editor"))
/** needed for VMI_BrushWireframe and VMI_LitLightmapDensity, Draws BSP triangles */
SHOWFLAG_FIXED_IN_SHIPPING(1, BSPTriangles, SFG_Hidden, NSLOCTEXT("UnrealEd", "BSPTrianglesSF", "BSP Triangles"))
/** Displays large clickable icons on static mesh vertices, only needed for the editor */
SHOWFLAG_FIXED_IN_SHIPPING(0, LargeVertices, SFG_Advanced, NSLOCTEXT("UnrealEd", "LargeVerticesSF", "Large Vertices"))

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/Compositing/Composure/Source/Composure/Private/ComposureUtils.cpp:14

Scope (from outer to inner):

file
function     void FComposureUtils::SetEngineShowFlagsForPostprocessingOnly

Source code excerpt:

	EngineShowFlags.LightShafts = false;
	EngineShowFlags.Lighting = false;
	EngineShowFlags.DeferredLighting = false;
	EngineShowFlags.Decals = false;
	EngineShowFlags.Translucency = false;
	EngineShowFlags.AntiAliasing = false;
	EngineShowFlags.MotionBlur = false;
	EngineShowFlags.Bloom = false;
	EngineShowFlags.EyeAdaptation = false;

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

Scope: file

Source code excerpt:

SHOWFLAG_ALWAYS_ACCESSIBLE(Lighting, SFG_Hidden, NSLOCTEXT("UnrealEd", "LightingSF", "Lighting"))
/** Execute the deferred light passes, can be disabled for debugging, for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture */
SHOWFLAG_ALWAYS_ACCESSIBLE(DeferredLighting, SFG_Advanced, NSLOCTEXT("UnrealEd", "DeferredLightingSF", "DeferredLighting"))
/** Special: Allows to hide objects in the editor, is evaluated per primitive */
SHOWFLAG_FIXED_IN_SHIPPING(0, Editor, SFG_Hidden, NSLOCTEXT("UnrealEd", "EditorSF", "Editor"))
/** needed for VMI_BrushWireframe and VMI_LitLightmapDensity, Draws BSP triangles */
SHOWFLAG_FIXED_IN_SHIPPING(1, BSPTriangles, SFG_Hidden, NSLOCTEXT("UnrealEd", "BSPTrianglesSF", "BSP Triangles"))
/** Displays large clickable icons on static mesh vertices, only needed for the editor */
SHOWFLAG_FIXED_IN_SHIPPING(0, LargeVertices, SFG_Advanced, NSLOCTEXT("UnrealEd", "LargeVerticesSF", "Large Vertices"))

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ClusteredDeferredShadingPass.cpp:168

Scope (from outer to inner):

file
function     static void InternalAddClusteredDeferredShadingPass

Source code excerpt:

	const bool bSubstrate = Substrate::IsSubstrateEnabled() && !bHairStrands;
	const bool bHasRectLights = SortedLightsSet.bHasRectLights;
	const bool bLightFunctionAtlas = LightFunctionAtlas::IsEnabled(View, ELightFunctionAtlasSystem::DeferredLighting);

	FClusteredShadingPS::FParameters *PassParameters = GraphBuilder.AllocParameters<FClusteredShadingPS::FParameters>();
	PassParameters->bHasLightChannels = SortedLightsSet.bHasLightChannels;
	PassParameters->View = View.ViewUniformBuffer;
	PassParameters->HairStrands = HairStrands::BindHairStrandsViewUniformParameters(View);
	PassParameters->Forward = View.ForwardLightingResources.ForwardLightUniformBuffer;

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

Scope (from outer to inner):

file
function     void FDeferredShadingSceneRenderer::Render

Source code excerpt:

	const bool bRenderDeferredLighting = ViewFamily.EngineShowFlags.Lighting
		&& FeatureLevel >= ERHIFeatureLevel::SM5
		&& ViewFamily.EngineShowFlags.DeferredLighting
		&& bUseGBuffer
		&& !bHasRayTracedOverlay;

	bool bComputeLightGrid = false;

	if (RendererOutput == ERendererOutput::FinalSceneColor)

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightFunctionAtlas.cpp:288

Scope (from outer to inner):

file
namespace    LightFunctionAtlas
function     void FLightFunctionAtlas::BeginSceneFrame

Source code excerpt:

	{
		if (bVolumetricFogRequestsLF) 		{ LightFunctionAtlasSceneData.AddSystem(ELightFunctionAtlasSystem::VolumetricFog); }
		if (bDeferredlightingRequestsLF)	{ LightFunctionAtlasSceneData.AddSystem(ELightFunctionAtlasSystem::DeferredLighting); }
		if (bManyLightsRequestsLF)			{ LightFunctionAtlasSceneData.AddSystem(ELightFunctionAtlasSystem::ManyLights); }
		if (bLumenRequestsLF) 				{ LightFunctionAtlasSceneData.AddSystem(ELightFunctionAtlasSystem::Lumen); }
	}

	for (uint32 ViewIndex=0,ViewCount=Views.Num();ViewIndex<ViewCount;++ViewIndex)
	{

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightFunctionAtlas.h:37

Scope (from outer to inner):

file
namespace    LightFunctionAtlas

Source code excerpt:

{
	VolumetricFog,
	DeferredLighting,
	ManyLights,
	Lumen,
};

struct FLightFunctionAtlas;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightFunctionRendering.cpp:172

Scope (from outer to inner):

file
class        class FLightFunctionPS : public FMaterialShader
function     void SetParameters

Source code excerpt:

		if (DeferredLightParameter.IsBound())
		{
			SetDeferredLightParameters(BatchedParameters, DeferredLightParameter, LightSceneInfo, View, LightFunctionAtlas::IsEnabled(View, ELightFunctionAtlasSystem::DeferredLighting));
		}
	}

private:
	LAYOUT_FIELD(FShaderParameter, SvPositionToLight);
	LAYOUT_FIELD(FLightFunctionSharedParameters, LightFunctionParameters);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightRendering.cpp:1154

Scope (from outer to inner):

file
function     void FSceneRenderer::GatherAndSortLights

Source code excerpt:

	SortedLights.Empty(Scene->Lights.Num() + SimpleLights.InstanceData.Num());

	const bool bUseLightFunctionAtlas = LightFunctionAtlas::IsEnabled(*Scene, ELightFunctionAtlasSystem::DeferredLighting);
	bool bDynamicShadows = ViewFamily.EngineShowFlags.DynamicShadows && GetShadowQuality() > 0;

#if ENABLE_DEBUG_DISCARD_PROP
	int32 Total = Scene->Lights.Num() + SimpleLights.InstanceData.Num();
	int32 NumToKeep = int32(float(Total) * (1.0f - GDebugLightDiscardProp));
	const float DebugDiscardStride = float(NumToKeep) / float(Total);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightRendering.cpp:1337

Scope (from outer to inner):

file
function     void FDeferredShadingSceneRenderer::RenderLights

Source code excerpt:

	const bool bEnableRayTracing = false;
#endif // RHI_RAYTRACING
	const bool bUseLightFunctionAtlas = LightFunctionAtlas::IsEnabled(*Scene, ELightFunctionAtlasSystem::DeferredLighting);

	RDG_EVENT_SCOPE(GraphBuilder, "Lights");
	RDG_GPU_STAT_SCOPE(GraphBuilder, Lights);

	SCOPED_NAMED_EVENT(FDeferredShadingSceneRenderer_RenderLights, FColor::Emerald);
	SCOPE_CYCLE_COUNTER(STAT_LightingDrawTime);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightRendering.cpp:2293

Scope (from outer to inner):

file
function     static TRDGUniformBufferRef<FDeferredLightUniformStruct> CreateDeferredLightUniformBuffer

Source code excerpt:

{
	auto* DeferredLightStruct = GraphBuilder.AllocParameters<FDeferredLightUniformStruct>();
	*DeferredLightStruct = GetDeferredLightParameters(View, LightSceneInfo, LightFunctionAtlas::IsEnabled(View, ELightFunctionAtlasSystem::DeferredLighting));
	return GraphBuilder.CreateUniformBuffer(DeferredLightStruct);
}

static TRDGUniformBufferRef<FDeferredLightUniformStruct> CreateDeferredLightUniformBuffer(FRDGBuilder& GraphBuilder, const FViewInfo& View, const FSimpleLightEntry& SimpleLight, const FVector& SimpleLightPosition)
{
	auto* DeferredLightStruct = GraphBuilder.AllocParameters<FDeferredLightUniformStruct>();

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightRendering.cpp:2653

Scope: file

Source code excerpt:

		PermutationVector.Set< FDeferredLightPS::FHairComplexTransmittance >(bNeedComplexTransmittanceSupport);
		PermutationVector.Set< FDeferredLightPS::FLightFunctionAtlasDim >(
			LightFunctionAtlas::IsEnabled(View, ELightFunctionAtlasSystem::DeferredLighting) && LightSceneInfo->Proxy->HasValidLightFunctionAtlasSlot() &&
			LightSceneInfo->Proxy->GetLightFunctionMaterial() != nullptr && !View.Family->EngineShowFlags.VisualizeLightCulling);

		if (bIsRadial)
		{
			PermutationVector.Set< FDeferredLightPS::FSourceShapeDim >(LightProxy->IsRectLight() ? ELightSourceShape::Rect : ELightSourceShape::Capsule);
			PermutationVector.Set< FDeferredLightPS::FSourceTextureDim >(LightProxy->IsRectLight() && LightProxy->HasSourceTexture());

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightRendering.cpp:2809

Scope: file

Source code excerpt:

	PermutationVector.Set< FDeferredLightPS::FVirtualShadowMapMask >(bUseVirtualShadowMapMask);
	PermutationVector.Set< FDeferredLightPS::FLightFunctionAtlasDim >(
		LightFunctionAtlas::IsEnabled(View, ELightFunctionAtlasSystem::DeferredLighting) && LightSceneInfo->Proxy->HasValidLightFunctionAtlasSlot() &&
		LightSceneInfo->Proxy->GetLightFunctionMaterial() != nullptr && !View.Family->EngineShowFlags.VisualizeLightCulling);
	if (bIsDirectional)
	{
		PermutationVector.Set< FDeferredLightPS::FSourceShapeDim >(ELightSourceShape::Directional);
		PermutationVector.Set< FDeferredLightPS::FSourceTextureDim >(false);
		PermutationVector.Set< FDeferredLightPS::FIESProfileDim >(false);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowRendering.cpp:468

Scope (from outer to inner):

file
function     static void BindShaderShaders

Source code excerpt:

	FRHIBatchedShaderParameters& BatchedParameters = RHICmdList.GetScratchShaderParameters();

	const bool bUseLightFunctionAtlas = LightFunctionAtlas::IsEnabled(View, ELightFunctionAtlasSystem::DeferredLighting);
	PixelShader->SetParameters(BatchedParameters, ViewIndex, View, ShadowInfo, bUseLightFunctionAtlas);

	if (Substrate::IsSubstrateEnabled())
	{
		TRDGUniformBufferRef<FSubstrateGlobalUniformParameters> SubstrateUniformBuffer = Substrate::BindSubstrateGlobalUniformParameters(View);
		PixelShader->FGlobalShader::template SetParameters<FSubstrateGlobalUniformParameters>(BatchedParameters, SubstrateUniformBuffer->GetRHIRef());

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowRendering.h:1618

Scope (from outer to inner):

file
class        class TOnePassPointShadowProjectionPS : public FGlobalShader
function     void SetParameters

Source code excerpt:

		if (DeferredLightParameter.IsBound())
		{
			SetDeferredLightParameters(BatchedParameters, DeferredLightParameter, &ShadowInfo->GetLightSceneInfo(), View, LightFunctionAtlas::IsEnabled(View, LightFunctionAtlas::ELightFunctionAtlasSystem::DeferredLighting));
		}
	}

private:
	LAYOUT_FIELD(FOnePassPointShadowProjectionShaderParameters, OnePassShadowParameters);
	LAYOUT_FIELD(FShaderResourceParameter, ShadowDepthTextureSampler);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/TranslucentLighting.cpp:1107

Scope: file

Source code excerpt:


	const FVolumetricCloudShadowAOParameters CloudShadowAOParameters = GetCloudShadowAOParameters(GraphBuilder, View, Scene->GetVolumetricCloudSceneInfo());
	const bool bUseLightFunctionAtlas = View.LightFunctionAtlasViewData.UsesLightFunctionAtlas(LightFunctionAtlas::ELightFunctionAtlasSystem::DeferredLighting);

	FRDGTextureRef TransmittanceLutTexture = GetSkyTransmittanceLutTexture(GraphBuilder, Scene, View);

	// Inject into each volume cascade. Operate on one cascade at a time to reduce render target switches.
	for (uint32 VolumeCascadeIndex = 0; VolumeCascadeIndex < TVC_MAX; VolumeCascadeIndex++)
	{