r.PostProcessAllowStencilTest

r.PostProcessAllowStencilTest

#Overview

name: r.PostProcessAllowStencilTest

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.PostProcessAllowStencilTest is to control whether stencil testing is enabled in post-process materials within the Unreal Engine rendering system.

This setting variable is primarily used by the Renderer module of Unreal Engine, specifically in the post-processing pipeline. It’s defined and used in the PostProcessMaterial.cpp file, which suggests it’s closely tied to the post-process material system.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1, meaning stencil testing is allowed by default. Developers can change this value at runtime using console commands or through code.

The associated variable CVarPostProcessAllowStencilTest directly interacts with r.PostProcessAllowStencilTest. They share the same value and purpose. CVarPostProcessAllowStencilTest is used in the IsPostProcessStencilTestAllowed() function to determine if stencil testing should be performed.

Developers must be aware that this variable affects the rendering performance and visual output of post-process materials. Disabling stencil testing (by setting the value to 0) might improve performance but could affect certain visual effects that rely on stencil testing.

Best practices when using this variable include:

  1. Keep it enabled (value 1) unless there’s a specific reason to disable it.
  2. Profile your game’s performance with and without stencil testing to understand its impact.
  3. If disabling, thoroughly test all post-process materials to ensure they still work as intended.

Regarding CVarPostProcessAllowStencilTest: This is the actual C++ variable that controls the behavior. It’s an instance of TAutoConsoleVariable, which means it can be modified at runtime through console commands. The IsPostProcessStencilTestAllowed() function uses this variable to determine if stencil testing should be performed in the rendering pipeline. Developers should use this function when they need to check if stencil testing is allowed in their rendering code, rather than accessing the CVar directly.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessMaterial.cpp:33

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


TAutoConsoleVariable<int32> CVarPostProcessAllowStencilTest(
	TEXT("r.PostProcessAllowStencilTest"),
	1,
	TEXT("Enables stencil testing in post process materials.\n")
	TEXT("0: disable stencil testing\n")
	TEXT("1: allow stencil testing\n")
	);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessMaterial.cpp:32

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

{

TAutoConsoleVariable<int32> CVarPostProcessAllowStencilTest(
	TEXT("r.PostProcessAllowStencilTest"),
	1,
	TEXT("Enables stencil testing in post process materials.\n")
	TEXT("0: disable stencil testing\n")
	TEXT("1: allow stencil testing\n")
	);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessMaterial.cpp:56

Scope (from outer to inner):

file
namespace    anonymous
function     static bool IsPostProcessStencilTestAllowed

Source code excerpt:

static bool IsPostProcessStencilTestAllowed()
{
	return CVarPostProcessAllowStencilTest.GetValueOnRenderThread() != 0;
}

enum class EMaterialCustomDepthPolicy : uint32
{
	// Custom depth is disabled.
	Disabled,