MaxPixelShaderAdditiveComplexityCount

MaxPixelShaderAdditiveComplexityCount

#Overview

name: MaxPixelShaderAdditiveComplexityCount

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of MaxPixelShaderAdditiveComplexityCount is to set a maximum threshold for pixel shader additive complexity in the rendering system of Unreal Engine 5. This variable is used to control the visualization and performance optimization of shader complexity.

The Unreal Engine rendering subsystem relies on this setting variable, specifically within the post-processing and visualization modules. It is referenced in the Engine class and used in shader complexity visualization.

The value of this variable is set globally in the engine configuration, as indicated by the UPROPERTY(globalconfig) decorator in the Engine.h file. It can also be modified at runtime through console commands, as seen in the HandleShaderComplexityCommand function in UnrealEngine.cpp.

This variable interacts with MaxES3PixelShaderAdditiveComplexityCount, which serves a similar purpose but is specifically for ES3 (OpenGL ES 3.0) rendering. The GetMaxShaderComplexityCount function in PostProcessVisualizeComplexity.cpp uses both variables depending on the rendering API in use.

Developers must be aware that this variable directly impacts the visualization of shader complexity in the engine. Changing its value will affect how shader complexity is displayed and potentially how performance optimizations are applied.

Best practices when using this variable include:

  1. Carefully consider the performance implications when adjusting this value.
  2. Use it in conjunction with shader complexity visualization tools to optimize rendering performance.
  3. Be mindful of different hardware capabilities when setting this value, especially for cross-platform development.
  4. Document any changes made to this variable, as it can significantly impact the rendering pipeline.
  5. Consider using the console command for testing different values before applying them to the global configuration.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:275, 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:1253

Scope (from outer to inner):

file
class        class UEngine : public UObject , public FExec

Source code excerpt:

	*/
	UPROPERTY(globalconfig)
	float MaxPixelShaderAdditiveComplexityCount;

	UPROPERTY(globalconfig)
	float MaxES3PixelShaderAdditiveComplexityCount;

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:5759

Scope (from outer to inner):

file
function     bool UEngine::HandleShaderComplexityCommand

Source code excerpt:

			if (NewMax > 0.0f)
			{
				GEngine->MaxPixelShaderAdditiveComplexityCount = NewMax;
			}
		}
		else
		{
			Ar.Logf( TEXT("Format is 'shadercomplexity [toggleadditive] [togglepixel] [max $int]"));
			return true;
		}

		float CurrentMax = GEngine->MaxPixelShaderAdditiveComplexityCount;

		Ar.Logf( TEXT("New ShaderComplexity Settings: Max = %f"), CurrentMax);
	} 
	else
	{
		Ar.Logf( TEXT("Format is 'shadercomplexity [max $int]"));

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

Scope (from outer to inner):

file
function     float GetMaxShaderComplexityCount

Source code excerpt:

		return GEngine->MaxES3PixelShaderAdditiveComplexityCount;
	default:
		return GEngine->MaxPixelShaderAdditiveComplexityCount;
	}
}

FScreenPassTexture AddVisualizeComplexityPass(FRDGBuilder& GraphBuilder, const FViewInfo& View, const FVisualizeComplexityInputs& Inputs)
{
	check(Inputs.SceneColor.IsValid());