r.RayTracing.EnableInGame
r.RayTracing.EnableInGame
#Overview
name: r.RayTracing.EnableInGame
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Controls the default state of ray tracing effects when running the game. This setting is overridden by its counterpart in GameUserSettings.ini (if it exists) to allow control through in-game UI. (default = 1)
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RayTracing.EnableInGame is to control the default state of ray tracing effects when running the game. It is primarily used for the rendering system, specifically for ray tracing functionality.
This setting variable is relied upon by Unreal Engine’s rendering subsystem, particularly the ray tracing module. It’s part of the RenderCore module, as evidenced by its location in the RenderUtils.cpp file.
The value of this variable is initially set to 1 (enabled) in the C++ code. However, it can be overridden by a corresponding setting in the GameUserSettings.ini file, allowing for control through in-game UI.
The variable interacts closely with GRayTracingEnableInGame, which is its associated C++ variable. It also interacts with other ray tracing-related variables and settings, such as GRayTracingMode and the “r.RayTracing” console variable.
Developers must be aware that this setting can be overridden by user settings, so the actual state of ray tracing might differ from the default value set in the code. They should also note that this setting is marked as ECVF_ReadOnly, meaning it cannot be changed at runtime through console commands.
Best practices when using this variable include:
- Ensuring that the GameUserSettings.ini file is properly set up if you want to allow users to control this setting.
- Checking the actual state of ray tracing at runtime rather than assuming based on the default value.
- Considering performance implications when enabling ray tracing, especially for less powerful hardware.
Regarding the associated variable GRayTracingEnableInGame:
The purpose of GRayTracingEnableInGame is to store the actual state of the ray tracing setting in the C++ code. It’s used internally by the engine to determine whether ray tracing should be enabled or disabled.
This variable is used within the RenderCore module, specifically in the RenderUtilsInit() function, to set the GRayTracingMode based on user settings and other factors.
The value of GRayTracingEnableInGame is initially set to 1 in the C++ code, but its actual value at runtime may be influenced by the r.RayTracing.EnableInGame setting from the GameUserSettings.ini file.
GRayTracingEnableInGame interacts directly with the r.RayTracing.EnableInGame console variable and is used in conjunction with other ray tracing-related variables to determine the final ray tracing state.
Developers should be aware that while GRayTracingEnableInGame is the C++ representation of the setting, the actual behavior may be overridden by user settings. They should use this variable for internal logic rather than for user-facing settings.
Best practices for using GRayTracingEnableInGame include:
- Treating it as a read-only variable in most cases, as its value is set based on user settings and engine initialization.
- Using it in conjunction with other ray tracing settings to determine the overall ray tracing state in the engine.
- Considering it as part of a broader ray tracing configuration system rather than a standalone switch.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderUtils.cpp:43
Scope: file
Source code excerpt:
int32 GRayTracingEnableInGame = 1;
FAutoConsoleVariableRef CVarRayTracingEnableInGame(
TEXT("r.RayTracing.EnableInGame"),
GRayTracingEnableInGame,
TEXT("Controls the default state of ray tracing effects when running the game. This setting is overridden by its counterpart in GameUserSettings.ini (if it exists) to allow control through in-game UI. ")
TEXT("(default = 1)"),
ECVF_ReadOnly
);
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderUtils.cpp:942
Scope (from outer to inner):
file
function void RenderUtilsInit
Source code excerpt:
RayTracingInt);
}
else if (GConfig->GetBool(TEXT("RayTracing"), TEXT("r.RayTracing.EnableInGame"), bUseRayTracing, GGameUserSettingsIni))
{
GRayTracingMode = bUseRayTracing ? DesiredRayTracingMode : ERayTracingMode::Disabled;
UE_LOG(LogRendererCore, Log, TEXT("Ray tracing is %s for the game. Reason: game user setting r.RayTracing.EnableInGame=%d."),
GetRayTracingModeName(GRayTracingMode),
(int)bUseRayTracing);
#Associated Variable and Callsites
This variable is associated with another variable named GRayTracingEnableInGame
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderUtils.cpp:41
Scope: file
Source code excerpt:
);
int32 GRayTracingEnableInGame = 1;
FAutoConsoleVariableRef CVarRayTracingEnableInGame(
TEXT("r.RayTracing.EnableInGame"),
GRayTracingEnableInGame,
TEXT("Controls the default state of ray tracing effects when running the game. This setting is overridden by its counterpart in GameUserSettings.ini (if it exists) to allow control through in-game UI. ")
TEXT("(default = 1)"),
ECVF_ReadOnly
);
int32 GRayTracingEnableInEditor = 1;
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderUtils.cpp:952
Scope (from outer to inner):
file
function void RenderUtilsInit
Source code excerpt:
else
{
GRayTracingMode = GRayTracingEnableInGame != 0 ? DesiredRayTracingMode : ERayTracingMode::Disabled;
UE_LOG(LogRendererCore, Log, TEXT("Ray tracing is %s for the game. Reason: CVar r.RayTracing=%d, and r.RayTracing.EnableInGame game user setting does not exist (using default from CVar: %d)."),
GetRayTracingModeName(GRayTracingMode),
RayTracingInt,
GRayTracingEnableInGame);
}
}
// Sanity check: skin cache is *required* for ray tracing.
// It can be dynamically enabled only when its shaders have been compiled.
IConsoleVariable* SkinCacheCompileShadersCVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.SkinCache.CompileShaders"));