reckfellENGINE

GpuParticles2D

A 2D particle emitter.

On this page
class GpuParticles2DReckfellSharpInherits Entity2D

A 2D particle emitter.

2D particle node used to create a variety of particle systems and effects. GpuParticles2D features an emitter that generates some number of particles at a given rate. Use the GpuParticles2D.ProcessMaterial property to add a ParticleProcessMaterial to configure particle appearance and behavior. Alternatively, you can add a ShaderMaterial which will be applied to all particles. 2D particles can optionally collide with LightOccluder2D, but they don't collide with PhysicsBody2D nodes.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

GpuParticles2DConstructor
# GpuParticles2D
C#
public GpuParticles2D();

Properties26

AmountProperty
# Amount
C#
public int Amount { get; set; }

The number of particles to emit in one emission cycle. The effective emission rate is (amount * amount_ratio) / lifetime particles per second. Higher values will increase GPU requirements, even if not all particles are visible at a given time or if GpuParticles2D.AmountRatio is decreased. Note: Changing this value will cause the particle system to restart. To avoid this, change GpuParticles2D.AmountRatio instead.

AmountRatioProperty
# AmountRatio
C#
public float AmountRatio { get; set; }

The ratio of particles that should actually be emitted. If set to a value lower than 1.0, this will set the amount of emitted particles throughout the lifetime to amount * amount_ratio. Unlike changing GpuParticles2D.Amount, changing GpuParticles2D.AmountRatio while emitting does not affect already-emitted particles and doesn't cause the particle system to restart. GpuParticles2D.AmountRatio can be used to create effects that make the number of emitted particles vary over time. Note: Reducing the GpuParticles2D.AmountRatio has no performance benefit, since resources need to be allocated and processed for the total GpuParticles2D.Amount of particles regardless of the GpuParticles2D.AmountRatio. If you don't intend to change the number of particles emitted while the particles are emitting, make sure GpuParticles2D.AmountRatio is set to 1 and change GpuParticles2D.Amount to your liking instead.

CollisionBaseSizeProperty
# CollisionBaseSize
C#
public float CollisionBaseSize { get; set; }

Multiplier for particle's collision radius. 1.0 corresponds to the size of the sprite. If particles appear to sink into the ground when colliding, increase this value. If particles appear to float when colliding, decrease this value. Only effective if ParticleProcessMaterial.CollisionMode is ParticleProcessMaterial.CollisionModeEnum.Rigid or ParticleProcessMaterial.CollisionModeEnum.HideOnContact. Note: Particles always have a spherical collision shape.

DrawOrderProperty
# DrawOrder
C#
public GpuParticles2D.DrawOrderEnum DrawOrder { get; set; }

Particle draw order.

EmittingProperty
# Emitting
C#
public bool Emitting { get; set; }

Allows new particles to be emitted. false does not delete existing live particles; they remain until their lifetimes end. This is not a full pause or Restart. For OneShot, observe Finished rather than treating Emitting=false as proof that the screen is empty.

ExplosivenessProperty
# Explosiveness
C#
public float Explosiveness { get; set; }

How rapidly particles in an emission cycle are emitted. If greater than 0, there will be a gap in emissions before the next cycle begins.

FixedFpsProperty
# FixedFps
C#
public int FixedFps { get; set; }

The particle system's frame rate is fixed to a value. For example, changing the value to 2 will make the particles render at 2 frames per second. Note this does not slow down the simulation of the particle system itself.

FractDeltaProperty
# FractDelta
C#
public bool FractDelta { get; set; }

If true, results in fractional delta calculation which has a smoother particles display effect.

InterpToEndProperty
# InterpToEnd
C#
public float InterpToEnd { get; set; }

Causes all the particles in this node to interpolate towards the end of their lifetime. Note: This only works when used with a ParticleProcessMaterial. It needs to be manually implemented for custom process shaders.

InterpolateProperty
# Interpolate
C#
public bool Interpolate { get; set; }

Enables particle interpolation, which makes the particle movement smoother when their GpuParticles2D.FixedFps is lower than the screen refresh rate.

LifetimeProperty
# Lifetime
C#
public double Lifetime { get; set; }

The amount of time each particle will exist (in seconds). The effective emission rate is (amount * amount_ratio) / lifetime particles per second.

LocalCoordsProperty
# LocalCoords
C#
public bool LocalCoords { get; set; }

Selects simulation space. With true, previously emitted particles follow emitter transforms; with false, they remain in world canvas space when the emitter subsequently moves. Choose before starting the effect and account for visibility bounds separately.

OneShotProperty
# OneShot
C#
public bool OneShot { get; set; }

If true, only one emission cycle occurs. If set true during a cycle, emission will stop at the cycle's end.

PreprocessProperty
# Preprocess
C#
public double Preprocess { get; set; }

Particle system starts as if it had already run for this many seconds. Note: This can be very expensive if set to a high number as it requires running the particle shader a number of times equal to the GpuParticles2D.FixedFps (or 30, if GpuParticles2D.FixedFps is 0) for every second. In extreme cases it can even lead to a GPU crash due to the volume of work done in a single frame.

ProcessMaterialProperty
# ProcessMaterial
C#
public Material ProcessMaterial { get; set; }

Simulation material, such as ParticleProcessMaterial or ShaderMaterial with a particle shader; separate from the CanvasItem drawing material. Assigning a ParticleProcessMaterial with DisableZ off and default gravity (0,-9.8,0) enables DisableZ and changes gravity to (0,98,0). This also edits a shared resource. Set intended 2D parameters explicitly before assignment.

RandomnessProperty
# Randomness
C#
public float Randomness { get; set; }

Emission lifetime randomness ratio.

SeedProperty
# Seed
C#
public uint Seed { get; set; }

Sets the random seed used by the particle system. Only effective if GpuParticles2D.UseFixedSeed is true.

SpeedScaleProperty
# SpeedScale
C#
public double SpeedScale { get; set; }

Particle system's running speed scaling ratio. A value of 0 can be used to pause the particles.

SubEmitterProperty
# SubEmitter
C#
public EntityPath SubEmitter { get; set; }

Path to another GpuParticles2D node that will be used as a subemitter (see ParticleProcessMaterial.SubEmitterMode). Subemitters can be used to achieve effects such as fireworks, sparks on collision, bubbles popping into water drops, and more. Note: When GpuParticles2D.SubEmitter is set, the target GpuParticles2D node will no longer emit particles on its own.

TextureProperty
# Texture
C#
public Texture2D Texture { get; set; }

Particle texture. If null, particles will be squares with a size of 1×1 pixels. Note: To use a flipbook texture, assign a new CanvasItemMaterial to the GpuParticles2D's CanvasItem.Material property, then enable CanvasItemMaterial.ParticlesAnimation and set CanvasItemMaterial.ParticlesAnimHFrames, CanvasItemMaterial.ParticlesAnimVFrames, and CanvasItemMaterial.ParticlesAnimLoop to match the flipbook texture.

TrailEnabledProperty
# TrailEnabled
C#
public bool TrailEnabled { get; set; }

If true, enables particle trails using a mesh skinning system. Note: Unlike GpuParticles3D, the number of trail sections and subdivisions is set with the GpuParticles2D.TrailSections and GpuParticles2D.TrailSectionSubdivisions properties.

TrailLifetimeProperty
# TrailLifetime
C#
public double TrailLifetime { get; set; }

The amount of time the particle's trail should represent (in seconds). Only effective if GpuParticles2D.TrailEnabled is true.

TrailSectionSubdivisionsProperty
# TrailSectionSubdivisions
C#
public int TrailSectionSubdivisions { get; set; }

The number of subdivisions to use for the particle trail rendering. Higher values can result in smoother trail curves, at the cost of performance due to increased mesh complexity. See also GpuParticles2D.TrailSections. Only effective if GpuParticles2D.TrailEnabled is true.

TrailSectionsProperty
# TrailSections
C#
public int TrailSections { get; set; }

The number of sections to use for the particle trail rendering. Higher values can result in smoother trail curves, at the cost of performance due to increased mesh complexity. See also GpuParticles2D.TrailSectionSubdivisions. Only effective if GpuParticles2D.TrailEnabled is true.

UseFixedSeedProperty
# UseFixedSeed
C#
public bool UseFixedSeed { get; set; }

If true, particles will use the same seed for every simulation using the seed defined in GpuParticles2D.Seed. This is useful for situations where the visual outcome should be consistent across replays, for example when using Movie Maker mode.

VisibilityRectProperty
# VisibilityRect
C#
public Rect2 VisibilityRect { get; set; }

Configured GPU-effect visibility bounds. Used for culling; not a trajectory, physics boundary or per-particle clipping rectangle. Allow for full lifetime, texture size and emitter motion. The verified Compatibility CaptureRect fails for 2D, so the example supplies conservative bounds explicitly.

Methods59

CaptureRectRect2
# CaptureRect
C#
public Rect2 CaptureRect();

Requests current particle bounds from the renderer. In the verified 1.0.0 Compatibility/OpenGL build, the 2D call reproduced buffer-read errors and an empty Rect2. Do not treat this result as proof of no particles or as a reliable source for VisibilityRect.

Explicit bounds for the complete example.

Returns Rect2

Renderer-provided Rect2. In the reproduced OpenGL failure it is empty despite visible particles. This call was not verified on other backends.

ConvertFromParticlesvoid
# ConvertFromParticles
C#
public void ConvertFromParticles(Entity particles);

Sets this node's properties to match a given CpuParticles2D node.

Parameters
NameTypeDefault
particlesEntity—
EmitParticlevoid
# EmitParticle
C#
public void EmitParticle(Transform2D xform, Vector2 velocity, Color color, Color custom, uint flags);

Emits a single particle. Whether xform, velocity, color and custom are applied depends on the value of flags. See GpuParticles2D.EmitFlags. The default ParticleProcessMaterial needs to have ParticleProcessMaterial.ParticleFlagPreserveColor set to true to correctly use the color given from this function. Additionally, it will use the contents of custom as (rotation, lifetime, animation, lifetime randomness). Note: GpuParticles2D.EmitParticle is only supported on the Forward+ and Mobile rendering methods, not Compatibility.

Parameters
NameTypeDefault
xformTransform2D—
velocityVector2—
colorColor—
customColor—
flagsuint—
GetAmountint
# GetAmount
C#
public int GetAmount();
Returns int
GetAmountRatiofloat
# GetAmountRatio
C#
public float GetAmountRatio();
Returns float
GetCollisionBaseSizefloat
# GetCollisionBaseSize
C#
public float GetCollisionBaseSize();
Returns float
GetDrawOrderGpuParticles2D.DrawOrderEnum
# GetDrawOrder
C#
public GpuParticles2D.DrawOrderEnum GetDrawOrder();
Returns GpuParticles2D.DrawOrderEnum
GetExplosivenessRatiofloat
# GetExplosivenessRatio
C#
public float GetExplosivenessRatio();
Returns float
GetFixedFpsint
# GetFixedFps
C#
public int GetFixedFps();
Returns int
GetFractionalDeltabool
# GetFractionalDelta
C#
public bool GetFractionalDelta();
Returns bool
GetInterpToEndfloat
# GetInterpToEnd
C#
public float GetInterpToEnd();
Returns float
GetInterpolatebool
# GetInterpolate
C#
public bool GetInterpolate();
Returns bool
GetLifetimedouble
# GetLifetime
C#
public double GetLifetime();
Returns double
GetOneShotbool
# GetOneShot
C#
public bool GetOneShot();
Returns bool
GetPreProcessTimedouble
# GetPreProcessTime
C#
public double GetPreProcessTime();
Returns double
GetProcessMaterialMaterial
# GetProcessMaterial
C#
public Material GetProcessMaterial();
Returns Material
GetRandomnessRatiofloat
# GetRandomnessRatio
C#
public float GetRandomnessRatio();
Returns float
GetSeeduint
# GetSeed
C#
public uint GetSeed();
Returns uint
GetSpeedScaledouble
# GetSpeedScale
C#
public double GetSpeedScale();
Returns double
GetSubEmitterEntityPath
# GetSubEmitter
C#
public EntityPath GetSubEmitter();
Returns EntityPath
GetTextureTexture2D
# GetTexture
C#
public Texture2D GetTexture();
Returns Texture2D
GetTrailLifetimedouble
# GetTrailLifetime
C#
public double GetTrailLifetime();
Returns double
GetTrailSectionSubdivisionsint
# GetTrailSectionSubdivisions
C#
public int GetTrailSectionSubdivisions();
Returns int
GetTrailSectionsint
# GetTrailSections
C#
public int GetTrailSections();
Returns int
GetUseFixedSeedbool
# GetUseFixedSeed
C#
public bool GetUseFixedSeed();
Returns bool
GetUseLocalCoordinatesbool
# GetUseLocalCoordinates
C#
public bool GetUseLocalCoordinates();
Returns bool
GetVisibilityRectRect2
# GetVisibilityRect
C#
public Rect2 GetVisibilityRect();
Returns Rect2
IsEmittingbool
# IsEmitting
C#
public bool IsEmitting();
Returns bool
IsTrailEnabledbool
# IsTrailEnabled
C#
public bool IsTrailEnabled();
Returns bool
RequestParticlesProcess2 overloads
# RequestParticlesProcess · 1/2
C#
public void RequestParticlesProcess(float processTime);

Requests the particles to process for extra process time during a single frame. process_time defines the time that the particles will process while emitting is on. process_time_residual defines the time that particles will process with emitting turned off for the simulation. When combined with GpuParticles2D.SpeedScale set to 0.0, this is useful to be able to seek a particle system timeline.

Parameters
NameTypeDefault
processTimefloat—
# RequestParticlesProcess · 2/2
C#
public void RequestParticlesProcess(float processTime, float processTimeResidual = 0f);

Requests the particles to process for extra process time during a single frame. process_time defines the time that the particles will process while emitting is on. process_time_residual defines the time that particles will process with emitting turned off for the simulation. When combined with GpuParticles2D.SpeedScale set to 0.0, this is useful to be able to seek a particle system timeline.

Parameters
NameTypeDefault
processTimefloat—
processTimeResidualfloat0f
Restart2 overloads
# Restart · 1/2
C#
public void Restart();

Restarts the particle system. Use Restart(bool keepSeed) for explicit seed control. Restart differs from merely setting Emitting=true and begins the effect again.

# Restart · 2/2
C#
public void Restart(bool keepSeed = false);

Resets simulation state and enables emission. Seed is retained when keepSeed=true or UseFixedSeed=true; a new random value is selected only when both are false. The image changes after processing/rendering a frame.

Parameters
NameTypeDefault
keepSeedboolfalse
keepSeed

true retains the current seed. false does not force a new seed when UseFixedSeed is already true. Keeping a seed does not guarantee identical pixels across CPU/GPU implementations, devices or configurations.

SetAmountvoid
# SetAmount
C#
public void SetAmount(int amount);
Parameters
NameTypeDefault
amountint—
SetAmountRatiovoid
# SetAmountRatio
C#
public void SetAmountRatio(float ratio);
Parameters
NameTypeDefault
ratiofloat—
SetCollisionBaseSizevoid
# SetCollisionBaseSize
C#
public void SetCollisionBaseSize(float size);
Parameters
NameTypeDefault
sizefloat—
SetDrawOrdervoid
# SetDrawOrder
C#
public void SetDrawOrder(GpuParticles2D.DrawOrderEnum order);
Parameters
NameTypeDefault
orderGpuParticles2D.DrawOrderEnum—
SetEmittingvoid
# SetEmitting
C#
public void SetEmitting(bool emitting);
Parameters
NameTypeDefault
emittingbool—
SetExplosivenessRatiovoid
# SetExplosivenessRatio
C#
public void SetExplosivenessRatio(float ratio);
Parameters
NameTypeDefault
ratiofloat—
SetFixedFpsvoid
# SetFixedFps
C#
public void SetFixedFps(int fps);
Parameters
NameTypeDefault
fpsint—
SetFractionalDeltavoid
# SetFractionalDelta
C#
public void SetFractionalDelta(bool enable);
Parameters
NameTypeDefault
enablebool—
SetInterpToEndvoid
# SetInterpToEnd
C#
public void SetInterpToEnd(float interp);
Parameters
NameTypeDefault
interpfloat—
SetInterpolatevoid
# SetInterpolate
C#
public void SetInterpolate(bool enable);
Parameters
NameTypeDefault
enablebool—
SetLifetimevoid
# SetLifetime
C#
public void SetLifetime(double secs);
Parameters
NameTypeDefault
secsdouble—
SetOneShotvoid
# SetOneShot
C#
public void SetOneShot(bool secs);
Parameters
NameTypeDefault
secsbool—
SetPreProcessTimevoid
# SetPreProcessTime
C#
public void SetPreProcessTime(double secs);
Parameters
NameTypeDefault
secsdouble—
SetProcessMaterialvoid
# SetProcessMaterial
C#
public void SetProcessMaterial(Material material);
Parameters
NameTypeDefault
materialMaterial—
SetRandomnessRatiovoid
# SetRandomnessRatio
C#
public void SetRandomnessRatio(float ratio);
Parameters
NameTypeDefault
ratiofloat—
SetSeedvoid
# SetSeed
C#
public void SetSeed(uint seed);
Parameters
NameTypeDefault
seeduint—
SetSpeedScalevoid
# SetSpeedScale
C#
public void SetSpeedScale(double scale);
Parameters
NameTypeDefault
scaledouble—
SetSubEmittervoid
# SetSubEmitter
C#
public void SetSubEmitter(EntityPath path);
Parameters
NameTypeDefault
pathEntityPath—
SetTexturevoid
# SetTexture
C#
public void SetTexture(Texture2D texture);
Parameters
NameTypeDefault
textureTexture2D—
SetTrailEnabledvoid
# SetTrailEnabled
C#
public void SetTrailEnabled(bool enabled);
Parameters
NameTypeDefault
enabledbool—
SetTrailLifetimevoid
# SetTrailLifetime
C#
public void SetTrailLifetime(double secs);
Parameters
NameTypeDefault
secsdouble—
SetTrailSectionSubdivisionsvoid
# SetTrailSectionSubdivisions
C#
public void SetTrailSectionSubdivisions(int subdivisions);
Parameters
NameTypeDefault
subdivisionsint—
SetTrailSectionsvoid
# SetTrailSections
C#
public void SetTrailSections(int sections);
Parameters
NameTypeDefault
sectionsint—
SetUseFixedSeedvoid
# SetUseFixedSeed
C#
public void SetUseFixedSeed(bool useFixedSeed);
Parameters
NameTypeDefault
useFixedSeedbool—
SetUseLocalCoordinatesvoid
# SetUseLocalCoordinates
C#
public void SetUseLocalCoordinates(bool enable);
Parameters
NameTypeDefault
enablebool—
SetVisibilityRectvoid
# SetVisibilityRect
C#
public void SetVisibilityRect(Rect2 visibilityRect);
Parameters
NameTypeDefault
visibilityRectRect2—

Signals and events1

FinishedEvent
# Finished
C#
public event Action Finished;

Emitted when all active particles have finished processing. To immediately restart the emission cycle, call GpuParticles2D.Restart. This signal is never emitted when GpuParticles2D.OneShot is disabled, as particles will be emitted and processed continuously. Note: For GpuParticles2D.OneShot emitters, due to the particles being computed on the GPU, there may be a short period after receiving the signal during which setting GpuParticles2D.Emitting to true will not restart the emission cycle. This delay is avoided by instead calling GpuParticles2D.Restart.

GpuParticles2D.DrawOrderEnum

ValueDescription
Index = 0

Particles are drawn in the order emitted.

Lifetime = 1

Particles are drawn in order of remaining lifetime. In other words, the particle with the highest lifetime is drawn at the front.

ReverseLifetime = 2

Particles are drawn in reverse order of remaining lifetime. In other words, the particle with the lowest lifetime is drawn at the front.

GpuParticles2D.EmitFlags

ValueDescription
Color = 8

Particle starts with specified color.

Custom = 16

Particle starts with specified CUSTOM data.

Position = 1

Particle starts at the specified position.

RotationScale = 2

Particle starts with specified rotation and scale.

Velocity = 4

Particle starts with the specified velocity vector, which defines the emission direction and speed.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.