r.VRS.ContrastAdaptiveShading.HDR10CorrectionMultiplier
r.VRS.ContrastAdaptiveShading.HDR10CorrectionMultiplier
#Overview
name: r.VRS.ContrastAdaptiveShading.HDR10CorrectionMultiplier
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Approximation multiplier to account for how perceptual values are spread out in SDR vs HDR10\n
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.VRS.ContrastAdaptiveShading.HDR10CorrectionMultiplier is to provide an approximation multiplier to account for how perceptual values are spread out in SDR (Standard Dynamic Range) versus HDR10 (High Dynamic Range) in the context of Variable Rate Shading (VRS) and Contrast Adaptive Shading (CAS).
This setting variable is primarily used in the rendering system, specifically in the Variable Rate Shading subsystem of Unreal Engine 5. It is part of the Contrast Adaptive Shading feature, which adjusts shading rates based on image contrast.
The variable is used in the Renderer module, as evident from its location in the “Runtime/Renderer/Private/VariableRateShading/ContrastAdaptiveImageGenerator.cpp” file.
The value of this variable is set as a console variable with a default value of 0.55. It can be modified at runtime through the console or configuration files.
This variable interacts with other VRS-related variables, particularly those related to edge thresholds in Contrast Adaptive Shading. It’s used as a multiplier for these thresholds when rendering in HDR10 mode.
Developers should be aware that this variable is specific to HDR10 rendering and will only affect the Contrast Adaptive Shading calculations when HDR10 is in use. It’s designed to compensate for the different perceptual value distribution between SDR and HDR10.
Best practices for using this variable include:
- Only adjusting it if you notice significant differences in VRS behavior between SDR and HDR10 rendering.
- Testing any changes thoroughly across a range of scenes and lighting conditions.
- Considering the impact on performance and image quality when modifying this value.
The associated variable CVarCAS_HDR10CorrectionMultiplier is the actual console variable implementation of r.VRS.ContrastAdaptiveShading.HDR10CorrectionMultiplier. It’s used in the same context and for the same purpose. This variable is accessed in the render thread, as seen in the GetValueOnRenderThread()
calls, which is important for thread safety in the rendering pipeline.
When using CVarCAS_HDR10CorrectionMultiplier, developers should ensure that any modifications are made in a thread-safe manner, preferably through engine configuration systems rather than direct code modification. It’s also important to note that changes to this variable will affect the edge detection thresholds in the Contrast Adaptive Shading calculations, potentially impacting both performance and visual quality in HDR10 rendering scenarios.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VariableRateShading/ContrastAdaptiveImageGenerator.cpp:47
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
TAutoConsoleVariable<float> CVarCAS_HDR10CorrectionMultiplier(
TEXT("r.VRS.ContrastAdaptiveShading.HDR10CorrectionMultiplier"),
0.55,
TEXT("Approximation multiplier to account for how perceptual values are spread out in SDR vs HDR10\n"),
ECVF_RenderThreadSafe);
/**
* Debug Settings
#Associated Variable and Callsites
This variable is associated with another variable named CVarCAS_HDR10CorrectionMultiplier
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VariableRateShading/ContrastAdaptiveImageGenerator.cpp:46
Scope: file
Source code excerpt:
TEXT(""),
ECVF_RenderThreadSafe);
TAutoConsoleVariable<float> CVarCAS_HDR10CorrectionMultiplier(
TEXT("r.VRS.ContrastAdaptiveShading.HDR10CorrectionMultiplier"),
0.55,
TEXT("Approximation multiplier to account for how perceptual values are spread out in SDR vs HDR10\n"),
ECVF_RenderThreadSafe);
/**
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VariableRateShading/ContrastAdaptiveImageGenerator.cpp:118
Scope (from outer to inner):
file
class class FCalculateShadingRateImageCS : public FGlobalShader
function static void InitParameters
Source code excerpt:
Parameters.LuminanceTexture = Luminance;
Parameters.ViewRect = FVector4f(ViewRect.Min.X, ViewRect.Min.Y, ViewRect.Max.X, ViewRect.Max.Y);
const float cEdgeThresholdCorrectionValue = bIsHDR10 ? CVarCAS_HDR10CorrectionMultiplier.GetValueOnRenderThread() : 1.0;
Parameters.EdgeThreshold = cEdgeThresholdCorrectionValue * CVarCASEdgeThreshold.GetValueOnRenderThread();
Parameters.ConservativeEdgeThreshold = cEdgeThresholdCorrectionValue * CVarCASConservativeEdgeThreshold.GetValueOnRenderThread();
Parameters.HardwareShadingRateImage = HardwareShadingRateImage;
Parameters.SoftwareShadingRateImage = SoftwareShadingRateImage;
}
};