MaterialBaking.ForceDisableEmissiveScaling
MaterialBaking.ForceDisableEmissiveScaling
#Overview
name: MaterialBaking.ForceDisableEmissiveScaling
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If set to true, values stored in the emissive textures will be clamped to the [0, 1] range rather than being normalized and scaled back using the EmissiveScale material static parameter.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of MaterialBaking.ForceDisableEmissiveScaling is to control how emissive textures are processed during material baking in Unreal Engine 5. Specifically, it determines whether emissive texture values should be clamped to the [0, 1] range or normalized and scaled using the EmissiveScale material static parameter.
This setting variable is primarily used by the Material Baking subsystem within Unreal Engine 5. It is part of the MaterialBaking module, which is responsible for baking materials into textures.
The value of this variable is set through a console variable (CVar) system, which allows it to be changed at runtime or through configuration files. By default, it is set to false.
The associated variable CVarMaterialBakingForceDisableEmissiveScaling directly interacts with MaterialBaking.ForceDisableEmissiveScaling. They share the same value and purpose.
Developers must be aware that when this variable is set to true, it will change how emissive textures are processed during material baking. Instead of normalizing and scaling the values, they will be clamped to the [0, 1] range. This can affect the final appearance of emissive materials in the baked result.
Best practices when using this variable include:
- Only enable it when you specifically want to disable emissive scaling and clamping.
- Be consistent in its usage across your project to avoid unexpected results.
- Document its usage in your project guidelines to ensure all team members are aware of its effects.
- Test the visual results with both settings to determine which is more appropriate for your specific use case.
Regarding the associated variable CVarMaterialBakingForceDisableEmissiveScaling:
The purpose of CVarMaterialBakingForceDisableEmissiveScaling is to provide a runtime-configurable way to control the MaterialBaking.ForceDisableEmissiveScaling setting.
This console variable is used within the MaterialBaking module to retrieve the current value of the setting. It’s queried in the GetCRC function and the ProcessEmissiveOutput function, indicating that it affects both the material baking process and potentially caching or versioning of baked materials.
The value of this variable can be set through console commands or configuration files that support CVar settings.
CVarMaterialBakingForceDisableEmissiveScaling directly controls the behavior of MaterialBaking.ForceDisableEmissiveScaling. They are essentially two interfaces to the same underlying setting.
Developers should be aware that changes to this CVar will take effect immediately, potentially affecting ongoing or future material baking operations.
Best practices for using this CVar include:
- Use it for debugging or testing different emissive scaling behaviors without recompiling code.
- Be cautious when changing its value in a production environment, as it can affect the consistency of baked materials.
- Consider exposing it in your project’s settings UI if you want to give artists control over this behavior.
- Log or track changes to this CVar if you need to diagnose issues related to material baking.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Developer/MaterialBaking/Private/MaterialBakingModule.cpp:69
Scope: file
Source code excerpt:
static TAutoConsoleVariable<bool> CVarMaterialBakingForceDisableEmissiveScaling(
TEXT("MaterialBaking.ForceDisableEmissiveScaling"),
false,
TEXT("If set to true, values stored in the emissive textures will be clamped to the [0, 1] range rather than being normalized and scaled back using the EmissiveScale material static parameter."));
namespace
{
// Custom dynamic mesh allocator specifically tailored for Material Baking.
#Associated Variable and Callsites
This variable is associated with another variable named CVarMaterialBakingForceDisableEmissiveScaling
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Developer/MaterialBaking/Private/MaterialBakingModule.cpp:68
Scope: file
Source code excerpt:
TEXT("Number of frames to render for virtual texture warmup when material baking."));
static TAutoConsoleVariable<bool> CVarMaterialBakingForceDisableEmissiveScaling(
TEXT("MaterialBaking.ForceDisableEmissiveScaling"),
false,
TEXT("If set to true, values stored in the emissive textures will be clamped to the [0, 1] range rather than being normalized and scaled back using the EmissiveScale material static parameter."));
namespace
{
#Loc: <Workspace>/Engine/Source/Developer/MaterialBaking/Private/MaterialBakingModule.cpp:350
Scope (from outer to inner):
file
function uint32 FMaterialBakingModule::GetCRC
Source code excerpt:
Ar << VTWarmupFrames;
bool ForceDisableEmissiveScaling = CVarMaterialBakingForceDisableEmissiveScaling.GetValueOnAnyThread();
Ar << ForceDisableEmissiveScaling;
return Ar.GetCrc();
}
FMaterialDataEx ToMaterialDataEx(const FMaterialData& MaterialData)
#Loc: <Workspace>/Engine/Source/Developer/MaterialBaking/Private/MaterialBakingModule.cpp:1274
Scope (from outer to inner):
file
function void ProcessEmissiveOutput
Source code excerpt:
const int32 LinesPerThread = FMath::CeilToInt((float)OutputSize.Y / (float)NumThreads);
const FFloat16Color BackgroundColor16 = FFloat16Color(FLinearColor(BackgroundColor)); // Can assume emissive always uses sRGB
const bool bShouldNormalize = CVarMaterialBakingForceDisableEmissiveScaling.GetValueOnAnyThread() == 0;
float GlobalMaxValue = 1.0f;
if (bShouldNormalize)
{
float* MaxValue = new float[NumThreads];
FMemory::Memset(MaxValue, 0, NumThreads * sizeof(MaxValue[0]));