ShaderComplexityColors

ShaderComplexityColors

#Overview

name: ShaderComplexityColors

The value of this variable can be defined or overridden in .ini config files. 9 .ini config files referencing this setting variable.

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of ShaderComplexityColors is to define a color palette used for visualizing shader complexity in Unreal Engine 5. This variable is part of the rendering system, specifically used in debug and optimization workflows.

The ShaderComplexityColors variable is primarily used by the Renderer module, as evidenced by its references in PostProcessVisualizeComplexity.cpp and PostProcessing.cpp. It’s also utilized in the Engine and Landscape modules, indicating its importance across multiple Unreal Engine subsystems.

The value of this variable is set through the UPROPERTY(globalconfig) macro, which suggests that it can be configured globally, likely through project settings or configuration files.

ShaderComplexityColors interacts with other variables such as QuadComplexityColors and MaxPixelShaderAdditiveComplexityCount. These variables work together to provide a comprehensive view of rendering complexity.

Developers should be aware that:

  1. The number of colors in ShaderComplexityColors affects the granularity of complexity visualization.
  2. It’s used in both standard and mobile rendering pipelines.
  3. The colors are used to map instruction counts in shaders to visual representations.

Best practices when using this variable include:

  1. Ensure the color array has enough entries to provide meaningful differentiation in complexity levels.
  2. Consider the color choices carefully to make complexity differences easily discernible.
  3. Use in conjunction with other complexity visualization tools for a comprehensive understanding of rendering performance.
  4. Be mindful of how changes to this variable might affect different platforms, especially mobile.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:203, section: [/Script/Engine.Engine]

Location: <Workspace>/Engine/Config/BaseEngine.ini:204, section: [/Script/Engine.Engine]

Location: <Workspace>/Engine/Config/BaseEngine.ini:205, section: [/Script/Engine.Engine]

Location: <Workspace>/Engine/Config/BaseEngine.ini:206, section: [/Script/Engine.Engine]

Location: <Workspace>/Engine/Config/BaseEngine.ini:207, section: [/Script/Engine.Engine]

Location: <Workspace>/Engine/Config/BaseEngine.ini:208, section: [/Script/Engine.Engine]

Location: <Workspace>/Engine/Config/BaseEngine.ini:209, section: [/Script/Engine.Engine]

Location: <Workspace>/Engine/Config/BaseEngine.ini:210, section: [/Script/Engine.Engine]

Location: <Workspace>/Engine/Config/BaseEngine.ini:211, section: [/Script/Engine.Engine]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/Engine.h:1192

Scope (from outer to inner):

file
class        class UEngine : public UObject , public FExec

Source code excerpt:

	/** The colors used to render shader complexity. */
	UPROPERTY(globalconfig)
	TArray<FLinearColor> ShaderComplexityColors;

	/** The colors used to render quad complexity. */
	UPROPERTY(globalconfig)
	TArray<FLinearColor> QuadComplexityColors;

	/** The colors used to render light complexity. */

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/Engine.h:1250

Scope: file

Source code excerpt:

	/**
	* Complexity limits for the various complexity view mode combinations.
	* These limits are used to map instruction counts to ShaderComplexityColors.
	*/
	UPROPERTY(globalconfig)
	float MaxPixelShaderAdditiveComplexityCount;

	UPROPERTY(globalconfig)
	float MaxES3PixelShaderAdditiveComplexityCount;

	/** Minimum lightmap density value for coloring. */
	UPROPERTY(globalconfig)

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeRender.cpp:2629

Scope: file

Source code excerpt:

			case ELandscapeViewMode::LayerDensity:
			{
				int32 ColorIndex = FMath::Min<int32>(NumWeightmapLayerAllocations, GEngine->ShaderComplexityColors.Num());
				auto LayerDensityMaterialInstance = new FColoredMaterialRenderProxy(GEngine->LevelColorationUnlitMaterial->GetRenderProxy(), ColorIndex ? GEngine->ShaderComplexityColors[ColorIndex - 1] : FLinearColor::Black);

				MeshTools.MaterialRenderProxy = LayerDensityMaterialInstance;
				Collector.RegisterOneFrameMaterialProxy(LayerDensityMaterialInstance);

				MeshTools.bCanApplyViewModeOverrides = true;
				MeshTools.bUseWireframeSelectionColoring = IsSelected();

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessVisualizeComplexity.cpp:105

Scope (from outer to inner):

file
function     FScreenPassTexture AddVisualizeComplexityPass

Source code excerpt:

			for (int32 ColorIndex = 0; ColorIndex < ClampedColorCount; ColorIndex++)
			{
				PassParameters->ShaderComplexityColors[ColorIndex] = Inputs.Colors[ColorIndex];
			}
			PassParameters->ShaderComplexityColorCount = ClampedColorCount;
		}
		else // Otherwise fallback to a safe value.
		{
			PassParameters->ShaderComplexityColors[0] = FLinearColor::Gray;
			PassParameters->ShaderComplexityColorCount = 1;
		}
	}

	const uint32 ShaderComplexityColorCount = PassParameters->ShaderComplexityColorCount;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessing.cpp:1893

Scope (from outer to inner):

file
function     void AddDebugViewPostProcessingPasses

Source code excerpt:

			PassInputs.OverrideOutput = OverrideOutput;
			PassInputs.SceneColor = SceneColor;
			PassInputs.Colors = GEngine->ShaderComplexityColors;
			PassInputs.ColorSamplingMethod = FVisualizeComplexityInputs::EColorSamplingMethod::Ramp;
			PassInputs.ComplexityScale = 1.0f;
			PassInputs.bDrawLegend = true;

			SceneColor = AddVisualizeComplexityPass(GraphBuilder, View, PassInputs);
			break;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessing.cpp:2902

Scope (from outer to inner):

file
function     void AddMobilePostProcessingPasses

Source code excerpt:

			PassInputs.OverrideOutput = OverrideOutput;
			PassInputs.SceneColor = SceneColor;
			PassInputs.Colors = GEngine->ShaderComplexityColors;
			PassInputs.ColorSamplingMethod = FVisualizeComplexityInputs::EColorSamplingMethod::Ramp;
			PassInputs.ComplexityScale = 1.0f;
			PassInputs.bDrawLegend = true;
			PassInputs.OverrideOutput.LoadAction = View.IsFirstInFamily() ? ERenderTargetLoadAction::EClear : ERenderTargetLoadAction::ELoad;

			SceneColor = AddVisualizeComplexityPass(GraphBuilder, View, PassInputs);