r.DiffuseColor.Min

r.DiffuseColor.Min

#Overview

name: r.DiffuseColor.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.DiffuseColor.Min is to allow quick material testing by remapping the minimum diffuse color value in materials. It 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 handling scene view parameters and uniform buffer setup.

The value of this variable is set through a console variable (CVarDiffuseColorMin) with a default value of 0.0f. It can be changed at runtime through console commands or programmatically.

This variable interacts closely with another variable called r.DiffuseColor.Max. Together, they define a range for remapping diffuse color values in materials.

Developers must be aware that this variable is intended for non-shipping builds only, as indicated by the ECVF_Cheat flag. It’s meant for quick material testing and debugging purposes, not for use in final, released games.

Best practices when using this variable include:

  1. Only use it for debugging and testing purposes.
  2. Be cautious when adjusting this value, as it can significantly affect the appearance of materials in the scene.
  3. Always consider the corresponding r.DiffuseColor.Max value when making adjustments.
  4. Remember to reset this value to its default (0.0f) after testing to ensure normal rendering behavior.

Regarding the associated variable CVarDiffuseColorMin:

The purpose of CVarDiffuseColorMin is to store and provide access to the r.DiffuseColor.Min value within the engine’s C++ code.

This variable is used in the Engine module, specifically in the scene view setup process. It’s accessed in the SetupCommonViewUniformBufferParameters function, which is responsible for setting up uniform shader parameters for the view.

The value of CVarDiffuseColorMin is set when the r.DiffuseColor.Min console variable is initialized or changed.

CVarDiffuseColorMin interacts directly with the r.DiffuseColor.Min console variable and is used in conjunction with CVarDiffuseColorMax to define the range for diffuse color remapping.

Developers should be aware that this variable is accessed on the render thread (GetValueOnRenderThread()), which means changes to it will be applied on the next frame render.

Best practices for using CVarDiffuseColorMin include:

  1. Access it only on the render thread to avoid race conditions.
  2. Use it in conjunction with CVarDiffuseColorMax for consistent material adjustments.
  3. Remember that changes to this variable will affect all materials in the scene that use diffuse color.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

// should be changed to BaseColor and Metallic, since some time now UE is not using DiffuseColor and SpecularColor any more
static TAutoConsoleVariable<float> CVarDiffuseColorMin(
	TEXT("r.DiffuseColor.Min"),
	0.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> CVarDiffuseColorMax(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:


// should be changed to BaseColor and Metallic, since some time now UE is not using DiffuseColor and SpecularColor any more
static TAutoConsoleVariable<float> CVarDiffuseColorMin(
	TEXT("r.DiffuseColor.Min"),
	0.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:2578

Scope (from outer to inner):

file
function     void FSceneView::SetupCommonViewUniformBufferParameters

Source code excerpt:

		float MaxValue = MinValue + LocalDiffuseOverrideParameter.W;

		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;
	}
	{