r.AmbientOcclusion.Denoiser.KernelSpreadFactor
r.AmbientOcclusion.Denoiser.KernelSpreadFactor
#Overview
name: r.AmbientOcclusion.Denoiser.KernelSpreadFactor
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Spread factor of the preconvolution passes.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.AmbientOcclusion.Denoiser.KernelSpreadFactor is to control the spread factor of the preconvolution passes in the Ambient Occlusion (AO) denoising process. This setting variable is primarily used in the rendering system, specifically for improving the quality of ambient occlusion effects.
Based on the details in the Callsites section, this setting variable is used in the Renderer module of Unreal Engine, particularly in the screen space denoising subsystem. It’s part of the post-processing pipeline that handles ambient occlusion effects.
The value of this variable is set as a console variable (CVar) with a default value of 4. It can be modified at runtime through the console or through engine configuration files.
This variable interacts closely with other AO denoising settings, such as CVarAOReconstructionSampleCount, CVarAOPreConvolutionCount, and CVarAOTemporalAccumulation. It’s part of a larger set of parameters that control the AO denoising process.
Developers must be aware that changing this value will affect the visual quality and performance of the ambient occlusion effect. A higher value will result in a more spread out kernel, which can help reduce noise but may also blur fine details. Conversely, a lower value will preserve more detail but may not denoise as effectively.
Best practices when using this variable include:
- Experimenting with different values to find the right balance between noise reduction and detail preservation for your specific scene.
- Considering the performance impact, as higher values may require more computational resources.
- Using it in conjunction with other AO denoising settings for optimal results.
- Testing the visual impact across a variety of scenes and lighting conditions.
Regarding the associated variable CVarAOKernelSpreadFactor:
This is the actual console variable that stores and manages the r.AmbientOcclusion.Denoiser.KernelSpreadFactor value. It’s defined as a TAutoConsoleVariable
The purpose of CVarAOKernelSpreadFactor is to provide a programmatic interface to access and modify the kernel spread factor setting. It’s used within the engine code to retrieve the current value of the setting when performing AO denoising calculations.
This variable is accessed in the DenoiseAmbientOcclusion function of the FDefaultScreenSpaceDenoiser class, which is part of the screen space denoising implementation. The value is retrieved using the GetValueOnRenderThread() method, ensuring thread-safe access in the rendering pipeline.
Developers should be aware that modifying this CVar directly in code will have the same effect as changing the r.AmbientOcclusion.Denoiser.KernelSpreadFactor setting. It’s important to only modify this value from the render thread to avoid potential race conditions or undefined behavior.
Best practices for using CVarAOKernelSpreadFactor include:
- Always access it using GetValueOnRenderThread() when in rendering code.
- Consider exposing it as a user-configurable setting if you want to allow runtime tweaking of AO quality.
- Be cautious when modifying it frequently, as it can impact performance and visual consistency.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceDenoise.cpp:77
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarAOKernelSpreadFactor(
TEXT("r.AmbientOcclusion.Denoiser.KernelSpreadFactor"), 4,
TEXT("Spread factor of the preconvolution passes."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarAOTemporalAccumulation(
TEXT("r.AmbientOcclusion.Denoiser.TemporalAccumulation"), 1,
TEXT("Accumulates the samples over multiple frames."),
#Associated Variable and Callsites
This variable is associated with another variable named CVarAOKernelSpreadFactor
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceDenoise.cpp:76
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarAOKernelSpreadFactor(
TEXT("r.AmbientOcclusion.Denoiser.KernelSpreadFactor"), 4,
TEXT("Spread factor of the preconvolution passes."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarAOTemporalAccumulation(
TEXT("r.AmbientOcclusion.Denoiser.TemporalAccumulation"), 1,
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceDenoise.cpp:2655
Scope (from outer to inner):
file
class class FDefaultScreenSpaceDenoiser : public IScreenSpaceDenoiser
function FAmbientOcclusionOutputs DenoiseAmbientOcclusion
Source code excerpt:
Settings.ReconstructionSamples = FMath::Clamp(CVarAOReconstructionSampleCount.GetValueOnRenderThread(), 1, kStackowiakMaxSampleCountPerSet);
Settings.PreConvolutionCount = CVarAOPreConvolutionCount.GetValueOnRenderThread();
Settings.KernelSpreadFactor = CVarAOKernelSpreadFactor.GetValueOnRenderThread();
Settings.bUseTemporalAccumulation = CVarAOTemporalAccumulation.GetValueOnRenderThread() != 0;
Settings.HistoryConvolutionSampleCount = CVarAOHistoryConvolutionSampleCount.GetValueOnRenderThread();
Settings.HistoryConvolutionKernelSpreadFactor = CVarAOHistoryConvolutionKernelSpreadFactor.GetValueOnRenderThread();
Settings.MaxInputSPP = RayTracingConfig.RayCountPerPixel;
TStaticArray<FScreenSpaceDenoiserHistory*, IScreenSpaceDenoiser::kMaxBatchSize> PrevHistories;