demo.ViewTargetPriorityScale
demo.ViewTargetPriorityScale
#Overview
name: demo.ViewTargetPriorityScale
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Scale view target priority by this value when prioritization is enabled.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of demo.ViewTargetPriorityScale
is to scale the priority of the view target during demo recording in Unreal Engine 5. This setting is specifically used in the demo recording and playback system.
The Unreal Engine subsystem that relies on this setting variable is the Demo Net Driver, which is part of the Engine module. This can be seen from the file path Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp
.
The value of this variable is set as a console variable with a default value of 3.0. It can be changed at runtime through the console or configuration files.
This variable interacts with the replay priority system. It’s used to multiply the priority of the current view target, effectively increasing its importance during demo recording.
Developers must be aware that this variable directly affects the prioritization of actors during demo recording. A higher value will make the view target more likely to be recorded with higher fidelity, potentially at the expense of other actors in the scene.
Best practices when using this variable include:
- Adjusting it based on the specific needs of your project. If the view target is crucial for your replay, you might want to increase this value.
- Testing different values to find the right balance between view target priority and overall replay quality.
- Being mindful of performance implications when increasing this value, as it might lead to more data being recorded for the view target.
The associated variable CVarDemoViewTargetPriorityScale
is the actual console variable that holds the value of demo.ViewTargetPriorityScale
. It’s defined using TAutoConsoleVariable<float>
, which means it’s a float value that can be changed at runtime through the console.
This associated variable is used directly in the TickDemoRecordFrame
function of the UDemoNetDriver
class. When calculating the replay priority for actors, if the current actor is the view target, its priority is multiplied by the value of CVarDemoViewTargetPriorityScale
.
Developers should be aware that changes to this console variable will take effect immediately during the next frame of demo recording. They should also note that extremely high values might lead to the view target dominating the recorded data, potentially at the expense of other important actors or events in the scene.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:143
Scope (from outer to inner):
file
namespace DemoNetDriverRecordingPrivate
Source code excerpt:
static TAutoConsoleVariable<int32> CVarDemoDestructionInfoPriority(TEXT("demo.DestructionInfoPriority"), MAX_int32, TEXT("Replay net priority assigned to destruction infos during recording."));
static TAutoConsoleVariable<int32> CVarDemoLateDestructionInfoPrioritize(TEXT("demo.LateDestructionInfoPrioritize"), 0, TEXT("If true, process destruction infos at the end of the prioritization phase."));
static TAutoConsoleVariable<float> CVarDemoViewTargetPriorityScale(TEXT("demo.ViewTargetPriorityScale"), 3.0, TEXT("Scale view target priority by this value when prioritization is enabled."));
static TAutoConsoleVariable<float> CVarDemoMaximumRecDestructionInfoTime(TEXT("demo.MaximumRecDestructionInfoTime"), 0.2, TEXT("Maximum percentage of frame to use replicating destruction infos, if per frame limit is enabled."));
static FAutoConsoleCommandWithWorldAndArgs DemoMaxDesiredRecordTimeMS(
TEXT("Demo.MaxDesiredRecordTimeMS"),
TEXT("Set max desired record time in MS on demo driver of the current world."),
FConsoleCommandWithWorldAndArgsDelegate::CreateStatic(
#Associated Variable and Callsites
This variable is associated with another variable named CVarDemoViewTargetPriorityScale
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:143
Scope (from outer to inner):
file
namespace DemoNetDriverRecordingPrivate
Source code excerpt:
static TAutoConsoleVariable<int32> CVarDemoDestructionInfoPriority(TEXT("demo.DestructionInfoPriority"), MAX_int32, TEXT("Replay net priority assigned to destruction infos during recording."));
static TAutoConsoleVariable<int32> CVarDemoLateDestructionInfoPrioritize(TEXT("demo.LateDestructionInfoPrioritize"), 0, TEXT("If true, process destruction infos at the end of the prioritization phase."));
static TAutoConsoleVariable<float> CVarDemoViewTargetPriorityScale(TEXT("demo.ViewTargetPriorityScale"), 3.0, TEXT("Scale view target priority by this value when prioritization is enabled."));
static TAutoConsoleVariable<float> CVarDemoMaximumRecDestructionInfoTime(TEXT("demo.MaximumRecDestructionInfoTime"), 0.2, TEXT("Maximum percentage of frame to use replicating destruction infos, if per frame limit is enabled."));
static FAutoConsoleCommandWithWorldAndArgs DemoMaxDesiredRecordTimeMS(
TEXT("Demo.MaxDesiredRecordTimeMS"),
TEXT("Set max desired record time in MS on demo driver of the current world."),
FConsoleCommandWithWorldAndArgsDelegate::CreateStatic(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:2068
Scope (from outer to inner):
file
function void UDemoNetDriver::TickDemoRecordFrame
Source code excerpt:
if (Actor == ViewTarget)
{
ReplayPriority = ReplayPriority * DemoNetDriverRecordingPrivate::CVarDemoViewTargetPriorityScale.GetValueOnAnyThread();
}
// clamp into a valid range prior to rounding to avoid potential undefined behavior
ActorPriority.Priority = FMath::RoundToInt(FMath::Clamp(ReplayPriority, (float)(MIN_int32 + 10), (float)(MAX_int32 - 10)));
}