r.SSR.Stencil
r.SSR.Stencil
#Overview
name: r.SSR.Stencil
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Defines if we use the stencil prepass for the screen space reflection\n 0 is off (default), 1 is on
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:
- This variable is a boolean flag (0 for off, 1 for on).
- It affects the performance and quality of screen space reflections.
- It’s render thread safe, meaning it can be changed during runtime without causing threading issues.
Best practices when using this variable include:
- Consider the performance implications of enabling the stencil prepass for SSR.
- Test the visual quality difference between having it on and off for your specific use case.
- Be cautious when changing this value at runtime, as it may affect frame rate.
Regarding the associated variable CVarSSRStencil:
- Its purpose is identical to r.SSR.Stencil, serving as the C++ interface for the console variable.
- It’s used within the ScreenSpaceRayTracing namespace to determine whether to use the stencil prepass for SSR.
- The value is accessed using GetValueOnRenderThread() to ensure thread-safe access.
- It’s checked in the RenderScreenSpaceReflections function to determine the SSR rendering approach.
- Developers should be aware that this variable is used in conjunction with other conditions (like SSRQuality and TiledScreenSpaceReflection) to determine the final SSR rendering method.
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)),