r.Shadow.Denoiser
r.Shadow.Denoiser
#Overview
name: r.Shadow.Denoiser
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Choose the denoising algorithm.\n 0: Disabled (default);\n 1: Forces the default denoiser of the renderer;\n 2: GScreenSpaceDenoiser witch may be overriden by a third party plugin.\n
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.Denoiser is to control the shadow denoising algorithm used in the Unreal Engine 5 rendering system. This setting variable allows developers to choose between different denoising options for shadows, which can significantly impact the visual quality and performance of shadow rendering in a game or application.
This setting variable is primarily used by the Renderer subsystem of Unreal Engine 5, specifically within the light rendering and shadow processing components.
The value of this variable is set through a console variable (CVarShadowUseDenoiser) in the LightRendering.cpp file. It has three possible values: 0: Disabled (default) 1: Forces the default denoiser of the renderer 2: Uses GScreenSpaceDenoiser, which may be overridden by a third-party plugin
The associated variable CVarShadowUseDenoiser directly interacts with r.Shadow.Denoiser. They share the same value and purpose.
Developers must be aware that changing this variable can affect both the visual quality of shadows and the performance of the rendering system. The choice of denoiser can impact the balance between shadow quality and rendering speed.
Best practices when using this variable include:
- Testing different modes to find the best balance between visual quality and performance for your specific project.
- Considering the target hardware when choosing a denoising mode, as more complex denoising algorithms may be more demanding on less powerful systems.
- If using mode 2, be aware of any third-party plugins that might override the GScreenSpaceDenoiser, as this could affect the behavior of the denoising system.
- Documenting the chosen setting in your project to ensure consistency across the development team.
Regarding the associated variable CVarShadowUseDenoiser:
The purpose of CVarShadowUseDenoiser is to provide a programmatic way to access and modify the r.Shadow.Denoiser setting within the C++ code of the engine.
This variable is used within the Renderer subsystem, specifically in the light rendering process.
The value of CVarShadowUseDenoiser is set and accessed using the TAutoConsoleVariable template, which allows it to be changed at runtime through console commands.
CVarShadowUseDenoiser directly interacts with the r.Shadow.Denoiser setting, effectively serving as its C++ representation within the engine code.
Developers should be aware that changes to CVarShadowUseDenoiser will directly affect the shadow denoising behavior of the engine. It’s important to use this variable consistently with the r.Shadow.Denoiser console command to avoid confusion.
Best practices for using CVarShadowUseDenoiser include:
- Using GetValueOnRenderThread() to safely access its value in render thread code.
- Consider caching the value if it’s accessed frequently to avoid potential performance overhead from repeated console variable lookups.
- Be cautious when modifying this variable during runtime, as it can have immediate effects on rendering performance and quality.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightRendering.cpp:86
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarShadowUseDenoiser(
TEXT("r.Shadow.Denoiser"),
2,
TEXT("Choose the denoising algorithm.\n")
TEXT(" 0: Disabled (default);\n")
TEXT(" 1: Forces the default denoiser of the renderer;\n")
TEXT(" 2: GScreenSpaceDenoiser witch may be overriden by a third party plugin.\n"),
ECVF_RenderThreadSafe);
#Associated Variable and Callsites
This variable is associated with another variable named CVarShadowUseDenoiser
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightRendering.cpp:85
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarShadowUseDenoiser(
TEXT("r.Shadow.Denoiser"),
2,
TEXT("Choose the denoising algorithm.\n")
TEXT(" 0: Disabled (default);\n")
TEXT(" 1: Forces the default denoiser of the renderer;\n")
TEXT(" 2: GScreenSpaceDenoiser witch may be overriden by a third party plugin.\n"),
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightRendering.cpp:1495
Scope (from outer to inner):
file
function void FDeferredShadingSceneRenderer::RenderLights
Source code excerpt:
RDG_EVENT_SCOPE(GraphBuilder, "UnbatchedLights");
const int32 DenoiserMode = CVarShadowUseDenoiser.GetValueOnRenderThread();
const IScreenSpaceDenoiser* DefaultDenoiser = IScreenSpaceDenoiser::GetDefaultDenoiser();
const IScreenSpaceDenoiser* DenoiserToUse = DenoiserMode == 1 ? DefaultDenoiser : GScreenSpaceDenoiser;
TArray<FRDGTextureRef, SceneRenderingAllocator> PreprocessedShadowMaskTextures;
TArray<FRDGTextureRef, SceneRenderingAllocator> PreprocessedShadowMaskSubPixelTextures;