r.LUT.Size

r.LUT.Size

#Overview

name: r.LUT.Size

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.LUT.Size is to define the size of the film Look-Up Table (LUT) used in color grading and post-processing within Unreal Engine’s rendering system.

This setting variable is primarily utilized by the rendering system, specifically in the post-processing pipeline. Based on the callsites, it’s evident that the Renderer module relies on this variable, particularly in the color grading and LUT combination processes.

The value of this variable is set through a console variable (CVarLUTSize) with a default value of 32. It can be modified at runtime using console commands or through C++ code.

The associated variable CVarLUTSize directly interacts with r.LUT.Size, as they share the same value. This variable is used to retrieve the LUT size in various parts of the rendering code.

Developers must be aware that changing this value affects the quality and performance of color grading. A larger LUT size can provide more accurate color grading but may impact performance and memory usage.

Best practices when using this variable include:

  1. Keeping the LUT size as a power of 2 for optimal performance.
  2. Balancing between quality and performance based on the target platform and requirements.
  3. Testing thoroughly after modifying the value to ensure desired visual results and performance.

Regarding the associated variable CVarLUTSize:

The purpose of CVarLUTSize is to provide a programmatic way to access and modify the r.LUT.Size value within the C++ code.

This variable is used in the Renderer module, specifically in the post-processing and color grading systems.

The value of CVarLUTSize is set when the r.LUT.Size console variable is initialized or modified.

CVarLUTSize directly interacts with r.LUT.Size, as they represent the same setting.

Developers should be aware that CVarLUTSize is a TAutoConsoleVariable, which means it can be modified at runtime and will automatically update the associated systems.

Best practices for using CVarLUTSize include:

  1. Using GetInt() method to retrieve the current value when needed.
  2. Avoiding direct modification of the variable, instead using console commands to change r.LUT.Size.
  3. Considering the performance implications when frequently accessing or modifying this value in performance-critical code paths.

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


TAutoConsoleVariable<int32> CVarLUTSize(
	TEXT("r.LUT.Size"),
	32,
	TEXT("Size of film LUT"),
	ECVF_RenderThreadSafe);

TAutoConsoleVariable<int32> CVarColorGrading(
	TEXT("r.Color.Grading"), 1,

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

	ECVF_RenderThreadSafe);

TAutoConsoleVariable<int32> CVarLUTSize(
	TEXT("r.LUT.Size"),
	32,
	TEXT("Size of film LUT"),
	ECVF_RenderThreadSafe);

TAutoConsoleVariable<int32> CVarColorGrading(

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

Scope (from outer to inner):

file
function     void GetCombineLUTParameters

Source code excerpt:

		// White balance
		UPDATE_CACHE_SETTINGS(Parameters.bIsTemperatureWhiteBalance, uint32(Settings.TemperatureType == ETemperatureMethod::TEMP_WhiteBalance), bHasChanged);
		UPDATE_CACHE_SETTINGS(Parameters.LUTSize, (float)CVarLUTSize->GetInt(), bHasChanged);
		UPDATE_CACHE_SETTINGS(Parameters.WhiteTemp, Settings.WhiteTemp, bHasChanged);
		UPDATE_CACHE_SETTINGS(Parameters.WhiteTint, Settings.WhiteTint, bHasChanged);

		// Color grade
		UPDATE_CACHE_SETTINGS(Parameters.ColorSaturation, FVector4f(Settings.ColorSaturation), bHasChanged);
		UPDATE_CACHE_SETTINGS(Parameters.ColorContrast, FVector4f(Settings.ColorContrast), bHasChanged);

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

Scope (from outer to inner):

file
function     FRDGTextureRef AddCombineLUTPass

Source code excerpt:


	// Attempt to register the persistent view LUT texture.
	const int32 LUTSize = CVarLUTSize->GetInt();
	FRDGTextureRef OutputTexture = TryRegisterExternalTexture(GraphBuilder,
		View.GetTonemappingLUT(GraphBuilder.RHICmdList, LUTSize, bUseVolumeTextureLUT, bUseComputePass, bUseFloatOutput));

	View.SetValidTonemappingLUT();

	const bool bHasChanged = CachedLUTSettings.UpdateCachedValues(View, LocalTextures, LocalWeights, LocalCount);