r.Color.Min

r.Color.Min

#Overview

name: r.Color.Min

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.Color.Min is to define the mapping of the value 0 in color channels after color grading in the rendering pipeline. It allows for fine-tuning of dark areas in the rendered image.

This setting variable is primarily used in the rendering system of Unreal Engine 5, specifically in the post-processing stage. Based on the callsites, it’s part of the color grading process within the Renderer module.

The value of this variable is set through the console variable system in Unreal Engine. It’s defined as a TAutoConsoleVariable with a default value of 0.0f.

The r.Color.Min variable interacts with two other variables: r.Color.Mid and r.Color.Max. Together, these three variables form a color transform that affects the overall color grading of the rendered image.

Developers must be aware that this variable directly impacts the dark areas of the rendered image. Positive values will add a gray scale to dark areas, while negative values will cause more dark values to become black. The valid range for this variable is clamped between -10.0f and 10.0f in the code.

Best practices when using this variable include:

  1. Use small adjustments, as even minor changes can have a noticeable impact on the image.
  2. Test the changes in various lighting conditions to ensure consistent results.
  3. Consider the interaction with r.Color.Mid and r.Color.Max for a balanced color grading approach.
  4. Use in conjunction with other post-processing settings for optimal results.

Regarding the associated variable CVarColorMin:

CVarColorMin is the actual console variable object that represents r.Color.Min in the code. It’s used to store and retrieve the current value of r.Color.Min.

The purpose of CVarColorMin is to provide a programmatic interface for getting and setting the r.Color.Min value. It’s used in the GetMappingPolynomial() function to retrieve the current value of r.Color.Min on the render thread.

This variable is part of the renderer’s internal implementation and is not typically interacted with directly by game developers. Instead, developers should use the console command “r.Color.Min” to adjust the value.

Best practices for CVarColorMin include:

  1. Use GetValueOnRenderThread() when accessing the value in render thread code.
  2. Be aware that changes to this variable will affect the entire rendering pipeline, so use with caution in performance-critical scenarios.
  3. Consider using the cvar system’s callback functionality if you need to react to changes in this value programmatically.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessCombineLUTs.cpp:13

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

{
TAutoConsoleVariable<float> CVarColorMin(
	TEXT("r.Color.Min"),
	0.0f,
	TEXT("Allows to define where the value 0 in the color channels is mapped to after color grading.\n")
	TEXT("The value should be around 0, positive: a gray scale is added to the darks, negative: more dark values become black, Default: 0"),
	ECVF_RenderThreadSafe);

TAutoConsoleVariable<float> CVarColorMid(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessCombineLUTs.cpp:12

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

namespace
{
TAutoConsoleVariable<float> CVarColorMin(
	TEXT("r.Color.Min"),
	0.0f,
	TEXT("Allows to define where the value 0 in the color channels is mapped to after color grading.\n")
	TEXT("The value should be around 0, positive: a gray scale is added to the darks, negative: more dark values become black, Default: 0"),
	ECVF_RenderThreadSafe);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessCombineLUTs.cpp:84

Scope (from outer to inner):

file
function     FVector3f GetMappingPolynomial

Source code excerpt:

{
	FColorTransform ColorTransform;
	ColorTransform.MinValue = FMath::Clamp(CVarColorMin.GetValueOnRenderThread(), -10.0f, 10.0f);
	ColorTransform.MidValue = FMath::Clamp(CVarColorMid.GetValueOnRenderThread(), -10.0f, 10.0f);
	ColorTransform.MaxValue = FMath::Clamp(CVarColorMax.GetValueOnRenderThread(), -10.0f, 10.0f);

	// x is the input value, y the output value
	// RGB = a, b, c where y = a * x*x + b * x + c
	float c = ColorTransform.MinValue;