r.Reflections.Denoiser

r.Reflections.Denoiser

#Overview

name: r.Reflections.Denoiser

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.Reflections.Denoiser is to control the denoising algorithm used for reflections in the rendering system. This setting variable allows developers to choose between different denoising options for screen space reflections.

This setting variable is primarily used in the Renderer module of Unreal Engine, specifically in the screen space denoising subsystem. It’s referenced in the ScreenSpaceDenoise.cpp file, which suggests it’s an integral part of the engine’s reflection denoising process.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 2, but can be changed at runtime or through configuration files.

The r.Reflections.Denoiser variable interacts directly with its associated variable CVarUseReflectionDenoiser. They share the same value and are used interchangeably in the code.

Developers must be aware that this variable has three possible settings: 0: Disabled (no denoising) 1: Forces the default denoiser of the renderer 2: Uses GScreenSpaceDenoiser, which can be overridden by a third-party plugin (default setting)

Best practices when using this variable include:

  1. Understanding the performance implications of each setting.
  2. Testing thoroughly when changing from the default setting, especially in a shipping game.
  3. Being aware that setting 2 allows for potential third-party plugin integration, which may affect consistency across different development environments.

Regarding the associated variable CVarUseReflectionDenoiser:

The purpose of CVarUseReflectionDenoiser is to provide a programmatic way to access and modify the r.Reflections.Denoiser setting within the C++ code of the engine.

This variable is used in the Renderer module, specifically in the GetReflectionsDenoiserMode() function, which suggests it’s used to retrieve the current denoiser mode in various parts of the rendering code.

The value of CVarUseReflectionDenoiser is set through the CVar system, mirroring r.Reflections.Denoiser.

CVarUseReflectionDenoiser interacts directly with r.Reflections.Denoiser, sharing the same value and purpose.

Developers should be aware that changes to CVarUseReflectionDenoiser will affect the reflection denoising behavior of the engine. It’s important to use the appropriate thread-safe methods (like GetValueOnRenderThread()) when accessing this variable to avoid race conditions.

Best practices for using CVarUseReflectionDenoiser include:

  1. Using it consistently throughout the codebase when needing to check or modify the reflection denoiser mode.
  2. Being mindful of the render thread when accessing or modifying this variable.
  3. Considering the implications on third-party plugins or custom rendering code when changing this value.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceDenoise.cpp:43

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarUseReflectionDenoiser(
	TEXT("r.Reflections.Denoiser"),
	2,
	TEXT("Choose the denoising algorithm.\n")
	TEXT(" 0: Disabled;\n")
	TEXT(" 1: Forces the default denoiser of the renderer;\n")
	TEXT(" 2: GScreenSpaceDenoiser which may be overriden by a third party plugin (default)."),
	ECVF_RenderThreadSafe);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceDenoise.cpp:42

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarUseReflectionDenoiser(
	TEXT("r.Reflections.Denoiser"),
	2,
	TEXT("Choose the denoising algorithm.\n")
	TEXT(" 0: Disabled;\n")
	TEXT(" 1: Forces the default denoiser of the renderer;\n")
	TEXT(" 2: GScreenSpaceDenoiser which may be overriden by a third party plugin (default)."),

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceDenoise.cpp:2904

Scope (from outer to inner):

file
function     int GetReflectionsDenoiserMode

Source code excerpt:

int GetReflectionsDenoiserMode()
{
	return CVarUseReflectionDenoiser.GetValueOnRenderThread();
}

// static
IScreenSpaceDenoiser::EMode IScreenSpaceDenoiser::GetDenoiserMode(const TAutoConsoleVariable<int32>& CVar)
{
	int32 CVarSettings = CVar.GetValueOnRenderThread();