r.Shading.FurnaceTest.SampleCount

r.Shading.FurnaceTest.SampleCount

#Overview

name: r.Shading.FurnaceTest.SampleCount

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.Shading.FurnaceTest.SampleCount is to control the number of samples per pixel used for furnace tests in the shading system of Unreal Engine 5. This setting is specifically related to energy conservation in the rendering pipeline.

This setting variable is primarily used by the Renderer module of Unreal Engine 5, particularly in the shading and energy conservation subsystem. It’s defined and used in the ShadingEnergyConservation.cpp file, which is part of the runtime renderer.

The value of this variable is set as a console variable with a default value of 64. It can be changed at runtime through the console or configuration files.

The associated variable CVarShadingFurnaceTest_SampleCount directly interacts with r.Shading.FurnaceTest.SampleCount. They share the same value and purpose.

Developers must be aware that this variable affects the quality and performance of furnace tests in the shading system. A higher sample count will provide more accurate results but at the cost of increased computational overhead.

Best practices when using this variable include:

  1. Adjusting the value based on the specific needs of your project, balancing between quality and performance.
  2. Testing different values to find the optimal setting for your particular use case.
  3. Being mindful of performance implications when increasing the sample count, especially on lower-end hardware.

Regarding the associated variable CVarShadingFurnaceTest_SampleCount:

This is the actual console variable object that controls the sample count. It’s used internally by the engine to retrieve and apply the setting. The variable is defined as a TAutoConsoleVariable, which means it’s an integer value that can be changed at runtime.

The value of CVarShadingFurnaceTest_SampleCount is used in the AddShadingFurnacePass function to set the NumSamplesPerSet parameter. It’s important to note that the value is clamped between 16 and 2048, ensuring that it stays within a reasonable range for performance and quality considerations.

When working with this variable, developers should:

  1. Use the GetValueOnAnyThread() method to retrieve its current value safely from any thread.
  2. Be aware of the clamping behavior when setting extreme values.
  3. Consider the impact on the shading furnace pass when modifying this value, as it directly affects the number of samples processed.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadingEnergyConservation.cpp:35

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarShadingFurnaceTest_SampleCount(
	TEXT("r.Shading.FurnaceTest.SampleCount"),
	64,
	TEXT("Number of sampler per pixel used for furnace tests."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarShadingFurnaceTest_TableFormat(
	TEXT("r.Shading.EnergyConservation.Format"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadingEnergyConservation.cpp:34

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarShadingFurnaceTest_SampleCount(
	TEXT("r.Shading.FurnaceTest.SampleCount"),
	64,
	TEXT("Number of sampler per pixel used for furnace tests."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarShadingFurnaceTest_TableFormat(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadingEnergyConservation.cpp:142

Scope (from outer to inner):

file
function     static void AddShadingFurnacePass

Source code excerpt:

	Parameters->ViewUniformBuffer				= View.ViewUniformBuffer;
	Parameters->SceneTexturesStruct				= SceneTexturesUniformBuffer;
	Parameters->NumSamplesPerSet				= FMath::Clamp(CVarShadingFurnaceTest_SampleCount.GetValueOnAnyThread(), 16, 2048);
	Parameters->RenderTargets[0]				= FRenderTargetBinding(OutTexture, ERenderTargetLoadAction::ELoad);
	if (Substrate::IsSubstrateEnabled())
	{
		Parameters->Substrate = Substrate::BindSubstrateGlobalUniformParameters(View);
	}