r.Color.Grading

r.Color.Grading

#Overview

name: r.Color.Grading

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.Grading is to control whether post-process color grading settings should be applied in the rendering pipeline. This setting variable is primarily used in the rendering system of Unreal Engine 5.

The Unreal Engine subsystem that relies on this setting variable is the Renderer module, specifically the post-processing pipeline. This can be seen from the file location where the variable is defined: Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessCombineLUTs.cpp.

The value of this variable is set using a console variable (CVar) system. It’s initialized with a default value of 1, meaning color grading is enabled by default. The value can be changed at runtime through console commands or programmatically.

The associated variable CVarColorGrading interacts directly with r.Color.Grading. They share the same value and purpose. This variable is used in the C++ code to check the current state of the color grading setting.

Developers must be aware that this variable affects the final visual output of the rendered scene. When disabled (set to 0), color grading post-process settings will not be applied, which can significantly change the look of the game.

Best practices when using this variable include:

  1. Use it for debugging or performance testing, temporarily disabling color grading if needed.
  2. Be cautious when changing its value during gameplay, as it can cause sudden visual changes.
  3. Consider exposing it as a graphics option for end-users if color grading has a significant performance impact.

Regarding the associated variable CVarColorGrading:

The purpose of CVarColorGrading is to provide a programmatic way to access and modify the r.Color.Grading setting within the C++ code of the engine.

It’s used in the Renderer module, specifically in the post-processing pipeline, to determine whether color grading should be applied.

The value of CVarColorGrading is set when r.Color.Grading is modified, as they share the same value.

This variable interacts directly with the engine’s post-processing system. It’s used in conditional statements to determine whether to apply color grading settings.

Developers should be aware that this variable is accessed on the render thread, as indicated by the GetValueOnRenderThread() method used in the code.

Best practices for using CVarColorGrading include:

  1. Use it for runtime checks of the color grading state in render-thread-safe contexts.
  2. Be aware of potential performance implications when frequently checking its value in performance-critical code paths.
  3. Consider caching its value if used frequently in a single frame to avoid repeated calls to GetValueOnRenderThread().

#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:40

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


TAutoConsoleVariable<int32> CVarColorGrading(
	TEXT("r.Color.Grading"), 1,
	TEXT("Controls whether post process settings's color grading settings should be applied."),
	ECVF_RenderThreadSafe);

TAutoConsoleVariable<int32> CVarLUTUpdateEveryFrame(
	TEXT("r.LUT.UpdateEveryFrame"), 0,
	TEXT("Controls whether the tonemapping LUT pass is executed every frame."),

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

	ECVF_RenderThreadSafe);

TAutoConsoleVariable<int32> CVarColorGrading(
	TEXT("r.Color.Grading"), 1,
	TEXT("Controls whether post process settings's color grading settings should be applied."),
	ECVF_RenderThreadSafe);

TAutoConsoleVariable<int32> CVarLUTUpdateEveryFrame(
	TEXT("r.LUT.UpdateEveryFrame"), 0,

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

Scope (from outer to inner):

file
function     void GetCombineLUTParameters

Source code excerpt:

		const FSceneViewFamily& ViewFamily = *(View.Family);
		const FPostProcessSettings& Settings = (
			ViewFamily.EngineShowFlags.ColorGrading && CVarColorGrading.GetValueOnRenderThread() != 0)
			? View.FinalPostProcessSettings
			: DefaultSettings;

		for (uint32 BlendIndex = 0; BlendIndex < BlendCount; ++BlendIndex)
		{
			// Neutral texture occupies the first slot and doesn't actually need to be set.