r.RayTracing.EnableInEditor
r.RayTracing.EnableInEditor
#Overview
name: r.RayTracing.EnableInEditor
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Controls whether ray tracing effects are available by default when running the editor. This can be useful to improve editor performance when only some people require ray tracing features. (default = 1)
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RayTracing.EnableInEditor is to control whether ray tracing effects are available by default when running the Unreal Engine editor. This setting is primarily used for the rendering system, specifically for ray tracing features.
This setting variable is primarily used in the RenderCore module of Unreal Engine 5. It affects the initialization of ray tracing features and the overall rendering pipeline.
The value of this variable is set through the console variable system in Unreal Engine. It’s defined as an FAutoConsoleVariableRef, which means it can be changed at runtime through console commands or configuration files.
The r.RayTracing.EnableInEditor variable interacts closely with GRayTracingEnableInEditor, which is the associated C++ variable that stores the actual value. They share the same value, with GRayTracingEnableInEditor being the internal representation used in the C++ code.
Developers must be aware that this variable affects editor performance. Enabling ray tracing in the editor can be resource-intensive, so it’s important to consider the hardware capabilities of the development team when setting this value.
Best practices for using this variable include:
- Setting it to 0 (disabled) if ray tracing features are not needed in the editor to improve performance.
- Enabling it (set to 1) only for team members who specifically require ray tracing features for their work.
- Being aware that changing this setting requires a restart of the editor to take effect.
Regarding the associated variable GRayTracingEnableInEditor:
The purpose of GRayTracingEnableInEditor is to store the actual value of the r.RayTracing.EnableInEditor setting within the C++ code.
This variable is used in the RenderCore module, specifically in the RenderUtils.cpp file. It’s used during the initialization of the rendering system to determine whether ray tracing should be enabled in the editor.
The value of GRayTracingEnableInEditor is set by the console variable system when r.RayTracing.EnableInEditor is initialized or changed.
GRayTracingEnableInEditor interacts with other ray tracing related variables, such as GRayTracingMode, to determine the overall ray tracing configuration of the engine.
Developers should be aware that this variable is marked as ECVF_ReadOnly, meaning it can’t be changed at runtime after initialization. Changes to this variable require a restart of the editor to take effect.
Best practices for using GRayTracingEnableInEditor include:
- Avoiding direct modification of this variable in code. Instead, use the r.RayTracing.EnableInEditor console variable to change its value.
- Using this variable in conditions where you need to check if ray tracing is enabled in the editor, rather than checking the console variable directly for potentially better performance.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderUtils.cpp:52
Scope: file
Source code excerpt:
int32 GRayTracingEnableInEditor = 1;
FAutoConsoleVariableRef CVarRayTracingEnableInEditor(
TEXT("r.RayTracing.EnableInEditor"),
GRayTracingEnableInEditor,
TEXT("Controls whether ray tracing effects are available by default when running the editor. This can be useful to improve editor performance when only some people require ray tracing features. ")
TEXT("(default = 1)"),
ECVF_ReadOnly
);
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderUtils.cpp:873
Scope (from outer to inner):
file
function RENDERCORE_API void RenderUtilsInit
Source code excerpt:
// - Skin cache must be enabled for the project
// - Current GPU, OS and driver must support ray tracing
// - User is running the Editor and r.RayTracing.EnableInEditor=1
// *OR* running the game with ray tracing enabled in graphics options
// When ray tracing is enabled, we must load additional shaders and build acceleration structures for meshes.
// For this reason it is only possible to enable RT at startup and changing the state requires restart.
// This is also the reason why IsRayTracingEnabled() lives in RenderCore module, as it controls creation of
// RT pipelines in ShaderPipelineCache.cpp.
#Associated Variable and Callsites
This variable is associated with another variable named GRayTracingEnableInEditor
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderUtils.cpp:50
Scope: file
Source code excerpt:
);
int32 GRayTracingEnableInEditor = 1;
FAutoConsoleVariableRef CVarRayTracingEnableInEditor(
TEXT("r.RayTracing.EnableInEditor"),
GRayTracingEnableInEditor,
TEXT("Controls whether ray tracing effects are available by default when running the editor. This can be useful to improve editor performance when only some people require ray tracing features. ")
TEXT("(default = 1)"),
ECVF_ReadOnly
);
static int32 GRayTracingEnableOnDemand = 0;
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderUtils.cpp:922
Scope (from outer to inner):
file
function void RenderUtilsInit
Source code excerpt:
// therefore the core ray tracing features are also enabled, so that required shaders
// are loaded, acceleration structures are built, etc.
GRayTracingMode = (GRayTracingEnableInEditor != 0) ? DesiredRayTracingMode : ERayTracingMode::Disabled;
UE_LOG(LogRendererCore, Log, TEXT("Ray tracing is %s for the editor. Reason: r.RayTracing=%d and r.RayTracing.EnableInEditor=%d."),
GetRayTracingModeName(GRayTracingMode),
RayTracingInt,
GRayTracingEnableInEditor);
}
else
{
// If user preference exists in game settings file, the bRayTracingEnabled will be set based on its value.
// Otherwise the current value is preserved.
bool bUseRayTracing = false;