r.GPUParticle.FixTolerance

r.GPUParticle.FixTolerance

#Overview

name: r.GPUParticle.FixTolerance

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.GPUParticle.FixTolerance is to set a delta second tolerance before switching to a fixed delta seconds for GPU particle simulation. This setting is part of the GPU particle simulation system in Unreal Engine 5.

This setting variable is primarily used in the particle simulation subsystem, specifically for GPU-based particle simulations. It is part of the Engine module, as evidenced by its location in the Engine/Source/Runtime/Engine/Private/Particles/ParticleGpuSimulation.cpp file.

The value of this variable is set using a TAutoConsoleVariable, which means it can be adjusted at runtime through the console or configuration files. Its default value is set to 0.1f.

This variable interacts closely with other GPU particle simulation settings, particularly:

  1. r.GPUParticle.FixDeltaSeconds: Sets the fixed delta seconds for GPU particle simulation.
  2. r.GPUParticle.MaxNumIterations: Sets the maximum number of iterations when using a fixed delta seconds.

Developers should be aware that this variable is part of a system that allows for frame rate independent particle simulation. It helps determine when the simulation should switch from variable time steps to fixed time steps, which can be crucial for maintaining consistent particle behavior across different frame rates.

Best practices when using this variable include:

  1. Adjusting it in conjunction with r.GPUParticle.FixDeltaSeconds and r.GPUParticle.MaxNumIterations for optimal performance and visual quality.
  2. Testing particle systems at various frame rates to ensure consistent behavior.
  3. Being cautious when modifying this value, as it can affect the visual consistency of particle systems across different hardware or frame rates.

Regarding the associated variable CVarGPUParticleFixTolerance: This is the actual console variable object that holds the value of r.GPUParticle.FixTolerance. It’s used internally by the engine to access and modify the tolerance value. The variable is defined as a static TAutoConsoleVariable, allowing for runtime adjustments.

This associated variable is used in the FGPUSpriteParticleEmitterInstance class when calculating delta times for particle simulation. It’s retrieved using the GetValueOnAnyThread() method, which suggests that it can be accessed from multiple threads safely.

Developers should note that while they can interact with the r.GPUParticle.FixTolerance setting directly, the engine internally uses CVarGPUParticleFixTolerance to access and apply this value in the particle simulation code.

#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:122

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"));

/*-----------------------------------------------------------------------------
	Allocators used to manage GPU particle resources.

#Associated Variable and Callsites

This variable is associated with another variable named CVarGPUParticleFixTolerance. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/ParticleGpuSimulation.cpp:122

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"));

/*-----------------------------------------------------------------------------
	Allocators used to manage GPU particle resources.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/ParticleGpuSimulation.cpp:3397

Scope (from outer to inner):

file
class        class FGPUSpriteParticleEmitterInstance : public FParticleEmitterInstance
function     virtual FDynamicEmitterDataBase* GetDynamicData

Source code excerpt:

			
			const float FixDeltaSeconds = CVarGPUParticleFixDeltaSeconds.GetValueOnAnyThread();
			const float FixTolerance = CVarGPUParticleFixTolerance.GetValueOnAnyThread();
			const int32 MaxNumIterations = CVarGPUParticleMaxNumIterations.GetValueOnAnyThread();

			DeltaSecondsInFix = FixDeltaSeconds;
			NumIterationsInFix = 0;

			DeltaSecondsInVar = PendingDeltaSeconds + OffsetSeconds;