MaterialBaking.SaveIntermediateTextures

MaterialBaking.SaveIntermediateTextures

#Overview

name: MaterialBaking.SaveIntermediateTextures

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 MaterialBaking.SaveIntermediateTextures is to control whether intermediate BMP images are saved for each flattened material property during the material baking process in Unreal Engine 5.

This setting variable is primarily used in the Material Baking system, which is part of the MaterialBaking module in Unreal Engine. The MaterialBaking module is responsible for flattening complex materials into simpler representations, which can be useful for optimizing performance or preparing assets for certain rendering techniques.

The value of this variable is set as a console variable using the TAutoConsoleVariable class. It is initialized with a default value of 0 (turned off) but can be changed at runtime through the console or configuration files.

The associated variable CVarSaveIntermediateTextures directly interacts with MaterialBaking.SaveIntermediateTextures. They share the same value and purpose. CVarSaveIntermediateTextures is used in the code to actually check and apply the setting.

Developers must be aware that enabling this variable (setting it to 1) will cause the engine to save out intermediate BMP images for each flattened material property. This can be useful for debugging or inspecting the material baking process, but it may also increase disk usage and potentially impact performance during the baking process.

Best practices when using this variable include:

  1. Keep it disabled (0) for production builds to avoid unnecessary file generation and potential performance impacts.
  2. Enable it (1) when debugging material baking issues or when you need to inspect the intermediate results of the baking process.
  3. Be mindful of disk space when enabling this option, especially when working with large numbers of materials or high-resolution textures.

Regarding the associated variable CVarSaveIntermediateTextures:

The purpose of CVarSaveIntermediateTextures is to provide a programmatic way to access and modify the MaterialBaking.SaveIntermediateTextures setting within the C++ code of the MaterialBaking module.

This variable is used in the FMaterialBakingProcessor class to determine whether intermediate textures should be saved during the material baking process. It’s accessed using the GetValueOnAnyThread() method, which suggests that this setting can be safely read from multiple threads.

The value of CVarSaveIntermediateTextures is set through the console variable system, which allows it to be changed at runtime without recompiling the engine.

Developers should be aware that changes to this variable will affect the behavior of the material baking process. Enabling it may increase processing time and disk usage, but can be valuable for debugging and development purposes.

Best practices for using CVarSaveIntermediateTextures include:

  1. Use it in conjunction with logging or debugging systems to help diagnose issues in the material baking process.
  2. Consider exposing this option in your development tools or editor interfaces to allow easy toggling during the asset creation process.
  3. Ensure that any code relying on the saved intermediate textures checks for their existence, as they may not always be available depending on this setting.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Developer/MaterialBaking/Private/MaterialBakingModule.cpp:48

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarSaveIntermediateTextures(
	TEXT("MaterialBaking.SaveIntermediateTextures"),
	0,
	TEXT("Determines whether or not to save out intermediate BMP images for each flattened material property.\n")
	TEXT("0: Turned Off\n")
	TEXT("1: Turned On"),
	ECVF_Default);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Developer/MaterialBaking/Private/MaterialBakingModule.cpp:47

Scope: file

Source code excerpt:

	ECVF_Default);

static TAutoConsoleVariable<int32> CVarSaveIntermediateTextures(
	TEXT("MaterialBaking.SaveIntermediateTextures"),
	0,
	TEXT("Determines whether or not to save out intermediate BMP images for each flattened material property.\n")
	TEXT("0: Turned Off\n")
	TEXT("1: Turned On"),
	ECVF_Default);

#Loc: <Workspace>/Engine/Source/Developer/MaterialBaking/Private/MaterialBakingModule.cpp:458

Scope (from outer to inner):

file
class        class FMaterialBakingProcessor
function     FMaterialBakingProcessor

Source code excerpt:

		, MaterialSettings(InMaterialSettings)
		, MeshSettings(InMeshSettings)
		, bSaveIntermediateTextures(CVarSaveIntermediateTextures.GetValueOnAnyThread() == 1)
		, bEmissiveHDR(InMaterialBakingModule.bEmissiveHDR)
	{
		checkf(MaterialSettings.Num() == MeshSettings.Num(), TEXT("Number of material settings does not match that of MeshSettings"));

		UE_LOG(LogMaterialBaking, Verbose, TEXT("Performing material baking for %d materials"), MaterialSettings.Num());
		for (int32 i = 0; i < MaterialSettings.Num(); i++)