r.Shadow.Denoiser.ReconstructionSamples
r.Shadow.Denoiser.ReconstructionSamples
#Overview
name: r.Shadow.Denoiser.ReconstructionSamples
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Maximum number of samples for the reconstruction pass (default = 16).
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.Denoiser.ReconstructionSamples is to control the maximum number of samples used in the reconstruction pass of the shadow denoiser in Unreal Engine 5’s rendering system.
This setting variable is primarily used by the rendering subsystem, specifically in the screen space denoising module. It’s part of the shadow denoising process, which aims to improve the quality of shadows while maintaining performance.
The value of this variable is set through a console variable (CVar) named CVarShadowReconstructionSampleCount. It’s defined with a default value of 8, but the comment suggests a default of 16. This discrepancy might be worth noting.
The associated variable CVarShadowReconstructionSampleCount directly interacts with r.Shadow.Denoiser.ReconstructionSamples. They essentially represent the same setting, with the CVar being the C++ representation used in the engine code.
Developers should be aware that this variable affects the quality and performance trade-off in shadow rendering. A higher value will likely result in better shadow quality but may impact performance.
Best practices when using this variable include:
- Experimenting with different values to find the optimal balance between shadow quality and performance for your specific project.
- Considering the target hardware when setting this value, as higher-end systems may be able to handle more samples.
- Using this in conjunction with other shadow and denoising settings for best results.
Regarding the associated variable CVarShadowReconstructionSampleCount:
- It’s the C++ representation of the r.Shadow.Denoiser.ReconstructionSamples setting.
- It’s used directly in the FDefaultScreenSpaceDenoiser class, specifically in the DenoiseShadowVisibilityMasks function.
- The value is clamped between 1 and kStackowiakMaxSampleCountPerSet when used, ensuring it stays within a valid range.
- It’s retrieved using GetValueOnRenderThread(), indicating that it’s safe to access from the render thread.
Developers should note that changes to this CVar will directly affect the shadow denoising process, and it’s important to test thoroughly when modifying its value to ensure desired visual results and performance.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceDenoise.cpp:23
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarShadowReconstructionSampleCount(
TEXT("r.Shadow.Denoiser.ReconstructionSamples"), 8,
TEXT("Maximum number of samples for the reconstruction pass (default = 16)."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarShadowPreConvolutionCount(
TEXT("r.Shadow.Denoiser.PreConvolution"), 1,
TEXT("Number of pre-convolution passes (default = 1)."),
#Associated Variable and Callsites
This variable is associated with another variable named CVarShadowReconstructionSampleCount
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceDenoise.cpp:22
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarShadowReconstructionSampleCount(
TEXT("r.Shadow.Denoiser.ReconstructionSamples"), 8,
TEXT("Maximum number of samples for the reconstruction pass (default = 16)."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarShadowPreConvolutionCount(
TEXT("r.Shadow.Denoiser.PreConvolution"), 1,
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceDenoise.cpp:2264
Scope (from outer to inner):
file
class class FDefaultScreenSpaceDenoiser : public IScreenSpaceDenoiser
function virtual void DenoiseShadowVisibilityMasks
Source code excerpt:
Settings.SignalProcessing = ESignalProcessing::ShadowVisibilityMask;
Settings.InputResolutionFraction = 1.0f;
Settings.ReconstructionSamples = FMath::Clamp(CVarShadowReconstructionSampleCount.GetValueOnRenderThread(), 1, kStackowiakMaxSampleCountPerSet);
Settings.PreConvolutionCount = CVarShadowPreConvolutionCount.GetValueOnRenderThread();
Settings.bUseTemporalAccumulation = CVarShadowTemporalAccumulation.GetValueOnRenderThread() != 0;
Settings.HistoryConvolutionSampleCount = CVarShadowHistoryConvolutionSampleCount.GetValueOnRenderThread();
Settings.SignalBatchSize = InputParameterCount;
for (int32 BatchedSignalId = 0; BatchedSignalId < InputParameterCount; BatchedSignalId++)