ShowFlag.ScreenSpaceReflections

ShowFlag.ScreenSpaceReflections

#Overview

name: ShowFlag.ScreenSpaceReflections

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

It is referenced in 19 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of ShowFlag.ScreenSpaceReflections is to control the rendering of Screen Space Reflections (SSR) in Unreal Engine 5. Screen Space Reflections is a rendering technique that adds realistic reflections to surfaces in real-time by using information already available on the screen.

This setting variable is primarily used by the rendering system, specifically in the following Unreal Engine subsystems and modules:

  1. The main Renderer module
  2. The Composure plugin
  3. The Customizable Object Editor
  4. The Functional Testing system
  5. The Persona animation editor

The value of this variable is typically set in various places:

  1. In engine configuration files
  2. Through the engine’s show flags system
  3. In viewport clients (e.g., FAnimationViewportClient)
  4. In automation and testing setups (UAutomationViewSettings)

Several other variables interact with ShowFlag.ScreenSpaceReflections:

  1. ReflectionEnvironment
  2. LumenReflections
  3. Other post-processing effects like MotionBlur, TemporalAA, ScreenSpaceAO, etc.

Developers should be aware of the following when using this variable:

  1. It can significantly impact performance, especially on lower-end hardware.
  2. It interacts with other reflection techniques like Lumen and should be configured accordingly.
  3. It’s often used in conjunction with other post-processing effects for optimal visual quality.

Best practices when using this variable include:

  1. Providing user options to toggle or adjust SSR quality for performance reasons.
  2. Ensuring it’s properly set in different view modes (e.g., editor, game, cinematics).
  3. Considering its interaction with other reflection techniques and choosing the most appropriate one for your project’s needs and performance targets.

Regarding the associated variable ScreenSpaceReflections:

The purpose of ScreenSpaceReflections is essentially the same as ShowFlag.ScreenSpaceReflections. It’s used in various parts of the engine to control the SSR effect, often in more specific contexts or for particular features.

This variable is used in similar subsystems and modules as ShowFlag.ScreenSpaceReflections, including the Renderer, Composure plugin, and various editor tools.

The value is typically set in viewport clients, editor settings, and sometimes in material or shader configurations.

Developers should be aware that this variable might be used in more specific contexts than the show flag version, such as in material editors or specific rendering passes.

Best practices include ensuring consistency between this variable and the show flag version, and considering its impact on different types of materials or surfaces in your scenes.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

SHOWFLAG_FIXED_IN_SHIPPING(0, SelectionOutlineColor5, SFG_Hidden, NSLOCTEXT("UnrealEd", "SelectionOutlineColor5", "Selection Outline Color 5"))
/** If screen space reflections are enabled, for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture */
SHOWFLAG_ALWAYS_ACCESSIBLE(ScreenSpaceReflections, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "ScreenSpaceReflectionsSF", "Screen Space Reflections"))
SHOWFLAG_ALWAYS_ACCESSIBLE(LumenReflections, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "LumenReflectionsSF", "Lumen Reflections"))
/** If Screen space contact shadows are enabled. */
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. */

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
function     void FComposureUtils::SetEngineShowFlagsForPostprocessingOnly

Source code excerpt:

	EngineShowFlags.DynamicShadows = false;
	EngineShowFlags.ReflectionEnvironment = false;
	EngineShowFlags.ScreenSpaceReflections = false;
	EngineShowFlags.ScreenSpaceAO = false;
	EngineShowFlags.LightShafts = false;
	EngineShowFlags.Lighting = false;
	EngineShowFlags.DeferredLighting = false;
	EngineShowFlags.Decals = false;
	EngineShowFlags.Translucency = false;

#Loc: <Workspace>/Engine/Plugins/Experimental/Mutable/Source/CustomizableObjectEditor/Private/MuCOE/CustomizableObjectEditorViewportClient.cpp:101

Scope (from outer to inner):

file
function     FCustomizableObjectEditorViewportClient::FCustomizableObjectEditorViewportClient

Source code excerpt:

	EngineShowFlags.SetCompositeEditorPrimitives(true);

	EngineShowFlags.ScreenSpaceReflections = 1;
	EngineShowFlags.AmbientOcclusion = 1;
	EngineShowFlags.Grid = ConfigOption->bShowGrid;

	OverrideNearClipPlane(1.0f);

	SetPreviewComponent(nullptr);

#Loc: <Workspace>/Engine/Plugins/Interchange/Runtime/Source/Nodes/Public/InterchangeShaderGraphNode.h:305

Scope (from outer to inner):

file
class        class UInterchangeShaderGraphNode : public UInterchangeShaderNode

Source code excerpt:

	IMPLEMENT_NODE_ATTRIBUTE_KEY(OpacityMaskClipValue)
	IMPLEMENT_NODE_ATTRIBUTE_KEY(IsAShaderFunction)
	IMPLEMENT_NODE_ATTRIBUTE_KEY(ScreenSpaceReflections)
	IMPLEMENT_NODE_ATTRIBUTE_KEY(BlendMode)
};

#Loc: <Workspace>/Engine/Source/Developer/FunctionalTesting/Private/AutomationBlueprintFunctionLibrary.cpp:187

Scope (from outer to inner):

file
class        class FAutomationViewExtension : public FWorldSceneViewExtension
function     virtual void SetupViewFamily

Source code excerpt:

			ShowFlags.SetMotionBlur(ViewSettings->MotionBlur);
			ShowFlags.SetTemporalAA(ViewSettings->TemporalAA);
			ShowFlags.SetScreenSpaceReflections(ViewSettings->ScreenSpaceReflections);
			ShowFlags.SetScreenSpaceAO(ViewSettings->ScreenSpaceAO);
			ShowFlags.SetDistanceFieldAO(ViewSettings->DistanceFieldAO);
			ShowFlags.SetContactShadows(ViewSettings->ContactShadows);
			ShowFlags.SetEyeAdaptation(ViewSettings->EyeAdaptation);
			ShowFlags.SetBloom(ViewSettings->Bloom);
		}

#Loc: <Workspace>/Engine/Source/Developer/FunctionalTesting/Public/AutomationViewSettings.h:18

Scope (from outer to inner):

file
class        class UAutomationViewSettings : public UDataAsset
function     UAutomationViewSettings

Source code excerpt:

		, MotionBlur(true)
		, TemporalAA(true)
		, ScreenSpaceReflections(true)
		, ScreenSpaceAO(true)
		, DistanceFieldAO(true)
		, ContactShadows(true)
		, EyeAdaptation(true)
		, Bloom(true)
	{

#Loc: <Workspace>/Engine/Source/Developer/FunctionalTesting/Public/AutomationViewSettings.h:37

Scope (from outer to inner):

file
class        class UAutomationViewSettings : public UDataAsset

Source code excerpt:

	
	UPROPERTY(EditAnywhere, Category="Rendering")
	bool ScreenSpaceReflections;
	
	UPROPERTY(EditAnywhere, Category="Rendering")
	bool ScreenSpaceAO;
	
	UPROPERTY(EditAnywhere, Category="Rendering")
	bool DistanceFieldAO;

#Loc: <Workspace>/Engine/Source/Editor/Persona/Private/AnimationEditorViewportClient.cpp:123

Scope (from outer to inner):

file
function     FAnimationViewportClient::FAnimationViewportClient

Source code excerpt:


	EngineShowFlags.Game = 0;
	EngineShowFlags.ScreenSpaceReflections = 1;
	EngineShowFlags.AmbientOcclusion = 1;
	EngineShowFlags.SetSnap(0);
	EngineShowFlags.Grid = ConfigOption->bShowGrid;

	SetRealtime(true);
	if(GEditor->PlayWorld)

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

Scope: file

Source code excerpt:

SHOWFLAG_FIXED_IN_SHIPPING(0, SelectionOutlineColor5, SFG_Hidden, NSLOCTEXT("UnrealEd", "SelectionOutlineColor5", "Selection Outline Color 5"))
/** If screen space reflections are enabled, for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture */
SHOWFLAG_ALWAYS_ACCESSIBLE(ScreenSpaceReflections, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "ScreenSpaceReflectionsSF", "Screen Space Reflections"))
SHOWFLAG_ALWAYS_ACCESSIBLE(LumenReflections, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "LumenReflectionsSF", "Lumen Reflections"))
/** If Screen space contact shadows are enabled. */
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. */

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CompositionLighting/CompositionLighting.cpp:71

Scope (from outer to inner):

file
function     static bool IsReflectionEnvironmentActive

Source code excerpt:

	bool IsReflectingEnvironment = View.Family->EngineShowFlags.ReflectionEnvironment;
	bool HasReflectionCaptures = (Scene->ReflectionSceneData.RegisteredReflectionCaptures.Num() > 0);
	bool HasSSR = View.Family->EngineShowFlags.ScreenSpaceReflections;

	return (Scene->GetFeatureLevel() >= ERHIFeatureLevel::SM5 && IsReflectingEnvironment && (HasReflectionCaptures || HasSSR) && !IsForwardShadingEnabled(View.GetShaderPlatform()));
}

static bool IsSkylightActive(const FViewInfo& View)
{

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/IndirectLightRendering.cpp:2053

Scope (from outer to inner):

file
function     void FDeferredShadingSceneRenderer::RenderDeferredReflectionsAndSkyLighting

Source code excerpt:

				check(View.ViewState);
				FTAAPassParameters TAASettings(View);
				TAASettings.Pass = ETAAPassConfig::ScreenSpaceReflections;
				TAASettings.SceneDepthTexture = SceneTextureParameters.SceneDepthTexture;
				TAASettings.SceneVelocityTexture = SceneTextureParameters.GBufferVelocityTexture;
				TAASettings.SceneColorInput = DenoiserInputs.Color;
				TAASettings.bOutputRenderTargetable = (
					ViewPipelineState.bComposePlanarReflections ||
					ViewPipelineState.ReflectionsMethod == EReflectionsMethod::Lumen);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/TemporalAA.h:36

Scope: file

Source code excerpt:


	// Permutation for SSR noise accumulation.
	ScreenSpaceReflections,
	
	// Permutation for light shaft noise accumulation.
	LightShaft,

	// Permutation for DOF that handle Coc.
	DiaphragmDOF,

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceRayTracing.cpp:123

Scope (from outer to inner):

file
namespace    ScreenSpaceRayTracing
function     bool ShouldRenderScreenSpaceReflections

Source code excerpt:

bool ShouldRenderScreenSpaceReflections(const FViewInfo& View)
{
	if(!View.Family->EngineShowFlags.ScreenSpaceReflections 
		// Note: intentionally allow falling back to SSR from other reflection methods, which may be disabled by scalability
		|| View.FinalPostProcessSettings.ReflectionMethod == EReflectionMethod::None 
		|| HasRayTracedOverlay(*View.Family)
		|| View.bIsReflectionCapture)
	{
		return false;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceRayTracing.cpp:1038

Scope (from outer to inner):

file
namespace    ScreenSpaceRayTracing
function     void RenderScreenSpaceReflections

Source code excerpt:

		Desc.Flags |= GFastVRamConfig.SSR;

		DenoiserInputs->Color = GraphBuilder.CreateTexture(Desc, TEXT("ScreenSpaceReflections"));

		if (bDenoiser)
		{
			Desc.Format = PF_R16F;
			DenoiserInputs->RayHitDistance = GraphBuilder.CreateTexture(Desc, TEXT("ScreenSpaceReflectionsHitDistance"));
		}

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceRayTracing.cpp:1090

Scope (from outer to inner):

file
namespace    ScreenSpaceRayTracing
function     void RenderScreenSpaceReflections

Source code excerpt:

		ClearUnusedGraphResources(PixelShader, PassParameters);

		RDG_GPU_STAT_SCOPE(GraphBuilder, ScreenSpaceReflections);

		GraphBuilder.AddPass(
			RDG_EVENT_NAME("SSR StencilSetup %dx%d", View.ViewRect.Width(), View.ViewRect.Height()),
			PassParameters,
			ERDGPassFlags::Raster,
			[PassParameters, &View, PixelShader](FRHICommandList& RHICmdList)

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceRayTracing.cpp:1180

Scope (from outer to inner):

file
namespace    ScreenSpaceRayTracing
function     void RenderScreenSpaceReflections

Source code excerpt:

	TShaderMapRef<FScreenSpaceReflectionsPS> PixelShader(View.ShaderMap, PermutationVector);

	RDG_GPU_STAT_SCOPE(GraphBuilder, ScreenSpaceReflections);

	static const auto CVarSSRTiledCompositeVisualize = IConsoleManager::Get().FindTConsoleVariableDataBool(TEXT("r.SSR.TiledComposite.Visualize"));
	const bool bVisualizeTiledScreenSpaceReflection = CVarSSRTiledCompositeVisualize ? CVarSSRTiledCompositeVisualize->GetValueOnRenderThread() : false;

	if (TiledScreenSpaceReflection == nullptr)
	{

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SingleLayerWaterRendering.cpp:182

Scope (from outer to inner):

file
namespace    ScreenSpaceRayTracing
function     bool ShouldRenderScreenSpaceReflectionsWater

Source code excerpt:

	const bool bSSRDefault = ReflectionsMethod == ESingleLayerWaterReflections::Enabled && View.FinalPostProcessSettings.ReflectionMethod != EReflectionMethod::None;

	if (!View.Family->EngineShowFlags.ScreenSpaceReflections
		|| (!bSSROverride && !bSSRDefault)
		|| HasRayTracedOverlay(*View.Family)
		|| !View.State /*no view state(e.g.thumbnail rendering ? ), no HZB(no screen space reflections or occlusion culling)*/
		|| View.bIsReflectionCapture)
	{
		return false;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SingleLayerWaterRendering.cpp:1049

Scope: file

Source code excerpt:

				TAASettings.SceneDepthTexture = SceneTextureParameters.SceneDepthTexture;
				TAASettings.SceneVelocityTexture = SceneTextureParameters.GBufferVelocityTexture;
				TAASettings.Pass = ETAAPassConfig::ScreenSpaceReflections;
				TAASettings.SceneColorInput = DenoiserInputs.Color;
				TAASettings.bOutputRenderTargetable = true;

				FTAAOutputs TAAOutputs = AddTemporalAAPass(
					GraphBuilder,
					View,

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/TranslucentRendering.cpp:252

Scope (from outer to inner):

file
function     static bool ShouldRenderTranslucencyScreenSpaceReflections

Source code excerpt:

	// or the raytracing overlay setting. It needs to be turned on/off dynamically to support
	// diffuse only
	if (!View.Family->EngineShowFlags.ScreenSpaceReflections)
	{
		return false;
	}

	int SSRQuality = GetSSRQuality();