r.GPUParticle.FixDeltaSeconds
r.GPUParticle.FixDeltaSeconds
#Overview
name: r.GPUParticle.FixDeltaSeconds
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
GPU particle fix delta seconds.
It is referenced in 7
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.GPUParticle.FixDeltaSeconds is to set a fixed delta time for GPU particle simulation. This setting is part of the particle system in Unreal Engine 5, specifically for GPU-based particle simulation.
-
The variable is used in the Engine’s particle simulation system, particularly in the GPU-based particle simulation module.
-
The value of this variable is set as a console variable, with a default value of 1/30 seconds (approximately 0.0333 seconds). This allows games targeting 30 fps and 60 fps to have single iteration updates.
-
Several other variables interact with it:
- CVarGPUParticleFixTolerance: Sets the tolerance for switching to a fixed delta time.
- CVarGPUParticleMaxNumIterations: Sets the maximum number of iterations when using a fixed delta time.
- CVarSimulateGPUParticles: Enables or disables GPU particle simulation.
-
Developers should be aware that this variable affects the simulation step size for GPU particles. When set to a value greater than 0, it forces the simulation to use this fixed time step instead of the actual frame delta time.
-
Best practices when using this variable:
- Use it to achieve consistent particle behavior across different frame rates.
- Be cautious when changing this value, as it can affect the visual quality and performance of particle systems.
- Consider the target frame rate of your game when adjusting this value.
Regarding the associated variable CVarGPUParticleFixDeltaSeconds:
- This is the actual console variable that stores the value of r.GPUParticle.FixDeltaSeconds.
- It’s used throughout the GPU particle simulation code to retrieve the current fixed delta time value.
- The variable is typically accessed using GetValueOnRenderThread() or GetValueOnAnyThread() methods, depending on the context.
- It’s used in various parts of the particle simulation process, including texture resource selection, parameter setup, and simulation loop control.
- When working with this variable, developers should ensure they’re using the appropriate getter method based on the execution context (render thread vs. game thread) to avoid potential race conditions or inconsistent behavior.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/ParticleGpuSimulation.cpp:121
Scope: file
Source code excerpt:
// Using a fix step 1/30, allows game targetting 30 fps and 60 fps to have single iteration updates.
static TAutoConsoleVariable<float> CVarGPUParticleFixDeltaSeconds(TEXT("r.GPUParticle.FixDeltaSeconds"), 1.f/30.f,TEXT("GPU particle fix delta seconds."));
static TAutoConsoleVariable<float> CVarGPUParticleFixTolerance(TEXT("r.GPUParticle.FixTolerance"),.1f,TEXT("Delta second tolerance before switching to a fix delta seconds."));
static TAutoConsoleVariable<int32> CVarGPUParticleMaxNumIterations(TEXT("r.GPUParticle.MaxNumIterations"),3,TEXT("Max number of iteration when using a fix delta seconds."));
static TAutoConsoleVariable<int32> CVarSimulateGPUParticles(TEXT("r.GPUParticle.Simulate"), 1, TEXT("Enable or disable GPU particle simulation"));
/*-----------------------------------------------------------------------------
#Associated Variable and Callsites
This variable is associated with another variable named CVarGPUParticleFixDeltaSeconds
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/ParticleGpuSimulation.cpp:121
Scope: file
Source code excerpt:
// Using a fix step 1/30, allows game targetting 30 fps and 60 fps to have single iteration updates.
static TAutoConsoleVariable<float> CVarGPUParticleFixDeltaSeconds(TEXT("r.GPUParticle.FixDeltaSeconds"), 1.f/30.f,TEXT("GPU particle fix delta seconds."));
static TAutoConsoleVariable<float> CVarGPUParticleFixTolerance(TEXT("r.GPUParticle.FixTolerance"),.1f,TEXT("Delta second tolerance before switching to a fix delta seconds."));
static TAutoConsoleVariable<int32> CVarGPUParticleMaxNumIterations(TEXT("r.GPUParticle.MaxNumIterations"),3,TEXT("Max number of iteration when using a fix delta seconds."));
static TAutoConsoleVariable<int32> CVarSimulateGPUParticles(TEXT("r.GPUParticle.Simulate"), 1, TEXT("Enable or disable GPU particle simulation"));
/*-----------------------------------------------------------------------------
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/ParticleGpuSimulation.cpp:641
Scope (from outer to inner):
file
class class FParticleSimulationResources
function FParticleStateTextures& GetVisualizeStateTextures
Source code excerpt:
FParticleStateTextures& GetVisualizeStateTextures()
{
const float FixDeltaSeconds = CVarGPUParticleFixDeltaSeconds.GetValueOnRenderThread();
if (FixDeltaSeconds > 0)
{
return GetPreviousStateTextures();
}
else
{
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/ParticleGpuSimulation.cpp:1091
Scope (from outer to inner):
file
function FParticlePerFrameSimulationShaderParameters GetParticlePerFrameSimulationShaderParameters
Source code excerpt:
// The offset must only be applied once in the frame, and be stored in the persistent data (not the interpolated one).
const float FixDeltaSeconds = CVarGPUParticleFixDeltaSeconds.GetValueOnRenderThread();
const bool bApplyOffset = FixDeltaSeconds <= 0 || bUseFixDT;
const FVector4f OnlyAttractorStrength = FVector4f(0, 0, 0, Parameters.PositionOffsetAndAttractorStrength.W);
Result.PointAttractor = Parameters.PointAttractor;
Result.PositionOffsetAndAttractorStrength = bApplyOffset ? Parameters.PositionOffsetAndAttractorStrength : OnlyAttractorStrength;
Result.LocalToWorldScale = Parameters.LocalToWorldScale;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/ParticleGpuSimulation.cpp:1499
Scope (from outer to inner):
file
function void ExecuteSimulationCommands
Source code excerpt:
SCOPED_UNIFORM_BUFFER_STATIC_BINDINGS(RHICmdList, StaticUniformBuffers);
const float FixDeltaSeconds = CVarGPUParticleFixDeltaSeconds.GetValueOnRenderThread();
const FParticleStateTextures& TextureResources = (FixDeltaSeconds <= 0 || bUseFixDT) ? ParticleSimulationResources->GetPreviousStateTextures() : ParticleSimulationResources->GetCurrentStateTextures();
const FParticleAttributesTexture& AttributeTexture = ParticleSimulationResources->SimulationAttributesTexture;
const FParticleAttributesTexture& RenderAttributeTexture = ParticleSimulationResources->RenderAttributesTexture;
// Grab shaders.
TShaderMapRef<FParticleTileVS> VertexShader(GetGlobalShaderMap(FeatureLevel));
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/ParticleGpuSimulation.cpp:3396
Scope (from outer to inner):
file
class class FGPUSpriteParticleEmitterInstance : public FParticleEmitterInstance
function virtual FDynamicEmitterDataBase* GetDynamicData
Source code excerpt:
int32& NumIterationsInVar = DynamicData->PerFrameSimulationParameters.NumIterationsInVar;
const float FixDeltaSeconds = CVarGPUParticleFixDeltaSeconds.GetValueOnAnyThread();
const float FixTolerance = CVarGPUParticleFixTolerance.GetValueOnAnyThread();
const int32 MaxNumIterations = CVarGPUParticleMaxNumIterations.GetValueOnAnyThread();
DeltaSecondsInFix = FixDeltaSeconds;
NumIterationsInFix = 0;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/ParticleGpuSimulation.cpp:4757
Scope (from outer to inner):
file
function void FFXSystem::SimulateGPUParticles
Source code excerpt:
SCOPE_CYCLE_COUNTER(STAT_GPUParticleTickTime);
const float FixDeltaSeconds = CVarGPUParticleFixDeltaSeconds.GetValueOnRenderThread();
// Grab resources.
FParticleStateTextures& CurrentStateTextures = ParticleSimulationResources->GetCurrentStateTextures();
FParticleStateTextures& PrevStateTextures = ParticleSimulationResources->GetPreviousStateTextures();
// Setup render states.