ShowFlag.IndirectLightingCache
ShowFlag.IndirectLightingCache
#Overview
name: ShowFlag.IndirectLightingCache
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Allows to override a specific showflag (works in editor and game, \
It is referenced in 18
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of ShowFlag.IndirectLightingCache is to control the visibility and usage of the Indirect Lighting Cache feature in Unreal Engine 5’s rendering system. This setting is primarily used for lighting and rendering purposes.
- The Indirect Lighting Cache is part of Unreal Engine’s rendering subsystem, specifically the lighting features.
- It is used in various parts of the engine, including the Renderer module and the Scene management system.
- The value of this variable is set through the engine’s show flags system, which allows toggling various rendering features on and off.
- It interacts closely with the IndirectLightingCache variable, which is the actual implementation of the cache.
- Developers should be aware that this flag affects the rendering performance and visual quality of indirect lighting in the scene.
- Best practices include using this flag for debugging and optimization purposes, and ensuring it’s enabled for final builds to benefit from the performance improvements it offers.
Regarding the associated variable IndirectLightingCache:
The purpose of IndirectLightingCache is to implement the actual caching mechanism for indirect lighting in Unreal Engine 5.
- It is a core component of the engine’s lighting system, used to optimize rendering performance by caching indirect lighting information.
- This variable is used extensively in the Renderer module, particularly in classes like FIndirectLightingCache and FScene.
- The value of this variable is typically set during scene initialization and updated as needed during rendering.
- It interacts with various other systems, including the GPUScene, PrimitiveSceneInfo, and ViewUniformShaderParameters.
- Developers should be aware that the IndirectLightingCache can have a significant impact on rendering performance and memory usage.
- Best practices include properly managing the lifecycle of the cache (initialization, updates, and cleanup) and considering its impact on different hardware configurations.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:161
Scope: file
Source code excerpt:
SHOWFLAG_ALWAYS_ACCESSIBLE(VolumetricLightmap, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "VolumetricLightmapSF", "Volumetric Lightmap"))
/** If the indirect lighting cache is enabled, for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture */
SHOWFLAG_ALWAYS_ACCESSIBLE(IndirectLightingCache, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "IndirectLightingCacheSF", "Indirect Lighting Cache"))
/** calls debug drawing for AIs */
SHOWFLAG_FIXED_IN_SHIPPING(0, DebugAI, SFG_Developer, NSLOCTEXT("UnrealEd", "DebugAISF", "AI Debug"))
/** calls debug drawing for whatever LogVisualizer wants to draw */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisLog, SFG_Developer, NSLOCTEXT("UnrealEd", "VisLogSF", "Log Visualizer"))
/** whether to draw navigation data */
SHOWFLAG_FIXED_IN_SHIPPING(0, Navigation, SFG_Normal, NSLOCTEXT("UnrealEd", "NavigationSF", "Navigation"))
#Associated Variable and Callsites
This variable is associated with another variable named IndirectLightingCache
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PrimitiveDrawingUtils.cpp:1525
Scope (from outer to inner):
file
function bool IsRichView
Source code excerpt:
// Force FDrawBasePassDynamicMeshAction to be used since it has access to the view and can implement the show flags
!ViewFamily.EngineShowFlags.VolumetricLightmap ||
!ViewFamily.EngineShowFlags.IndirectLightingCache ||
!ViewFamily.EngineShowFlags.Lighting ||
!ViewFamily.EngineShowFlags.Materials)
{
return true;
}
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:161
Scope: file
Source code excerpt:
SHOWFLAG_ALWAYS_ACCESSIBLE(VolumetricLightmap, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "VolumetricLightmapSF", "Volumetric Lightmap"))
/** If the indirect lighting cache is enabled, for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture */
SHOWFLAG_ALWAYS_ACCESSIBLE(IndirectLightingCache, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "IndirectLightingCacheSF", "Indirect Lighting Cache"))
/** calls debug drawing for AIs */
SHOWFLAG_FIXED_IN_SHIPPING(0, DebugAI, SFG_Developer, NSLOCTEXT("UnrealEd", "DebugAISF", "AI Debug"))
/** calls debug drawing for whatever LogVisualizer wants to draw */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisLog, SFG_Developer, NSLOCTEXT("UnrealEd", "VisLogSF", "Log Visualizer"))
/** whether to draw navigation data */
SHOWFLAG_FIXED_IN_SHIPPING(0, Navigation, SFG_Normal, NSLOCTEXT("UnrealEd", "NavigationSF", "Navigation"))
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/IndirectLightingCache.cpp:473
Scope (from outer to inner):
file
function bool FIndirectLightingCache::IndirectLightingAllowed
Source code excerpt:
for (int32 ViewIndex = 0; ViewIndex < Renderer.Views.Num(); ViewIndex++)
{
bAnyViewAllowsIndirectLightingCache |= (bool)Renderer.Views[ViewIndex].Family->EngineShowFlags.IndirectLightingCache;
}
}
return bAnyViewAllowsIndirectLightingCache;
}
void FIndirectLightingCache::ProcessPrimitiveUpdate(FScene* Scene, FViewInfo& View, int32 PrimitiveIndex, bool bAllowUnbuiltPreview, bool bAllowVolumeSample, TMap<FIntVector, FBlockUpdateInfo>& OutBlocksToUpdate, TArray<FIndirectLightingCacheAllocation*>& OutTransitionsOverTimeToUpdate, TArray<FPrimitiveSceneInfo*>& OutPrimitivesToUpdateStaticMeshes)
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightMapRendering.h:347
Scope (from outer to inner):
file
class class FUniformLightMapPolicyShaderParametersType
function void Bind
Source code excerpt:
{
PrecomputedLightingBufferParameter.Bind(ParameterMap, TEXT("PrecomputedLightingBuffer"));
IndirectLightingCacheParameter.Bind(ParameterMap, TEXT("IndirectLightingCache"));
LightmapResourceCluster.Bind(ParameterMap, TEXT("LightmapResourceCluster"));
}
void Serialize(FArchive& Ar)
{
Ar << PrecomputedLightingBufferParameter;
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/MobileShadingRenderer.cpp:728
Scope (from outer to inner):
file
function void FMobileSceneRenderer::InitViews
Source code excerpt:
if (ILCTaskData)
{
Scene->IndirectLightingCache.FinalizeCacheUpdates(Scene, *this, *ILCTaskData);
}
}
ExternalAccessQueue.Submit(GraphBuilder);
InstanceCullingManager.BeginDeferredCulling(GraphBuilder, Scene->GPUScene);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PrimitiveSceneInfo.cpp:1562
Scope (from outer to inner):
file
function void FPrimitiveSceneInfo::AddToScene
Source code excerpt:
&& IsIndirectLightingCacheAllowed(Scene->GetFeatureLevel()))
{
FIndirectLightingCacheAllocation* PrimitiveAllocation = Scene->IndirectLightingCache.FindPrimitiveAllocation(SceneInfo->PrimitiveComponentId);
if (PrimitiveAllocation)
{
SceneInfo->IndirectLightingCacheAllocation = PrimitiveAllocation;
PrimitiveAllocation->SetDirty();
}
else
{
PrimitiveAllocation = Scene->IndirectLightingCache.AllocatePrimitive(SceneInfo, true);
PrimitiveAllocation->SetDirty();
SceneInfo->IndirectLightingCacheAllocation = PrimitiveAllocation;
}
}
SceneInfo->MarkIndirectLightingCacheBufferDirty();
}
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PrimitiveSceneInfo.cpp:2280
Scope (from outer to inner):
file
function void FPrimitiveSceneInfo::UpdateIndirectLightingCacheBuffer
Source code excerpt:
}
// The update is invalid if the lighting cache allocation was not in a functional state.
else if (IndirectLightingCacheAllocation && (Scene->IndirectLightingCache.IsInitialized() && IndirectLightingCacheAllocation->bHasEverUpdatedSingleSample))
{
UpdateIndirectLightingCacheBuffer(
RHICmdList,
&Scene->IndirectLightingCache,
IndirectLightingCacheAllocation,
FVector(0, 0, 0),
0,
nullptr);
}
else
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RendererScene.cpp:1628
Scope (from outer to inner):
file
function FScene::FScene
Source code excerpt:
, SimpleDirectionalLight(NULL)
, ReflectionSceneData(InFeatureLevel)
, IndirectLightingCache(InFeatureLevel)
, VolumetricLightmapSceneData(this)
, GPUScene(*this)
, DistanceFieldSceneData(GShaderPlatformForFeatureLevel[InFeatureLevel])
, DefaultLumenSceneData(nullptr)
, PreshadowCacheLayout(0, 0, 0, 0, false)
, SkyAtmosphere(NULL)
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RendererScene.cpp:1797
Scope (from outer to inner):
file
function FScene::~FScene
Source code excerpt:
ReflectionSceneData.CubemapArray.ReleaseResource();
IndirectLightingCache.ReleaseResource();
DistanceFieldSceneData.Release();
delete GPUSkinCache;
GPUSkinCache = nullptr;
ComputeSystemInterface::DestroyWorkers(this, ComputeTaskWorkers);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RendererScene.cpp:2579
Scope (from outer to inner):
file
function void FScene::BatchReleasePrimitivesInternal
lambda-function
Source code excerpt:
{
// Free the space in the indirect lighting cache
Scene->IndirectLightingCache.ReleasePrimitive(PrimitiveComponentId);
}
});
}
void FScene::BatchReleasePrimitives(TArrayView<UPrimitiveComponent*> InPrimitives)
{
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RendererScene.cpp:3463
Scope (from outer to inner):
file
function void FScene::AddPrecomputedLightVolume
lambda-function
Source code excerpt:
{
Scene->PrecomputedLightVolumes.Add(Volume);
Scene->IndirectLightingCache.SetLightingCacheDirty(Scene, Volume);
});
}
void FScene::RemovePrecomputedLightVolume(const FPrecomputedLightVolume* Volume)
{
FScene* Scene = this;
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RendererScene.cpp:3475
Scope (from outer to inner):
file
function void FScene::RemovePrecomputedLightVolume
lambda-function
Source code excerpt:
{
Scene->PrecomputedLightVolumes.Remove(Volume);
Scene->IndirectLightingCache.SetLightingCacheDirty(Scene, Volume);
});
}
void FVolumetricLightmapSceneData::AddLevelVolume(const FPrecomputedVolumetricLightmap* InVolume, EShadingPath ShadingPath, bool bIsPersistentLevel)
{
LevelVolumetricLightmaps.Add(InVolume);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RendererScene.cpp:4843
Scope (from outer to inner):
file
function void FScene::ApplyWorldOffset_RenderThread
Source code excerpt:
// Invalidate indirect lighting cache
IndirectLightingCache.SetLightingCacheDirty(this, NULL);
// Primitives octree
PrimitiveOctree.ApplyOffset(InOffset, /*bGlobalOctee*/ true);
// Lights
VectorRegister OffsetReg = VectorLoadFloat3_W0(&InOffset);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScenePrivate.h:3083
Scope (from outer to inner):
file
class class FScene : public FSceneInterface
Source code excerpt:
/** Interpolates and caches indirect lighting for dynamic objects. */
FIndirectLightingCache IndirectLightingCache;
FVolumetricLightmapSceneData VolumetricLightmapSceneData;
FGPUScene GPUScene;
#if RHI_RAYTRACING
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:1275
Scope (from outer to inner):
file
function void FViewInfo::SetupUniformBufferParameters
Source code excerpt:
ViewUniformShaderParameters.bCheckerboardSubsurfaceProfileRendering = bCheckerboardSubsurfaceRendering ? 1.0f : 0.0f;
ViewUniformShaderParameters.IndirectLightingCacheShowFlag = Family->EngineShowFlags.IndirectLightingCache;
FScene* Scene = nullptr;
if (Family->Scene)
{
Scene = Family->Scene->GetRenderScene();
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneVisibility.cpp:5423
Scope (from outer to inner):
file
function void FSceneRenderer::PostVisibilityFrameSetup
Source code excerpt:
{
OutILCTaskData = Allocator.Create<FILCUpdatePrimTaskData>();
Scene->IndirectLightingCache.StartUpdateCachePrimitivesTask(Scene, *this, true, *OutILCTaskData);
check(OutILCTaskData->TaskRef.IsValid());
}
}
uint32 GetShadowQuality();
void UpdateHairResources(FRDGBuilder& GraphBuilder, const FViewInfo& View);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneVisibility.cpp:5647
Scope (from outer to inner):
file
function void FDeferredShadingSceneRenderer::EndInitViews
Source code excerpt:
QUICK_SCOPE_CYCLE_COUNTER(STAT_PostVisibilityFrameSetup_IndirectLightingCache_Update);
check(!TaskDatas.ILCUpdatePrim);
Scene->IndirectLightingCache.UpdateCache(Scene, *this, true);
}
// If we kicked off ILC update via task, wait and finalize.
if (TaskDatas.ILCUpdatePrim)
{
Scene->IndirectLightingCache.FinalizeCacheUpdates(Scene, *this, *TaskDatas.ILCUpdatePrim);
}
{
QUICK_SCOPE_CYCLE_COUNTER(STAT_InitViews_UpdatePrimitiveIndirectLightingCacheBuffers);
// Now that the indirect lighting cache is updated, we can update the primitive precomputed lighting buffers.
UpdatePrimitiveIndirectLightingCacheBuffers(GraphBuilder.RHICmdList);