r.DiffuseColor.Max

r.DiffuseColor.Max

#Overview

name: r.DiffuseColor.Max

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.DiffuseColor.Max is to allow quick material testing by remapping the maximum diffuse color value to a new value between 0 and 1. This setting is part of the rendering system in Unreal Engine 5.

This setting variable is primarily used in the Engine module, specifically within the rendering subsystem. It’s referenced in the SceneView.cpp file, which is responsible for managing scene views and related parameters.

The value of this variable is set through a console variable (CVarDiffuseColorMax) with a default value of 1.0f. It can be changed at runtime using console commands or through code.

The r.DiffuseColor.Max variable interacts with another variable called r.DiffuseColor.Min (represented by CVarDiffuseColorMin). Together, they define a range for remapping diffuse colors in materials.

Developers must be aware that this variable is marked with ECVF_Cheat and ECVF_RenderThreadSafe flags. The ECVF_Cheat flag indicates that it should not be used in shipping builds, as it’s intended for testing and debugging purposes only. The ECVF_RenderThreadSafe flag means it can be safely accessed from the render thread.

Best practices when using this variable include:

  1. Only use it for quick material testing and debugging.
  2. Ensure it’s not enabled in shipping builds.
  3. Use it in conjunction with r.DiffuseColor.Min for a complete range control.
  4. Be cautious when modifying it, as it can significantly affect the appearance of materials in the scene.

Regarding the associated variable CVarDiffuseColorMax:

The purpose of CVarDiffuseColorMax is to store and manage the r.DiffuseColor.Max console variable. It’s an instance of TAutoConsoleVariable, which is a template class used for creating console variables in Unreal Engine.

This associated variable is used within the Engine module, specifically in the SceneView.cpp file. It’s part of the rendering subsystem and is used to control the maximum diffuse color value.

The value of CVarDiffuseColorMax is set when the console variable is created, with a default value of 1.0f. It can be modified at runtime using console commands.

CVarDiffuseColorMax interacts directly with the r.DiffuseColor.Max setting. It’s used to retrieve the current value of the setting using the GetValueOnRenderThread() method.

Developers should be aware that this variable is thread-safe for render thread access, as indicated by the ECVF_RenderThreadSafe flag. It’s also marked as a cheat variable (ECVF_Cheat), meaning it should not be used in shipping builds.

Best practices for using CVarDiffuseColorMax include:

  1. Access its value using GetValueOnRenderThread() when in render thread context.
  2. Use it for debugging and testing purposes only.
  3. Ensure it’s not accessed or modified in shipping builds.
  4. Consider potential performance implications when frequently accessing or modifying this value.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SceneView.cpp:288

Scope: file

Source code excerpt:

	);
static TAutoConsoleVariable<float> CVarDiffuseColorMax(
	TEXT("r.DiffuseColor.Max"),
	1.0f,
	TEXT("Allows quick material test by remapping the diffuse color at 1 to a new value (0..1), Only for non shipping built!\n")
	TEXT("1: (default)"),
	ECVF_Cheat | ECVF_RenderThreadSafe
	);
static TAutoConsoleVariable<float> CVarRoughnessMin(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SceneView.cpp:287

Scope: file

Source code excerpt:

	ECVF_Cheat | ECVF_RenderThreadSafe
	);
static TAutoConsoleVariable<float> CVarDiffuseColorMax(
	TEXT("r.DiffuseColor.Max"),
	1.0f,
	TEXT("Allows quick material test by remapping the diffuse color at 1 to a new value (0..1), Only for non shipping built!\n")
	TEXT("1: (default)"),
	ECVF_Cheat | ECVF_RenderThreadSafe
	);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SceneView.cpp:2579

Scope (from outer to inner):

file
function     void FSceneView::SetupCommonViewUniformBufferParameters

Source code excerpt:


		float NewMinValue = FMath::Max(MinValue, CVarDiffuseColorMin.GetValueOnRenderThread());
		float NewMaxValue = FMath::Min(MaxValue, CVarDiffuseColorMax.GetValueOnRenderThread());

		LocalDiffuseOverrideParameter.X = LocalDiffuseOverrideParameter.Y = LocalDiffuseOverrideParameter.Z = NewMinValue;
		LocalDiffuseOverrideParameter.W = NewMaxValue - NewMinValue;
	}
	{
		float MinValue = LocalRoughnessOverrideParameter.X;