r.SSR.Stencil

r.SSR.Stencil

#Overview

name: r.SSR.Stencil

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.SSR.Stencil is to control whether a stencil prepass is used for screen space reflections (SSR) in Unreal Engine’s rendering system. This setting variable is part of the screen space reflection rendering pipeline.

The Unreal Engine subsystem that relies on this setting variable is the Renderer module, specifically the screen space ray tracing component. This can be seen from the file path “Engine/Source/Runtime/Renderer/Private/ScreenSpaceRayTracing.cpp” where the variable is defined and used.

The value of this variable is set through the console variable system in Unreal Engine. It’s defined as a TAutoConsoleVariable with a default value of 0 (off). Users can change this value at runtime through the console or configuration files.

The associated variable CVarSSRStencil directly interacts with r.SSR.Stencil. They share the same value and purpose. CVarSSRStencil is the C++ representation of the console variable r.SSR.Stencil.

Developers must be aware that:

  1. This variable is a boolean flag (0 for off, 1 for on).
  2. It affects the performance and quality of screen space reflections.
  3. It’s render thread safe, meaning it can be changed during runtime without causing threading issues.

Best practices when using this variable include:

  1. Consider the performance implications of enabling the stencil prepass for SSR.
  2. Test the visual quality difference between having it on and off for your specific use case.
  3. Be cautious when changing this value at runtime, as it may affect frame rate.

Regarding the associated variable CVarSSRStencil:

When working with CVarSSRStencil, developers should follow the same best practices as with r.SSR.Stencil, ensuring that any changes are thoroughly tested for both performance and visual quality impacts.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarSSRStencil(
	TEXT("r.SSR.Stencil"),
	0,
	TEXT("Defines if we use the stencil prepass for the screen space reflection\n")
	TEXT(" 0 is off (default), 1 is on"),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarSSGILeakFreeReprojection(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarSSRStencil(
	TEXT("r.SSR.Stencil"),
	0,
	TEXT("Defines if we use the stencil prepass for the screen space reflection\n")
	TEXT(" 0 is off (default), 1 is on"),
	ECVF_RenderThreadSafe);

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

Scope (from outer to inner):

file
namespace    ScreenSpaceRayTracing
function     void RenderScreenSpaceReflections

Source code excerpt:

	}

	const bool SSRStencilPrePass = CVarSSRStencil.GetValueOnRenderThread() != 0 && SSRQuality != ESSRQuality::VisualizeSSR && TiledScreenSpaceReflection == nullptr;
	
	// Alloc inputs for denoising.
	{
		FRDGTextureDesc Desc = FRDGTextureDesc::Create2D(
			View.GetSceneTexturesConfig().Extent,
			PF_FloatRGBA, FClearValueBinding(FLinearColor(0, 0, 0, 0)),