r.MaterialLogErrorOnFailure

r.MaterialLogErrorOnFailure

#Overview

name: r.MaterialLogErrorOnFailure

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.MaterialLogErrorOnFailure is to control the logging behavior when a material fails to compile in Unreal Engine 5. It determines whether material compilation failures should be logged as errors or warnings.

This setting variable is primarily used by the rendering system, specifically in the material compilation process within the Engine module.

The value of this variable is set through a console variable (CVar) declaration in the Material.cpp file. It is initialized as false by default, meaning material compilation failures are logged as warnings unless explicitly changed.

The associated variable CVarMaterialLogErrorOnFailure directly interacts with r.MaterialLogErrorOnFailure. They share the same value and purpose.

Developers must be aware that enabling this variable will change the severity of material compilation failure logs from warnings to errors. This can impact how these issues are perceived and handled in the development process.

Best practices when using this variable include:

  1. Keep it disabled (false) during regular development to avoid excessive error messages.
  2. Enable it (true) when preparing for release or when stricter material compilation checks are required.
  3. Use it in conjunction with other material-related debugging tools for comprehensive material issue detection.

Regarding the associated variable CVarMaterialLogErrorOnFailure:

The purpose of CVarMaterialLogErrorOnFailure is identical to r.MaterialLogErrorOnFailure. It’s the actual C++ variable that implements the console variable functionality.

This variable is used within the Engine module, specifically in the material compilation and error handling process.

The value of CVarMaterialLogErrorOnFailure is set through the TAutoConsoleVariable declaration, which links it to the r.MaterialLogErrorOnFailure console command.

CVarMaterialLogErrorOnFailure directly controls the logging behavior in the HandleCacheShadersForResourcesErrors function, determining whether to log material compilation failures as errors or warnings.

Developers should be aware that changing this variable at runtime will immediately affect the logging behavior of material compilation failures.

Best practices for CVarMaterialLogErrorOnFailure align with those of r.MaterialLogErrorOnFailure, as they are essentially the same setting exposed through different interfaces (console command vs. C++ variable).

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Materials/Material.cpp:115

Scope: file

Source code excerpt:


static TAutoConsoleVariable<bool> CVarMaterialLogErrorOnFailure(
	TEXT("r.MaterialLogErrorOnFailure"),
	false,
	TEXT("When enabled, when a material fails to compile it will issue an Error instead of a Warning.\n")
	TEXT("Default: false"),
	ECVF_RenderThreadSafe);
	
static TAutoConsoleVariable<bool> CVarMaterialsDuplicateVerbatim(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Materials/Material.cpp:114

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<bool> CVarMaterialLogErrorOnFailure(
	TEXT("r.MaterialLogErrorOnFailure"),
	false,
	TEXT("When enabled, when a material fails to compile it will issue an Error instead of a Warning.\n")
	TEXT("Default: false"),
	ECVF_RenderThreadSafe);
	

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Materials/Material.cpp:2534

Scope (from outer to inner):

file
namespace    MaterialImpl
function     void HandleCacheShadersForResourcesErrors

Source code excerpt:

				}
			}
			else if (CVarMaterialLogErrorOnFailure.GetValueOnAnyThread())
			{
				UE_ASSET_LOG(LogMaterial, Error, This, TEXT("%s"), *ErrorString);
			}
			else
			{
				UE_ASSET_LOG(LogMaterial, Warning, This, TEXT("%s"), *ErrorString);