r.SSR.HalfResSceneColor

r.SSR.HalfResSceneColor

#Overview

name: r.SSR.HalfResSceneColor

The value of this variable can be defined or overridden in .ini config files. 5 .ini config files referencing this setting variable.

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

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.SSR.HalfResSceneColor is to enable the use of half resolution scene color as input for Screen Space Reflections (SSR). This setting is intended to improve performance without significantly impacting visual quality.

The r.SSR.HalfResSceneColor variable is primarily used in the rendering system, specifically in the Screen Space Reflections subsystem. It’s part of the post-processing pipeline and affects how reflections are calculated and rendered.

The value of this variable is set through the console variable system. It’s defined as an integer (int32) and initialized to 0, which means it’s disabled by default. It can be enabled by setting it to 1 through the console or configuration files.

This variable interacts closely with the SSR (Screen Space Reflections) system. When enabled, it affects:

  1. The input texture used for SSR calculations (using half-res instead of full-res scene color).
  2. The sampling method used when reading the scene color (bilinear vs point sampling).
  3. The storage and retrieval of half-res scene color in the view state history.

Developers should be aware that:

  1. Enabling this option can improve performance, especially on lower-end hardware or in performance-critical scenarios.
  2. There might be a slight loss in reflection quality, which may or may not be noticeable depending on the scene.
  3. It interacts with other SSR settings and the temporal anti-aliasing system.

Best practices when using this variable include:

  1. Testing the visual impact in various scenarios before enabling it globally.
  2. Considering it as part of a broader performance optimization strategy, alongside other SSR and rendering settings.
  3. Potentially exposing it as a user-configurable graphics option for players to balance performance and quality.

The associated variable GSSRHalfResSceneColor is the internal representation of this setting. It’s used throughout the codebase to check if the half-res scene color option is enabled. This variable directly reflects the value set for r.SSR.HalfResSceneColor.

When working with GSSRHalfResSceneColor, developers should:

  1. Use it for conditional logic in SSR-related code paths.
  2. Be aware that it affects texture sampling methods and buffer allocations.
  3. Consider its impact on other systems that might rely on full-resolution scene color for their calculations.

Overall, both r.SSR.HalfResSceneColor and GSSRHalfResSceneColor provide a way to trade off some reflection quality for improved performance in the screen space reflections system.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseScalability.ini:346, section: [ReflectionQuality@0]

Location: <Workspace>/Engine/Config/BaseScalability.ini:351, section: [ReflectionQuality@1]

Location: <Workspace>/Engine/Config/BaseScalability.ini:356, section: [ReflectionQuality@2]

Location: <Workspace>/Engine/Config/BaseScalability.ini:366, section: [ReflectionQuality@3]

Location: <Workspace>/Engine/Config/BaseScalability.ini:376, section: [ReflectionQuality@Cine]

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

int32 GSSRHalfResSceneColor = 0;
FAutoConsoleVariableRef CVarSSRHalfResSceneColor(
	TEXT("r.SSR.HalfResSceneColor"),
	GSSRHalfResSceneColor,
	TEXT("Use half res scene color as input for SSR. Improves performance without much of a visual quality loss."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarSSRTemporal(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessing.cpp:682

Scope (from outer to inner):

file
function     void AddPostProcessingPasses

Source code excerpt:

			(bLensFlareEnabled && bFFTBloomEnabled) ||
			bLocalExposureBlurredLum);
		extern int32 GSSRHalfResSceneColor;
		const bool bNeedBeforeBloomHalfRes    = (!bProcessQuarterResolution && !bProcessEighthResolution) || (bFFTBloomEnabled && FFTBloomResolutionFraction > 0.25f && FFTBloomResolutionFraction <= 0.5f) || (ReflectionsMethod == EReflectionsMethod::SSR && !View.bStatePrevViewInfoIsReadOnly && GSSRHalfResSceneColor);
		const bool bNeedBeforeBloomQuarterRes = bProcessQuarterResolution || (bFFTBloomEnabled && FFTBloomResolutionFraction > 0.125f && FFTBloomResolutionFraction <= 0.25f);
		const bool bNeedBeforeBloomEighthRes  = bProcessEighthResolution || (bFFTBloomEnabled && FFTBloomResolutionFraction <= 0.125f);


		const FPostProcessMaterialChain MaterialChainSceneColorBeforeDOF = GetPostProcessMaterialChain(View, BL_SceneColorBeforeDOF);
		const FPostProcessMaterialChain MaterialChainSceneColorAfterDOF = GetPostProcessMaterialChain(View, BL_SceneColorAfterDOF);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessing.cpp:1029

Scope (from outer to inner):

file
function     void AddPostProcessingPasses

Source code excerpt:


		// Store half res scene color in the history
		if (ReflectionsMethod == EReflectionsMethod::SSR && !View.bStatePrevViewInfoIsReadOnly && GSSRHalfResSceneColor && HalfResSceneColor.IsValid())
		{
			check(View.ViewState);
			GraphBuilder.QueueTextureExtraction(HalfResSceneColor.TextureSRV->Desc.Texture, &View.ViewState->PrevFrameViewInfo.HalfResTemporalAAHistory);
		}

		{

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

Scope: file

Source code excerpt:

	ECVF_Scalability | ECVF_RenderThreadSafe);

int32 GSSRHalfResSceneColor = 0;
FAutoConsoleVariableRef CVarSSRHalfResSceneColor(
	TEXT("r.SSR.HalfResSceneColor"),
	GSSRHalfResSceneColor,
	TEXT("Use half res scene color as input for SSR. Improves performance without much of a visual quality loss."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarSSRTemporal(
	TEXT("r.SSR.Temporal"),

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

Scope (from outer to inner):

file
namespace    ScreenSpaceRayTracing
function     void RenderScreenSpaceReflections

Source code excerpt:

				GraphBuilder.RegisterExternalTexture(View.PrevViewInfo.CustomSSRInput.RT[0])));
		}
		else if (GSSRHalfResSceneColor && View.PrevViewInfo.HalfResTemporalAAHistory.IsValid())
		{
			FRDGTextureRef HalfResTemporalAAHistory = GraphBuilder.RegisterExternalTexture(View.PrevViewInfo.HalfResTemporalAAHistory);

			if (HalfResTemporalAAHistory->Desc.Dimension == ETextureDimension::Texture2DArray)
			{
				InputColor = GraphBuilder.CreateSRV(FRDGTextureSRVDesc::CreateForSlice(HalfResTemporalAAHistory, /* SliceIndex = */ 0));

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

Scope (from outer to inner):

file
namespace    ScreenSpaceRayTracing
function     void RenderScreenSpaceReflections
lambda-function

Source code excerpt:

		
		PassParameters->SceneColor = InputColor;
		PassParameters->SceneColorSampler = GSSRHalfResSceneColor ? TStaticSamplerState<SF_Bilinear>::GetRHI() : TStaticSamplerState<SF_Point>::GetRHI();
		
		PassParameters->HZB = View.HZB;
		PassParameters->HZBSampler = TStaticSamplerState<SF_Point>::GetRHI();
	};

	FScreenSpaceReflectionsPS::FPermutationDomain PermutationVector;