ShowFlag.LightMapDensity
ShowFlag.LightMapDensity
#Overview
name: ShowFlag.LightMapDensity
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 17
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of ShowFlag.LightMapDensity is to visualize the lightmap density of objects in the scene. It is primarily used for debugging and optimizing lightmap resolution in Unreal Engine’s rendering system.
- This setting variable is part of the rendering system, specifically related to lightmapping and visualization.
- The Unreal Engine subsystems that rely on this variable include the rendering module, particularly the base pass rendering and lightmap density rendering components.
- The value of this variable is typically set through the engine’s show flags system, which allows toggling various debug visualization modes.
- It interacts closely with the associated variable LightMapDensity, which is used to store the texture for displaying lightmap density.
- Developers should be aware that enabling this flag will switch the rendering to a debug visualization mode, which may impact performance and is not intended for use in shipping builds.
- Best practices include using this flag during level design and optimization phases to ensure efficient use of lightmap resolution across different objects in the scene.
Regarding the associated variable LightMapDensity:
- This variable represents the texture used to display the lightmap density visualization.
- It is defined in the Engine class and is used when the LightMapDensity show flag is enabled.
- The texture is loaded from a path specified by the LightMapDensityTextureName property.
- This variable is used in conjunction with the ShowFlag.LightMapDensity to provide the visual representation of lightmap density in the scene.
- Developers should ensure that the appropriate texture is set for this variable to get accurate lightmap density visualization.
- When working with lightmap optimization, it’s important to reference this texture to understand how the engine is interpreting and displaying lightmap density information.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:211
Scope: file
Source code excerpt:
SHOWFLAG_FIXED_IN_SHIPPING(0, StationaryLightOverlap, SFG_Hidden, NSLOCTEXT("UnrealEd", "StationaryLightOverlapSF", "Stationary Light Overlap"))
/** needed for VMI_LightmapDensity and VMI_LitLightmapDensity, render checkerboard material with UVs scaled by lightmap resolution w. color tint for world-space lightmap density */
SHOWFLAG_FIXED_IN_SHIPPING(0, LightMapDensity, SFG_Hidden, NSLOCTEXT("UnrealEd", "LightMapDensitySF", "Light Map Density"))
/** Render streaming bounding volumes for the currently selected texture */
SHOWFLAG_FIXED_IN_SHIPPING(0, StreamingBounds, SFG_Advanced, NSLOCTEXT("UnrealEd", "StreamingBoundsSF", "Streaming Bounds"))
/** Render joint limits */
SHOWFLAG_FIXED_IN_SHIPPING(0, Constraints, SFG_Advanced, NSLOCTEXT("UnrealEd", "ConstraintsSF", "Constraints"))
/** Render mass debug data */
SHOWFLAG_FIXED_IN_SHIPPING(0, MassProperties, SFG_Advanced, NSLOCTEXT("UnrealEd", "MassPropertiesSF", "Mass Properties"))
#Associated Variable and Callsites
This variable is associated with another variable named LightMapDensity
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/Engine.h:1411
Scope: file
Source code excerpt:
FSoftObjectPath WeightMapArrayPlaceholderTextureName;
/** Texture used to display LightMapDensity */
UPROPERTY()
TObjectPtr<class UTexture2D> LightMapDensityTexture;
/** Path of the texture used to display LightMapDensity */
UPROPERTY(globalconfig)
FSoftObjectPath LightMapDensityTextureName;
// Variables.
/** Engine loop, used for callbacks from the engine module into launch. */
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PrimitiveDrawingUtils.cpp:1537
Scope (from outer to inner):
file
function bool IsRichView
Source code excerpt:
ViewFamily.EngineShowFlags.StationaryLightOverlap ||
ViewFamily.EngineShowFlags.BSPSplit ||
ViewFamily.EngineShowFlags.LightMapDensity ||
ViewFamily.EngineShowFlags.MeshEdges ||
ViewFamily.EngineShowFlags.LightInfluences ||
ViewFamily.EngineShowFlags.Wireframe ||
ViewFamily.EngineShowFlags.ActorColoration ||
ViewFamily.EngineShowFlags.LODColoration ||
ViewFamily.EngineShowFlags.HLODColoration ||
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PrimitiveDrawingUtils.cpp:1620
Scope (from outer to inner):
file
function void ApplyViewModeOverrides
Source code excerpt:
FVector2D LMResolution;
if (EngineShowFlags.LightMapDensity && Mesh.LCI)
{
auto Interaction = Mesh.LCI->GetLightMapInteraction(FeatureLevel);
auto Texture = Interaction.GetTexture(AllowHighQualityLightmaps(FeatureLevel));
if (Interaction.GetType() == LMIT_Texture && Texture)
{
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ShowFlags.cpp:764
Scope: file
Source code excerpt:
return VMI_LightComplexity;
}
else if (EngineShowFlags.LightMapDensity)
{
if (EngineShowFlags.Lighting)
{
return VMI_LitLightmapDensity;
}
else
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:211
Scope: file
Source code excerpt:
SHOWFLAG_FIXED_IN_SHIPPING(0, StationaryLightOverlap, SFG_Hidden, NSLOCTEXT("UnrealEd", "StationaryLightOverlapSF", "Stationary Light Overlap"))
/** needed for VMI_LightmapDensity and VMI_LitLightmapDensity, render checkerboard material with UVs scaled by lightmap resolution w. color tint for world-space lightmap density */
SHOWFLAG_FIXED_IN_SHIPPING(0, LightMapDensity, SFG_Hidden, NSLOCTEXT("UnrealEd", "LightMapDensitySF", "Light Map Density"))
/** Render streaming bounding volumes for the currently selected texture */
SHOWFLAG_FIXED_IN_SHIPPING(0, StreamingBounds, SFG_Advanced, NSLOCTEXT("UnrealEd", "StreamingBoundsSF", "Streaming Bounds"))
/** Render joint limits */
SHOWFLAG_FIXED_IN_SHIPPING(0, Constraints, SFG_Advanced, NSLOCTEXT("UnrealEd", "ConstraintsSF", "Constraints"))
/** Render mass debug data */
SHOWFLAG_FIXED_IN_SHIPPING(0, MassProperties, SFG_Advanced, NSLOCTEXT("UnrealEd", "MassPropertiesSF", "Mass Properties"))
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.cpp:1036
Scope (from outer to inner):
file
function void FDeferredShadingSceneRenderer::RenderBasePass
Source code excerpt:
const bool bIsWireframeRenderpass = ViewFamily.EngineShowFlags.Wireframe && FSceneRenderer::ShouldCompositeEditorPrimitives(InViews[0]);
const bool bDebugViewMode = ViewFamily.UseDebugViewPS();
const bool bRenderLightmapDensity = ViewFamily.EngineShowFlags.LightMapDensity && AllowDebugViewmodes();
const bool bRenderSkyAtmosphereEditorNotifications = ShouldRenderSkyAtmosphereEditorNotifications();
const bool bDoParallelBasePass = bEnableParallelBasePasses && !bDebugViewMode && !bRenderLightmapDensity; // DebugView and LightmapDensity are non-parallel substitutions inside BasePass
const bool bNeedsBeginRender = AllowDebugViewmodes() &&
(ViewFamily.EngineShowFlags.RequiredTextureResolution ||
ViewFamily.EngineShowFlags.VirtualTexturePendingMips ||
ViewFamily.EngineShowFlags.MaterialTextureScaleAccuracy ||
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DeferredShadingRenderer.cpp:1684
Scope (from outer to inner):
file
function void FDeferredShadingSceneRenderer::Render
Source code excerpt:
&& !ViewFamily.UseDebugViewPS()
&& !ViewFamily.EngineShowFlags.Wireframe
&& !ViewFamily.EngineShowFlags.LightMapDensity;
const FExclusiveDepthStencil::Type BasePassDepthStencilAccess =
bAllowReadOnlyDepthBasePass
? FExclusiveDepthStencil::DepthRead_StencilWrite
: FExclusiveDepthStencil::DepthWrite_StencilWrite;
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/FogRendering.cpp:560
Scope (from outer to inner):
file
function bool ShouldRenderFog
Source code excerpt:
&& CVarFog.GetValueOnRenderThread() == 1
&& !EngineShowFlags.StationaryLightOverlap
&& !EngineShowFlags.LightMapDensity;
}
float GetFogDefaultStartDistance()
{
return 30.0f;
}
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightMapDensityRendering.cpp:37
Scope: file
Source code excerpt:
BEGIN_GLOBAL_SHADER_PARAMETER_STRUCT(FLightmapDensityPassUniformParameters, )
SHADER_PARAMETER_STRUCT(FSceneTextureUniformParameters, SceneTextures)
SHADER_PARAMETER(FVector4f, LightMapDensity)
SHADER_PARAMETER(FVector4f, DensitySelectedColor) // The color to apply to selected objects.
SHADER_PARAMETER(FVector4f, VertexMappedColor) // The color to apply to vertex mapped objects.
SHADER_PARAMETER_TEXTURE(Texture2D, GridTexture) // The "Grid" texture to visualize resolution.
SHADER_PARAMETER_SAMPLER(SamplerState, GridTextureSampler)
END_GLOBAL_SHADER_PARAMETER_STRUCT()
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightMapDensityRendering.cpp:53
Scope (from outer to inner):
file
function void SetupLightmapDensityPassUniformBuffer
Source code excerpt:
LightmapDensityPassParameters.GridTextureSampler = TStaticSamplerState<SF_Bilinear, AM_Wrap, AM_Wrap, AM_Wrap>::GetRHI();
LightmapDensityPassParameters.LightMapDensity = FVector4f(
1.0f,
GEngine->MinLightMapDensity * GEngine->MinLightMapDensity,
GEngine->IdealLightMapDensity * GEngine->IdealLightMapDensity,
GEngine->MaxLightMapDensity * GEngine->MaxLightMapDensity);
LightmapDensityPassParameters.DensitySelectedColor = GEngine->LightMapDensitySelectedColor;
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightMapDensityRendering.cpp:366
Scope (from outer to inner):
file
function void FLightmapDensityMeshProcessor::AddMeshBatch
Source code excerpt:
void FLightmapDensityMeshProcessor::AddMeshBatch(const FMeshBatch& RESTRICT MeshBatch, uint64 BatchElementMask, const FPrimitiveSceneProxy* RESTRICT PrimitiveSceneProxy, int32 StaticMeshId)
{
if (FeatureLevel >= ERHIFeatureLevel::SM5 && ViewIfDynamicMeshCommand->Family->EngineShowFlags.LightMapDensity && AllowDebugViewmodes() && MeshBatch.bUseForMaterial)
{
const FMaterialRenderProxy* MaterialRenderProxy = MeshBatch.MaterialRenderProxy;
while (MaterialRenderProxy)
{
const FMaterial* Material = MaterialRenderProxy->GetMaterialNoFallback(FeatureLevel);
if (Material)
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightMapRendering.cpp:461
Scope (from outer to inner):
file
function bool FUniformLightMapPolicy::ShouldCompilePermutation
Source code excerpt:
return FMobileDirectionalLightAndCSMPolicy::ShouldCompilePermutation(Parameters);
// LightMapDensity
case LMP_DUMMY:
return FDummyLightMapPolicy::ShouldCompilePermutation(Parameters);
default:
check(false);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightMapRendering.cpp:527
Scope (from outer to inner):
file
function void FUniformLightMapPolicy::ModifyCompilationEnvironment
Source code excerpt:
break;
// LightMapDensity
case LMP_DUMMY:
FDummyLightMapPolicy::ModifyCompilationEnvironment(Parameters, OutEnvironment);
break;
default:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightMapRendering.h:336
Scope: file
Source code excerpt:
LMP_MOBILE_DIRECTIONAL_LIGHT_CSM,
// LightMapDensity
LMP_DUMMY
};
class FUniformLightMapPolicyShaderParametersType
{
DECLARE_TYPE_LAYOUT(FUniformLightMapPolicyShaderParametersType, NonVirtual);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessEyeAdaptation.cpp:1198
Scope (from outer to inner):
file
function void FViewInfo::UpdatePreExposure
Source code excerpt:
&& bIsPostProcessingEnabled
&& ViewFamily.bResolveScene
&& !ViewFamily.EngineShowFlags.LightMapDensity
&& !ViewFamily.EngineShowFlags.StationaryLightOverlap
&& !ViewFamily.EngineShowFlags.LightComplexity
&& !ViewFamily.EngineShowFlags.LODColoration
&& !ViewFamily.EngineShowFlags.HLODColoration
&& !ViewFamily.EngineShowFlags.ActorColoration
&& ((!ViewFamily.EngineShowFlags.VisualizeBuffer) || CurrentBufferVisualizationMode != NAME_None) // disable pre-exposure for the buffer visualization modes
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneVisibility.cpp:4081
Scope (from outer to inner):
file
function FVisibilityTaskData::FVisibilityTaskData
Source code excerpt:
, TaskConfig(Scene, Views)
, bAddNaniteRelevance(InSceneRenderer.ShouldRenderNanite())
, bAddLightmapDensityCommands(ViewFamily.EngineShowFlags.LightMapDensity&& AllowDebugViewmodes())
{
Tasks.bWaitingAllowed = TaskConfig.Schedule == EVisibilityTaskSchedule::Parallel;
}
void FVisibilityTaskData::LaunchVisibilityTasks(const UE::Tasks::FTask& BeginInitVisibilityPrerequisites)
{