r.AmbientOcclusion.Denoiser

r.AmbientOcclusion.Denoiser

#Overview

name: r.AmbientOcclusion.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.AmbientOcclusion.Denoiser is to control the denoising algorithm used for ambient occlusion in Unreal Engine’s rendering system. It allows developers to choose between different denoising options for improving the visual quality of ambient occlusion effects.

This setting variable is primarily used in the Renderer module of Unreal Engine, specifically within the ray tracing subsystem for ambient occlusion. It’s referenced in the RayTracingAmbientOcclusion.cpp file, which suggests it’s closely tied to the ray-traced ambient occlusion feature.

The value of this variable is set through a console variable (CVar) system, which allows it to be changed at runtime. It’s defined with a default value of 2, but can be modified through console commands or project settings.

The variable interacts with the GScreenSpaceDenoiser, which is likely a global denoiser object used across the rendering system. It also interacts with the default denoiser of the renderer.

Developers should be aware that this variable offers three options: 0: Disables the denoiser 1: Forces the use of the default denoiser of the renderer 2: Uses GScreenSpaceDenoiser, which can be overridden by third-party plugins (default option)

Best practices when using this variable include:

  1. Understanding the performance implications of each option
  2. Testing the visual quality difference between options in various scenarios
  3. Considering the compatibility with any third-party denoising plugins when using option 2

Regarding the associated variable CVarUseAODenoiser:

The purpose of CVarUseAODenoiser is to serve as the actual console variable that stores and manages the r.AmbientOcclusion.Denoiser setting. It’s an implementation detail of how Unreal Engine manages console variables internally.

This variable is used directly in the code to retrieve the current denoiser mode and apply the appropriate denoising algorithm. It’s accessed using the GetValueOnRenderThread() method, ensuring thread-safe access to the variable’s value.

Developers should be aware that while they interact with r.AmbientOcclusion.Denoiser through console commands or project settings, the actual logic in the code uses CVarUseAODenoiser. Any changes to r.AmbientOcclusion.Denoiser will be reflected in CVarUseAODenoiser.

Best practices for CVarUseAODenoiser include:

  1. Avoiding direct manipulation of this variable in code; instead, use the r.AmbientOcclusion.Denoiser console command or project settings
  2. Being aware of its existence when debugging or profiling ambient occlusion denoising performance

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingAmbientOcclusion.cpp:32

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarUseAODenoiser(
	TEXT("r.AmbientOcclusion.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 witch may be overriden by a third party plugin (default)."),
	ECVF_RenderThreadSafe);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingAmbientOcclusion.cpp:31

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarUseAODenoiser(
	TEXT("r.AmbientOcclusion.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 witch may be overriden by a third party plugin (default)."),

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingAmbientOcclusion.cpp:213

Scope: file

Source code excerpt:

	});

	int32 DenoiserMode = CVarUseAODenoiser.GetValueOnRenderThread();
	if (DenoiserMode != 0)
	{
		const IScreenSpaceDenoiser* DefaultDenoiser = IScreenSpaceDenoiser::GetDefaultDenoiser();
		const IScreenSpaceDenoiser* DenoiserToUse = DenoiserMode == 1 ? DefaultDenoiser : GScreenSpaceDenoiser;

		RDG_EVENT_SCOPE(GraphBuilder, "%s%s(AmbientOcclusion) %dx%d",