r.TonemapperGamma
r.TonemapperGamma
#Overview
name: r.TonemapperGamma
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
0: Default behavior\n#: Use fixed gamma # instead of sRGB or Rec709 transform
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.TonemapperGamma is to control the gamma correction applied during the tonemapping process in Unreal Engine’s rendering pipeline. It allows developers to override the default gamma behavior with a fixed gamma value.
This setting variable is primarily used in the Renderer module of Unreal Engine, specifically in the post-processing and tonemapping stages. It’s also utilized in the SlateRHIRenderer for UI rendering and in the FunctionalTesting module for automated screenshot comparisons.
The value of this variable is typically set through the console or configuration files. It’s defined as a TAutoConsoleVariable, which means it can be changed at runtime.
r.TonemapperGamma interacts with other rendering-related variables, particularly those involved in color space transformations and display output formatting. It’s often used in conjunction with variables like r.TonemapperSharpen and r.ScreenPercentage.
Developers must be aware that changing this variable can significantly affect the overall look of the rendered image. It’s particularly important when targeting different display types or when trying to achieve specific visual styles.
Best practices for using this variable include:
- Leave it at the default value (0.0) unless there’s a specific need to override the engine’s built-in gamma correction.
- When using a custom value, ensure it’s appropriate for the target display and color space.
- Test the results across different display types to ensure consistency.
- Consider the impact on performance, as custom gamma values may require additional computation.
- Use in conjunction with other tonemapping and color grading tools for a holistic approach to visual quality.
Remember that incorrect use of this variable can lead to inconsistent or incorrect color representation across different displays, so it should be adjusted with care and thorough testing.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessTonemap.cpp:44
Scope (from outer to inner):
file
namespace anonymous
Source code excerpt:
TAutoConsoleVariable<float> CVarTonemapperGamma(
TEXT("r.TonemapperGamma"),
0.0f,
TEXT("0: Default behavior\n")
TEXT("#: Use fixed gamma # instead of sRGB or Rec709 transform"),
ECVF_Scalability | ECVF_RenderThreadSafe);
TAutoConsoleVariable<float> CVarGamma(
#Loc: <Workspace>/Engine/Source/Developer/FunctionalTesting/Private/AutomationBlueprintFunctionLibrary.cpp:246
Scope (from outer to inner):
file
function FAutomationTestScreenshotEnvSetup::FAutomationTestScreenshotEnvSetup
Source code excerpt:
, EyeAdaptationQuality(TEXT("r.EyeAdaptationQuality"))
, ContactShadows(TEXT("r.ContactShadows"))
, TonemapperGamma(TEXT("r.TonemapperGamma"))
, TonemapperSharpen(TEXT("r.Tonemapper.Sharpen"))
, ScreenPercentage(TEXT("r.ScreenPercentage"))
, DynamicResTestScreenPercentage(TEXT("r.DynamicRes.TestScreenPercentage"))
, DynamicResOperationMode(TEXT("r.DynamicRes.OperationMode"))
, SecondaryScreenPercentage(TEXT("r.SecondaryScreenPercentage.GameViewport"))
{
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessDeviceEncodingOnly.cpp:36
Scope (from outer to inner):
file
function FDeviceEncodingOnlyOutputDeviceParameters GetDeviceEncodingOnlyOutputDeviceParameters
Source code excerpt:
FDeviceEncodingOnlyOutputDeviceParameters GetDeviceEncodingOnlyOutputDeviceParameters(const FSceneViewFamily& Family)
{
static TConsoleVariableData<float>* CVarOutputGamma = IConsoleManager::Get().FindTConsoleVariableDataFloat(TEXT("r.TonemapperGamma"));
EDisplayOutputFormat OutputDeviceValue;
if (Family.SceneCaptureSource == SCS_FinalColorHDR)
{
OutputDeviceValue = EDisplayOutputFormat::HDR_LinearNoToneCurve;
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessTonemap.cpp:244
Scope (from outer to inner):
file
function FTonemapperOutputDeviceParameters GetTonemapperOutputDeviceParameters
Source code excerpt:
FTonemapperOutputDeviceParameters GetTonemapperOutputDeviceParameters(const FSceneViewFamily& Family)
{
static TConsoleVariableData<float>* CVarOutputGamma = IConsoleManager::Get().FindTConsoleVariableDataFloat(TEXT("r.TonemapperGamma"));
EDisplayOutputFormat OutputDeviceValue;
if (Family.SceneCaptureSource == SCS_FinalColorHDR)
{
OutputDeviceValue = EDisplayOutputFormat::HDR_LinearNoToneCurve;
#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderer.cpp:678
Scope (from outer to inner):
file
function void SetParameters
Source code excerpt:
void SetParameters(FRHIBatchedShaderParameters& BatchedParameters, EDisplayOutputFormat DisplayOutputFormat, EDisplayColorGamut DisplayColorGamut, float DisplayMaxLuminance)
{
static const auto CVarOutputGamma = IConsoleManager::Get().FindTConsoleVariableDataFloat(TEXT("r.TonemapperGamma"));
int32 OutputDeviceValue = (int32)DisplayOutputFormat;
int32 OutputGamutValue = (int32)DisplayColorGamut;
float Gamma = CVarOutputGamma->GetValueOnRenderThread();
// In case gamma is unspecified, fall back to 2.2 which is the most common case