r.DiffuseIndirect.HalfRes

r.DiffuseIndirect.HalfRes

#Overview

name: r.DiffuseIndirect.HalfRes

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.DiffuseIndirect.HalfRes is to control the resolution of diffuse indirect lighting calculations in the rendering system of Unreal Engine 5. This setting variable is primarily used in the indirect lighting rendering subsystem.

Based on the callsites provided, this setting variable is utilized in the Renderer module, specifically within the indirect light rendering component. The main file referencing this variable is IndirectLightRendering.cpp, which suggests it’s a core part of the engine’s lighting calculations.

The value of this variable is set as a console variable using TAutoConsoleVariable, with a default value of 1. This means it can be changed at runtime through console commands or configuration files.

The associated variable CVarDiffuseIndirectHalfRes directly interacts with r.DiffuseIndirect.HalfRes. They share the same value and are used interchangeably in the code.

Developers should be aware that this variable affects the performance and quality trade-off in indirect lighting calculations. When set to 1 (default), it enables half-resolution rendering for diffuse indirect lighting, which can improve performance at the cost of some visual quality.

Best practices when using this variable include:

  1. Testing different values to find the optimal balance between performance and visual quality for your specific project.
  2. Considering the target hardware when adjusting this setting, as lower-end devices may benefit more from the performance boost of half-resolution rendering.
  3. Using it in conjunction with other lighting-related settings to achieve the desired visual results and performance.

Regarding the associated variable CVarDiffuseIndirectHalfRes:

The purpose of CVarDiffuseIndirectHalfRes is to provide a programmatic way to access and modify the r.DiffuseIndirect.HalfRes setting within the C++ code of the engine.

This variable is used in the Renderer module, specifically in the indirect lighting calculations. It’s primarily used in the FDeferredShadingSceneRenderer::SetupCommonDiffuseIndirectParameters function.

The value of CVarDiffuseIndirectHalfRes is set when the r.DiffuseIndirect.HalfRes console variable is initialized. It can be accessed and modified at runtime using the GetValueOnRenderThread() method.

CVarDiffuseIndirectHalfRes interacts directly with the r.DiffuseIndirect.HalfRes setting, serving as its in-code representation.

Developers should be aware that changes to CVarDiffuseIndirectHalfRes will affect the rendering resolution of diffuse indirect lighting. When its value is 1 (true), it enables half-resolution rendering, which can improve performance but may slightly reduce visual quality.

Best practices for using CVarDiffuseIndirectHalfRes include:

  1. Using GetValueOnRenderThread() to safely access its value in render thread code.
  2. Considering the performance implications when modifying this value dynamically during runtime.
  3. Coordinating changes to this variable with other related rendering settings to maintain consistent visual quality and performance.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/IndirectLightRendering.cpp:53

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarDiffuseIndirectHalfRes(
	TEXT("r.DiffuseIndirect.HalfRes"), 1,
	TEXT("TODO(Guillaume)"),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarDiffuseIndirectRayPerPixel(
	TEXT("r.DiffuseIndirect.RayPerPixel"), 6, // TODO(Guillaume): Matches old Lumen hard code sampling pattern.
	TEXT("TODO(Guillaume)"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/IndirectLightRendering.cpp:52

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarDiffuseIndirectHalfRes(
	TEXT("r.DiffuseIndirect.HalfRes"), 1,
	TEXT("TODO(Guillaume)"),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarDiffuseIndirectRayPerPixel(
	TEXT("r.DiffuseIndirect.RayPerPixel"), 6, // TODO(Guillaume): Matches old Lumen hard code sampling pattern.

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/IndirectLightRendering.cpp:787

Scope (from outer to inner):

file
function     void FDeferredShadingSceneRenderer::SetupCommonDiffuseIndirectParameters

Source code excerpt:

	const FPerViewPipelineState& ViewPipelineState = GetViewPipelineState(View);

	int32 DownscaleFactor = CVarDiffuseIndirectHalfRes.GetValueOnRenderThread() ? 2 : 1;

	int32 RayCountPerPixel = FMath::Clamp(
		int32(CVarDiffuseIndirectRayPerPixel.GetValueOnRenderThread()),
		1, HybridIndirectLighting::kMaxRayPerPixel);

	if (ViewPipelineState.DiffuseIndirectMethod == EDiffuseIndirectMethod::SSGI)