r.MaterialEditor.UseDevShaders
r.MaterialEditor.UseDevShaders
#Overview
name: r.MaterialEditor.UseDevShaders
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Toggles whether the material editor will use shaders that include extra overhead incurred by the editor. Material editor must be re-opened if changed at runtime.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.MaterialEditor.UseDevShaders is to control whether the material editor uses development shaders that include extra overhead for editing purposes. This setting is specifically designed for the material editing system within Unreal Engine 5.
This setting variable is primarily used by the Material Editor subsystem, which is part of the editor module in Unreal Engine. It’s referenced in the MaterialEditor.cpp file, indicating its relevance to the material editing functionality.
The value of this variable is set through a console variable (CVarMaterialEdUseDevShaders) with a default value of 1 (enabled). It can be changed at runtime, but the material editor needs to be re-opened for changes to take effect.
The associated variable CVarMaterialEdUseDevShaders directly interacts with r.MaterialEditor.UseDevShaders. They share the same value and purpose.
Developers should be aware that:
- Changing this variable at runtime requires reopening the material editor to apply the changes.
- Enabling this feature (value = 1) may introduce additional overhead in the editor due to the use of development shaders.
- This setting affects the compilation of shaders specifically for the material editor.
Best practices when using this variable include:
- Keep it enabled (default value of 1) during development for better editing capabilities.
- Consider disabling it (set to 0) if performance in the material editor becomes an issue, but be aware that this might limit some editing functionalities.
- Remember to reopen the material editor after changing the value for the changes to take effect.
Regarding the associated variable CVarMaterialEdUseDevShaders:
- It’s a TAutoConsoleVariable
type, allowing for runtime modification via console commands. - It’s used to set the bAllowDevelopmentShaderCompile flag on the Material object in the InitEditorForMaterial function.
- Developers can modify this variable using console commands, which provides flexibility in adjusting the behavior without recompiling the engine.
When working with CVarMaterialEdUseDevShaders, developers should:
- Use the GetValueOnGameThread() method to retrieve its current value safely.
- Be aware that changes to this variable will affect all instances of the material editor.
- Consider the performance implications when enabling or disabling development shaders in the editor.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Editor/MaterialEditor/Private/MaterialEditor.cpp:181
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarMaterialEdUseDevShaders(
TEXT("r.MaterialEditor.UseDevShaders"),
1,
TEXT("Toggles whether the material editor will use shaders that include extra overhead incurred by the editor. Material editor must be re-opened if changed at runtime."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarMaterialEdMaxDerivedMaterialInstances(
TEXT("r.MaterialEditor.MaxDerivedMaterialInstances"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarMaterialEdUseDevShaders
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Editor/MaterialEditor/Private/MaterialEditor.cpp:180
Scope: file
Source code excerpt:
DEFINE_LOG_CATEGORY_STATIC(LogMaterialEditor, Log, All);
static TAutoConsoleVariable<int32> CVarMaterialEdUseDevShaders(
TEXT("r.MaterialEditor.UseDevShaders"),
1,
TEXT("Toggles whether the material editor will use shaders that include extra overhead incurred by the editor. Material editor must be re-opened if changed at runtime."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarMaterialEdMaxDerivedMaterialInstances(
#Loc: <Workspace>/Engine/Source/Editor/MaterialEditor/Private/MaterialEditor.cpp:520
Scope (from outer to inner):
file
function void FMaterialEditor::InitEditorForMaterial
Source code excerpt:
//I'm hackily canceling the jobs here but we should really not add the jobs in the first place. <<--- TODO
Material->bAllowDevelopmentShaderCompile = CVarMaterialEdUseDevShaders.GetValueOnGameThread();
// Ensure there are no null entries
check(Material->GetExpressions().Find(nullptr) == INDEX_NONE);
TArray<FString> Groups;
GetAllMaterialExpressionGroups(&Groups);