CParticleEvolver Spawner

From PopcornFX
Jump to navigation Jump to search
! IMPORTANT ! This is a PopcornFX v1 page. PopcornFX v2 documentation can be found here

Spawner evolver Last update: v1.9.0 - Main page : Particle evolvers Particle evolvers

The spawner evolver allows you to create particles that will spawn other particles, when moving around, or when enough time has passed. It is typically used to create trails.
See the Trails tutorial for more details on how to use this evolver.

Unless you are moving the particles by hand, usually to work correctly, all spawner evolvers in a given state must be located _after_ the Physics evolver Physics evolver.

NOTE : In PK-Editor v1.5.2 and below, the spawner evolver needed another evolver to fill the 'PrevPosition' field for him, usually the Physics evolver Physics evolver. This is no longer the case in v1.5.3 and above, everything is done automatically.

NOTE2 : In PK-Editor v1.4.2 and below, when creating a new spawner evolver, no particles will be visible, you will need to manually create a renderer, and a state, by right-clicking on the particle layer > new state, and on the 'renderers' node > new renderer.

Spawner evolver Node properties

Field name Default value Description
Spawner evolver Spawner
SpawnMetric Distance Controls what metric the evolver should look at to decide when to spawn a particle.
  • Distance : will spawn a child particle when the parent particle has travelled 'SpawnInterval' world units
  • Time : will spawn a child particle every 'SpawnInterval' seconds
  • Custom : will read the <float> value of the parent particle's 'CustomSpawnMetricField' field, each frame, and spawn that number of child particles
SpawnInterval 0.1 Interval between two consecutive spawns. if 'SpawnMetric' is set to 'Distance', this will be the distance in units the parent particle has to travel before it spawns another child particle, if set to 'Time', it will be the time in seconds between two consecutive spawns.
UseVelocityOrientedSpawnMatrix false Tells wether or not child particles should inherit the source particle's coordinate frame, defined by the optional 'ForwardAxisField' and/or 'UpAxisField'.
FirstSpawnDelay 1 Time offset in the [0,1] range that controls when the child particles are spawned. A value of 0 will make the evolver spawn a child particle right when the source particle is born. A value of 1 will offset it forward in time to the next child spawn.

If set to 0, the first particle is spawned at t=0, and the last at t=duration - duration/spawnCount.
If set to 1, the first particle is spawned at t=duration/spawnCount, and the last at t=duration.
More generally, t0 = spawnDelay * duration/spawnCount

FluxFunctionTiledRelativeDuration 1 Number of times the flux function will repeat itself across the life of the source particles. (you can see this as the "tiling" of the flux function)
LocalSpaceSpawn false If true, spawn interpolations beetween frames will be localspace.
Spawner evolver Field customization
PositionField "Position" If this field is declared as a <float3>, it will be used to compute the trajectory trajectory and spawn the child particles.
ForwardAxisField "Velocity" If this field is declared as a <float3>, when using oriented spawn matrices, if will be used as the 'FORWARD' axis of the child spawn-matrix.
UpAxisField <empty> If this field is declared as a <float3>, when using oriented spawn matrices, if will be used as the 'UP' axis of the child spawn-matrix.
CustomSpawnMetricField <empty> Used only if SpawnMetric is set to Custom. If this field is declared as a <float>, will be used to grab the spawn metric value each frame.

For example, a value of 5.5 means \"spawn 5 and a half particles this frame\". The evolver will emit 5 particles, remember the half particle and take it into account next frame.

CustomSpawnMetricScaleField <empty> If this field is declared as a <float>, will be used as a dynamic multiplier to the spawn metric. Can be seen as a spawn-count multiplier. 0.0 produces no particles. One produces the normal amount of particles. 10.0 produces ten times more particles.
CustomSpawnIntervalScaleField <empty> If this field is declared as a <float>, will be used as a dynamic multiplier to the spawn interval.
Spawner evolver properties

the FirstSpawnDelay property can seem a bit shady at first, its use not being really clear.
You can check out this small video illustrating it:

Spawner evolver Auto-fields

The spawner evolver automatically creates, if they don't exist, the following particle fields:

Name Type Footprint TransformMode self access to field
Position float3 16 bytes Transform read
Private fields used internally:
PrevPosition float3 16 bytes none read
SpawnerID int 4 bytes n/a read
SelfID int 4 bytes n/a read
PartialIntervalAccumulator float 4 bytes n/a read/write

Spawner evolver Side effects

The spawner evolver

  • Spawns other particles
  • Writes to the 'CustomPartialIntervalAccumulatorField'

Spawner evolver Flux functions

Like regular particle spawners, trail spawners support flux functions. To create a new flux function, right-click on the evolver, and select 'New Flux Function'

Flux function 1

A "Flux Function" entry will be added in the treeview:

Flux function 2

When selecting the Flux Function node, you can change the curve to control the particle flux:

Constant flux function Constant flux function : results
Default flux function. Constant flux = 1.0

Simple nonlinear flux function Simple nonlinear flux function : results
Simple flux function. Starts with a low flux, ends with a high flux. Particles start wide apart and end close together

Complex flux function with degenerate zones Complex flux function with degenerate zones : results
Complex flux function. Drops to zero at multiple places.

Spawner evolver Velocity-oriented spawn matrices

the 'UseVelocityOrientedSpawnMatrix' property controls the spawn transform space of the child particles.

Up axis : World
Up axis : World
Up axis : Velocity-oriented
Up axis : Velocity-oriented

These two screenshots draw a per-particle float3 'Up' axis setup as follows in the spawn script:

Up = float3(0,1,0);

In the first screenshot, 'UseVelocityOrientedSpawnMatrix' is unchecked, and the 'Up' particle field only gets transformed by the original effect instance transforms.
In the second screenshot, it is checked, and the 'Up' particle field gets transformed by the local per-particle transforms that are computed using the 'velocity' property.