r.StencilLODMode

r.StencilLODMode

#Overview

name: r.StencilLODMode

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.StencilLODMode is to specify the dither LOD stencil mode in the rendering system of Unreal Engine 5. This setting variable is primarily used for controlling the method of applying level of detail (LOD) transitions using stencil operations.

This setting variable is primarily utilized by the Renderer module of Unreal Engine, specifically within the depth rendering subsystem. It’s referenced in the DepthRendering.cpp file, which is part of the core rendering pipeline.

The value of this variable is set through a console variable (CVarStencilLODDitherMode) with a default value of 2. It can be changed at runtime through console commands or programmatically.

The r.StencilLODMode variable interacts directly with its associated variable CVarStencilLODDitherMode. They share the same value and purpose.

Developers must be aware that this variable affects the performance and visual quality of LOD transitions in the rendered scene. The chosen mode (0, 1, or 2) determines whether the stencil LOD dithering is performed in a graphics pass, a compute pass, or an asynchronous compute pass, respectively.

Best practices when using this variable include:

  1. Consider the target hardware capabilities when choosing a mode.
  2. Use mode 2 (async compute) for best performance on supported platforms.
  3. Fall back to mode 0 (graphics pass) for wider compatibility if issues arise.

Regarding the associated variable CVarStencilLODDitherMode:

The purpose of CVarStencilLODDitherMode is to provide a console-accessible interface for the r.StencilLODMode setting. It allows runtime modification of the stencil LOD dithering mode.

This variable is used within the Renderer module, specifically in the depth rendering pass preparation.

The value of CVarStencilLODDitherMode is set upon initialization with a default of 2, but can be changed at runtime via console commands.

CVarStencilLODDitherMode directly interacts with r.StencilLODMode, as they represent the same setting.

Developers should be aware that changes to this variable will immediately affect the rendering pipeline’s behavior regarding LOD transitions.

Best practices for using CVarStencilLODDitherMode include:

  1. Use it for debugging or performance testing different LOD dithering modes.
  2. Be cautious when changing its value in a shipping build, as it may affect performance or visual quality.
  3. Consider exposing it as a user-configurable setting if LOD transition quality is crucial for your game’s visual style or performance profile.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DepthRendering.cpp:58

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarStencilLODDitherMode(
	TEXT("r.StencilLODMode"),
	2,
	TEXT("Specifies the dither LOD stencil mode.\n")
	TEXT(" 0: Graphics pass.\n")
	TEXT(" 1: Compute pass (on supported platforms).\n")
	TEXT(" 2: Compute async pass (on supported platforms)."),
	ECVF_RenderThreadSafe);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DepthRendering.cpp:57

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarStencilLODDitherMode(
	TEXT("r.StencilLODMode"),
	2,
	TEXT("Specifies the dither LOD stencil mode.\n")
	TEXT(" 0: Graphics pass.\n")
	TEXT(" 1: Compute pass (on supported platforms).\n")
	TEXT(" 2: Compute async pass (on supported platforms)."),

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DepthRendering.cpp:104

Scope (from outer to inner):

file
function     FDepthPassInfo GetDepthPassInfo

Source code excerpt:

	if (GRHISupportsDepthUAV && !IsHMDHiddenAreaMaskActive())
	{
		switch (CVarStencilLODDitherMode.GetValueOnAnyThread())
		{
		case 1:
			Info.StencilDitherPassFlags = ERDGPassFlags::Compute;
			break;
		case 2:
			Info.StencilDitherPassFlags = ERDGPassFlags::AsyncCompute;