r.Shadow.FreezeCamera
r.Shadow.FreezeCamera
#Overview
name: r.Shadow.FreezeCamera
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Debug the shadow methods by allowing to observe the system from outside.\n0: default\n1: freeze camera at current location
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.FreezeCamera is to debug shadow rendering methods by allowing developers to observe the shadow system from a fixed camera position. This setting is part of Unreal Engine’s rendering system, specifically focused on shadow rendering and debugging.
This setting variable is primarily used in the Engine module, particularly within the scene view and rendering subsystems. It’s referenced in SceneView.cpp and SceneView.h, which are core files for handling scene views and camera perspectives.
The value of this variable is set through a console command. It’s defined as a TAutoConsoleVariable with a default value of 0, which can be changed at runtime.
The associated variable CVarShadowFreezeCamera directly interacts with r.Shadow.FreezeCamera. They share the same value and purpose, with CVarShadowFreezeCamera being the actual console variable implementation.
Developers must be aware that this variable is intended for debugging purposes only. It’s marked with ECVF_Cheat flag, indicating it should not be used in production or shipping builds. When activated, it freezes the camera at its current location, which can significantly affect rendering and gameplay.
Best practices for using this variable include:
- Only use it during development and debugging phases.
- Remember to disable it before building for production or shipping.
- Use it in conjunction with other shadow debugging tools for comprehensive shadow system analysis.
- Be cautious when using it in multiplayer or networked environments, as it may cause desynchronization.
Regarding the associated variable CVarShadowFreezeCamera:
The purpose of CVarShadowFreezeCamera is to implement the console variable functionality for r.Shadow.FreezeCamera. It’s the actual variable that stores and manages the freeze camera state.
This variable is used in the Engine module, specifically within the scene view system. It’s defined and used in SceneView.cpp.
The value of CVarShadowFreezeCamera is set through the console command “r.Shadow.FreezeCamera”. It’s initialized with a default value of 0.
CVarShadowFreezeCamera directly controls the behavior of the shadow freezing functionality. When its value is non-zero, it triggers the camera freezing mechanism in the FSceneView::FSceneView function.
Developers should be aware that modifying CVarShadowFreezeCamera directly in code is not recommended. Instead, they should use the console command to change its value.
Best practices for CVarShadowFreezeCamera include:
- Access its value using GetValueOnAnyThread() for thread-safe operations.
- Use it only for debugging purposes and ensure it’s reset to 0 before finalizing development.
- Consider the performance implications when the camera is frozen, as it may affect frame rates and rendering optimizations.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SceneView.cpp:75
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarShadowFreezeCamera(
TEXT("r.Shadow.FreezeCamera"),
0,
TEXT("Debug the shadow methods by allowing to observe the system from outside.\n")
TEXT("0: default\n")
TEXT("1: freeze camera at current location"),
ECVF_Cheat);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/SceneView.h:1304
Scope: file
Source code excerpt:
TOptional<FTransform> PreviousViewTransform;
// normally the same as ViewMatrices unless "r.Shadow.FreezeCamera" is activated
FViewMatrices ShadowViewMatrices;
FMatrix ProjectionMatrixUnadjustedForRHI;
FLinearColor BackgroundColor;
FLinearColor OverlayColor;
#Associated Variable and Callsites
This variable is associated with another variable named CVarShadowFreezeCamera
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SceneView.cpp:74
Scope: file
Source code excerpt:
ECVF_Cheat);
static TAutoConsoleVariable<int32> CVarShadowFreezeCamera(
TEXT("r.Shadow.FreezeCamera"),
0,
TEXT("Debug the shadow methods by allowing to observe the system from outside.\n")
TEXT("0: default\n")
TEXT("1: freeze camera at current location"),
ECVF_Cheat);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SceneView.cpp:933
Scope (from outer to inner):
file
function FSceneView::FSceneView
Source code excerpt:
{
// console variable override
int32 Value = CVarShadowFreezeCamera.GetValueOnAnyThread();
static FViewMatrices Backup = ShadowViewMatrices;
if(Value)
{
ShadowViewMatrices = Backup;