r.MaterialEditor.LWCTruncateMode
r.MaterialEditor.LWCTruncateMode
#Overview
name: r.MaterialEditor.LWCTruncateMode
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether or not the material compiler respects the truncate LWC node or automatic transforms.\n0: no truncate (LWC always used even if asked to truncate)\n1: respect the truncate LWC node\n2: respect the truncate LWC node and automatic transforms
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.MaterialEditor.LWCTruncateMode is to control how the material compiler handles Large World Coordinates (LWC) truncation in the material editor. It specifically determines whether the compiler respects the truncate LWC node and automatic transforms.
This setting variable is primarily used in the material compilation and shader generation systems of Unreal Engine. Based on the callsites, it’s evident that the Engine, RenderCore, and Core modules rely on this variable.
The value of this variable is set through the console variable system, with a default value of 2. It can be accessed and modified at runtime using console commands or through configuration files.
The variable interacts with the material compilation process, particularly affecting how LWC nodes are handled. It has three possible values: 0: No truncation (LWC always used even if asked to truncate) 1: Respect the truncate LWC node 2: Respect both the truncate LWC node and automatic transforms
Developers must be aware that changing this variable can affect the behavior of materials, especially those using LWC nodes or relying on automatic transforms. It’s a read-only variable, meaning its value should not be changed frequently during runtime.
Best practices when using this variable include:
- Understanding the implications of each mode on material behavior and performance.
- Setting it appropriately based on the project’s requirements for large world coordinates.
- Ensuring consistency across development and production environments to avoid unexpected material behavior.
- Documenting the chosen mode and its rationale in the project’s technical documentation.
- Testing materials thoroughly when changing this setting to ensure desired behavior across different scenarios.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/ConsoleManager.cpp:3901
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarLWCTruncateMode(
TEXT("r.MaterialEditor.LWCTruncateMode"),
2,
TEXT("Whether or not the material compiler respects the truncate LWC node or automatic transforms.\n"
"0: no truncate (LWC always used even if asked to truncate)\n"
"1: respect the truncate LWC node\n"
"2: respect the truncate LWC node and automatic transforms"),
ECVF_ReadOnly);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Materials/HLSLMaterialTranslator.cpp:126
Scope (from outer to inner):
file
function static int32 GetLWCTruncateMode
Source code excerpt:
static int32 GetLWCTruncateMode()
{
static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.MaterialEditor.LWCTruncateMode"));
const int32 LWCTruncateValue = CVar ? CVar->GetValueOnAnyThread() : 0;
return LWCTruncateValue;
}
bool IsExpressionClassPermitted(const UClass* const Class)
{
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/Shader.cpp:1548
Scope (from outer to inner):
file
function void ShaderMapAppendKeyString
Source code excerpt:
{
static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.MaterialEditor.LWCTruncateMode"));
const int32 LWCTruncateValue = CVar ? CVar->GetValueOnAnyThread() : 0;
if (LWCTruncateValue == 1)
{
KeyString += TEXT("_LWC1");
}
else if (LWCTruncateValue == 2)