ShowFlag.RayTracedDistanceFieldShadows

ShowFlag.RayTracedDistanceFieldShadows

#Overview

name: ShowFlag.RayTracedDistanceFieldShadows

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of ShowFlag.RayTracedDistanceFieldShadows is to control the visibility of ray-traced distance field shadows in the rendering system of Unreal Engine 5. This setting is part of the lighting features and is used to enable or disable the rendering of distance field shadows using ray tracing techniques.

The Unreal Engine subsystem that primarily relies on this setting variable is the Renderer module, specifically the distance field shadowing component. This can be seen from the references in the DistanceFieldShadowing.cpp file.

The value of this variable is set through the engine’s show flags system, which allows developers and users to toggle various rendering features on and off. It’s typically controlled via the engine’s user interface or through code.

This variable interacts closely with other rendering and shadowing-related variables, such as ContactShadows and CapsuleShadows, as seen in the ShowFlagsValues.inl file. It’s part of a group of shadow-related show flags that collectively control different aspects of shadow rendering in the engine.

Developers must be aware that this variable specifically controls ray-traced distance field shadows, which is a high-quality but potentially performance-intensive shadowing technique. Enabling this feature may have performance implications, especially on less powerful hardware.

Best practices when using this variable include:

  1. Consider the target hardware when deciding to enable this feature.
  2. Use it in conjunction with other shadowing techniques for a balance of performance and visual quality.
  3. Test thoroughly to ensure it doesn’t cause performance issues in your specific use case.

Regarding the associated variable RayTracedDistanceFieldShadows, it appears to be the same variable, just referenced in different contexts. The purpose and usage considerations are the same as described above. It’s used in the actual rendering code to check if the feature should be applied, as seen in the DistanceFieldShadowing.cpp file. Developers should ensure consistency when referencing this variable, whether through the ShowFlag system or directly in code.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

SHOWFLAG_ALWAYS_ACCESSIBLE(ContactShadows, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "ContactShadows", "Screen Space Contact Shadows"))
/** If RTDF shadows are enabled. */
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)"))

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

SHOWFLAG_ALWAYS_ACCESSIBLE(ContactShadows, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "ContactShadows", "Screen Space Contact Shadows"))
/** If RTDF shadows are enabled. */
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)"))

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldShadowing.cpp:880

Scope (from outer to inner):

file
function     FRDGTextureRef FProjectedShadowInfo::RenderRayTracedDistanceFieldProjection

Source code excerpt:

	const FScene* Scene = (const FScene*)(View.Family->Scene);

	if (bDFShadowSupported && View.Family->EngineShowFlags.RayTracedDistanceFieldShadows)
	{
		QUICK_SCOPE_CYCLE_COUNTER(STAT_BeginRenderRayTracedDistanceFieldShadows);
		RDG_EVENT_SCOPE(GraphBuilder, "BeginRayTracedDistanceFieldShadow");

		if (Scene->DistanceFieldSceneData.NumObjectsInBuffer > 0)
		{

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldShadowing.cpp:968

Scope (from outer to inner):

file
function     FRDGTextureRef FProjectedShadowInfo::RenderRayTracedDistanceFieldProjection

Source code excerpt:


	if (bDirectionalLight
		&& View.Family->EngineShowFlags.RayTracedDistanceFieldShadows
		&& GHeightFieldTextureAtlas.HasAtlasTexture()
		&& Scene->DistanceFieldSceneData.HeightFieldObjectBuffers
		&& Scene->DistanceFieldSceneData.HeightfieldPrimitives.Num() > 0
		&& bHFShadowSupported)
	{
		QUICK_SCOPE_CYCLE_COUNTER(STAT_BeginRenderRayTracedHeightFieldShadows);