r.Test.OverrideTimeMaterialExpressions

r.Test.OverrideTimeMaterialExpressions

#Overview

name: r.Test.OverrideTimeMaterialExpressions

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.Test.OverrideTimeMaterialExpressions is to freeze time material expressions for testing and debugging purposes in Unreal Engine’s rendering system.

This setting variable is primarily used in the rendering subsystem of Unreal Engine, specifically in the scene view component. It’s referenced in the Engine module, within the SceneView.cpp file.

The value of this variable is set through a console variable (CVarOverrideTimeMaterialExpressions) using the TAutoConsoleVariable template. It’s initialized with a default value of -1.0f, which means the override is not active by default.

The associated variable CVarOverrideTimeMaterialExpressions interacts directly with r.Test.OverrideTimeMaterialExpressions. They share the same value and purpose.

Developers must be aware that:

  1. This variable is only active in non-shipping and non-test builds (wrapped in #if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)).
  2. When set to a value >= 0.0f, it overrides the time values used in material expressions.
  3. It affects both game time and real time in the view uniform shader parameters.

Best practices when using this variable include:

  1. Use it only for debugging and testing purposes, not in production builds.
  2. Reset the value to -1.0f when done testing to ensure normal time progression in materials.
  3. Be cautious when using it in multiplayer scenarios, as it may cause visual inconsistencies between clients.

Regarding the associated variable CVarOverrideTimeMaterialExpressions:

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarOverrideTimeMaterialExpressions(
	TEXT("r.Test.OverrideTimeMaterialExpressions"), -1.0f,
	TEXT("Value to freeze time material expressions with."),
	ECVF_RenderThreadSafe);

#endif

/** Global vertex color view mode setting when SHOW_VertexColors show flag is set */

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)

static TAutoConsoleVariable<float> CVarOverrideTimeMaterialExpressions(
	TEXT("r.Test.OverrideTimeMaterialExpressions"), -1.0f,
	TEXT("Value to freeze time material expressions with."),
	ECVF_RenderThreadSafe);

#endif

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

Scope (from outer to inner):

file
function     void FSceneView::SetupCommonViewUniformBufferParameters

Source code excerpt:


#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
	float OverrideTimeMaterialExpression = CVarOverrideTimeMaterialExpressions.GetValueOnRenderThread();
	if (OverrideTimeMaterialExpression >= 0.0f)
	{
		ViewUniformShaderParameters.PrevFrameGameTime = OverrideTimeMaterialExpression;
		ViewUniformShaderParameters.PrevFrameRealTime = OverrideTimeMaterialExpression;
		ViewUniformShaderParameters.GameTime = OverrideTimeMaterialExpression;
		ViewUniformShaderParameters.RealTime = OverrideTimeMaterialExpression;