ShowFlag.CapsuleShadows

ShowFlag.CapsuleShadows

#Overview

name: ShowFlag.CapsuleShadows

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

It is referenced in 10 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of ShowFlag.CapsuleShadows is to control the rendering of capsule shadows in the Unreal Engine 5 rendering system. Capsule shadows are a type of dynamic shadow technique used to approximate shadows for characters and other objects in real-time.

This setting variable is primarily used in the rendering subsystem of Unreal Engine 5, specifically within the deferred shading renderer. It is referenced in the CapsuleShadowRendering.cpp file, which is part of the Renderer module.

The value of this variable is set through the engine’s show flags system, which allows developers to toggle various rendering features on and off. It can be accessed and modified through the ViewFamily.EngineShowFlags.CapsuleShadows property.

The CapsuleShadows variable interacts with other rendering-related variables and systems, such as dynamic shadows and indirect shadows. It is often used in conjunction with other show flags to determine whether certain shadow rendering techniques should be applied.

Developers should be aware that:

  1. This flag affects both direct and indirect capsule shadows.
  2. It is platform-dependent, as indicated by the SupportsCapsuleDirectShadows and SupportsCapsuleIndirectShadows checks.
  3. It can impact performance, especially in scenes with many dynamic objects.

Best practices when using this variable include:

  1. Only enabling it when necessary, as it can have performance implications.
  2. Considering the target platform’s capabilities before relying on capsule shadows.
  3. Using it in combination with other shadow techniques for optimal visual results.

The associated variable CapsuleShadows is essentially the same as ShowFlag.CapsuleShadows. It is used interchangeably in the code to check whether capsule shadows should be rendered. The same considerations and best practices apply to this variable as well. Its purpose is identical: to control the rendering of capsule shadows in the engine’s lighting system.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

SHOWFLAG_ALWAYS_ACCESSIBLE(RayTracedDistanceFieldShadows, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "RayTracedDistanceFieldShadows", "Distance Field Shadows"))
/** If Capsule shadows are enabled. */
SHOWFLAG_ALWAYS_ACCESSIBLE(CapsuleShadows, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "CapsuleShadows", "Capsule Shadows"))
/** If Screen Space Subsurface Scattering enabled */
SHOWFLAG_FIXED_IN_SHIPPING(1, SubsurfaceScattering, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "SubsurfaceScatteringSF", "Subsurface Scattering (Screen Space)"))
/** If Screen Space Subsurface Scattering visualization is enabled */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeSSS, SFG_Visualize, NSLOCTEXT("UnrealEd", "VisualizeSSSSF", "Subsurface Scattering (Screen Space)"))
/** Whether to apply volumetric lightmap lighting, when present. */
SHOWFLAG_ALWAYS_ACCESSIBLE(VolumetricLightmap, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "VolumetricLightmapSF", "Volumetric Lightmap"))

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

SHOWFLAG_ALWAYS_ACCESSIBLE(RayTracedDistanceFieldShadows, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "RayTracedDistanceFieldShadows", "Distance Field Shadows"))
/** If Capsule shadows are enabled. */
SHOWFLAG_ALWAYS_ACCESSIBLE(CapsuleShadows, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "CapsuleShadows", "Capsule Shadows"))
/** If Screen Space Subsurface Scattering enabled */
SHOWFLAG_FIXED_IN_SHIPPING(1, SubsurfaceScattering, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "SubsurfaceScatteringSF", "Subsurface Scattering (Screen Space)"))
/** If Screen Space Subsurface Scattering visualization is enabled */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeSSS, SFG_Visualize, NSLOCTEXT("UnrealEd", "VisualizeSSSSF", "Subsurface Scattering (Screen Space)"))
/** Whether to apply volumetric lightmap lighting, when present. */
SHOWFLAG_ALWAYS_ACCESSIBLE(VolumetricLightmap, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "VolumetricLightmapSF", "Volumetric Lightmap"))

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

Scope (from outer to inner):

file
function     bool FDeferredShadingSceneRenderer::RenderCapsuleDirectShadows

Source code excerpt:

	const FLightSceneInfo& LightSceneInfo,
	FRDGTextureRef ScreenShadowMaskTexture,
	TArrayView<const FProjectedShadowInfo* const> CapsuleShadows,
	bool bProjectingForForwardShading) const
{
	bool bAllViewsHaveViewState = true;

	for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ViewIndex++)
	{

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CapsuleShadowRendering.cpp:484

Scope (from outer to inner):

file
function     bool FDeferredShadingSceneRenderer::RenderCapsuleDirectShadows

Source code excerpt:


	if (!SupportsCapsuleDirectShadows(ShaderPlatform)
		|| CapsuleShadows.Num() == 0
		|| !ViewFamily.EngineShowFlags.CapsuleShadows
		|| !bAllViewsHaveViewState)
	{
		return false;
	}

	QUICK_SCOPE_CYCLE_COUNTER(STAT_RenderCapsuleShadows);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CapsuleShadowRendering.cpp:508

Scope (from outer to inner):

file
function     bool FDeferredShadingSceneRenderer::RenderCapsuleDirectShadows

Source code excerpt:

		RDG_GPU_MASK_SCOPE(GraphBuilder, View.GPUMask);
		RDG_EVENT_SCOPE(GraphBuilder, "CapsuleShadows");
		RDG_GPU_STAT_SCOPE(GraphBuilder, CapsuleShadows);

		TArray<FCapsuleShape3f> CapsuleShapeData;

		for (int32 ShadowIndex = 0; ShadowIndex < CapsuleShadows.Num(); ShadowIndex++)
		{
			const FProjectedShadowInfo* Shadow = CapsuleShadows[ShadowIndex];

			int32 OriginalCapsuleIndex = CapsuleShapeData.Num();

			TArray<const FPrimitiveSceneInfo*, SceneRenderingAllocator> ShadowGroupPrimitives;
			Shadow->GetParentSceneInfo()->GatherLightingAttachmentGroupPrimitives(ShadowGroupPrimitives);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CapsuleShadowRendering.cpp:953

Scope (from outer to inner):

file
function     void FDeferredShadingSceneRenderer::RenderIndirectCapsuleShadows

Source code excerpt:

	if (!SupportsCapsuleIndirectShadows(ShaderPlatform)
		|| !ViewFamily.EngineShowFlags.DynamicShadows
		|| !ViewFamily.EngineShowFlags.CapsuleShadows)
	{
		return;
	}

	RDG_CSV_STAT_EXCLUSIVE_SCOPE(GraphBuilder, RenderIndirectCapsuleShadows);
	QUICK_SCOPE_CYCLE_COUNTER(STAT_RenderIndirectCapsuleShadows);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CapsuleShadowRendering.cpp:1005

Scope (from outer to inner):

file
function     void FDeferredShadingSceneRenderer::RenderIndirectCapsuleShadows

Source code excerpt:

		{
			RDG_GPU_MASK_SCOPE(GraphBuilder, View.GPUMask);
			RDG_GPU_STAT_SCOPE(GraphBuilder, CapsuleShadows);

			int32 NumCapsuleShapes = 0;
			int32 NumMeshesWithCapsules = 0;
			int32 NumMeshDistanceFieldCasters = 0;
			IndirectCapsuleShadowsResources Resources = CreateIndirectCapsuleShadowsResources(GraphBuilder, Scene, View, NumCapsuleShapes, NumMeshesWithCapsules, NumMeshDistanceFieldCasters);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CapsuleShadowRendering.cpp:1175

Scope (from outer to inner):

file
function     bool FSceneRenderer::ShouldPrepareForDFInsetIndirectShadow

Source code excerpt:

bool FSceneRenderer::ShouldPrepareForDFInsetIndirectShadow() const
{
	return SupportsCapsuleIndirectShadows(ShaderPlatform) && ViewFamily.EngineShowFlags.CapsuleShadows;
}

void FDeferredShadingSceneRenderer::RenderCapsuleShadowsForMovableSkylight(
	FRDGBuilder& GraphBuilder,
	const FViewInfo& View,
	TRDGUniformBufferRef<FSceneTextureUniformParameters> SceneTexturesUniformBuffer,

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CapsuleShadowRendering.cpp:1185

Scope (from outer to inner):

file
function     void FDeferredShadingSceneRenderer::RenderCapsuleShadowsForMovableSkylight

Source code excerpt:

{
	if (SupportsCapsuleIndirectShadows(ShaderPlatform)
		&& ViewFamily.EngineShowFlags.CapsuleShadows)
	{
		QUICK_SCOPE_CYCLE_COUNTER(STAT_RenderCapsuleShadowsSkylight);

		if (View.IndirectShadowPrimitives.Num() > 0 && View.ViewState)
		{
			RDG_GPU_MASK_SCOPE(GraphBuilder, View.GPUMask);
			RDG_EVENT_SCOPE(GraphBuilder, "IndirectCapsuleShadows");
			RDG_GPU_STAT_SCOPE(GraphBuilder, CapsuleShadows);

			FRDGTextureRef NewBentNormal = nullptr;
			AllocateOrReuseAORenderTarget(GraphBuilder, View, NewBentNormal, TEXT("CapsuleBentNormal"), PF_FloatRGBA);

			int32 NumCapsuleShapes = 0;
			int32 NumMeshesWithCapsules = 0;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DeferredShadingRenderer.h:899

Scope (from outer to inner):

file
class        class FDeferredShadingSceneRenderer : public FSceneRenderer

Source code excerpt:

		const FLightSceneInfo& LightSceneInfo,
		FRDGTextureRef ScreenShadowMaskTexture,
		TArrayView<const FProjectedShadowInfo* const> CapsuleShadows,
		bool bProjectingForForwardShading) const;

	/** Renders indirect shadows from capsules modulated onto scene color. */
	void RenderIndirectCapsuleShadows(FRDGBuilder& GraphBuilder, const FSceneTextures& SceneTextures) const;

	/** Renders capsule shadows for movable skylights, using the cone of visibility (bent normal) from DFAO. */