Skip to content

MultiplexSpawn

Thomas Iché edited this page Oct 28, 2022 · 1 revision

Multiplex Spawn Blocks

Multiplex Spawn blocks enable bypassing a limitation case of VFX Graph : handling multiple events sent every frame by C# code.

The problem : Generally, when sending events to a VFX Graph, they are caught by Spawn contexts to start them. However an incoming event will only restart the Spawn context, so 10 events at the same frame will result in only restarting once. Moreover, if there are different VFXEventAttribute payloads for each event, only the last one will be retained by the spawn context. And no evidence of previous events will be retained.

The solution : Using C# Spawn Blocks, we can intercept all incoming events to handle things before they get lost. Multiplex Blocks do that kind of job in two different ways : Multiplex Burst and Multiplex Rate.

IMPORTANT As these block tinker with the internal state of the Spawn contexts, they should NOT be mixed up among themselves, and among other burst/rate blocks.

Burst Multiplex FIFO

Burst Multiplex FIFO uses a First-in-first-out Queue to store incoming events that hit start, and for each of them, their VFXEventAttribute payload. It is mainly used to multiplex spawnCount (eg: incoming spawnCount of 2 will be multiplied by 10)

The incoming VFX events and their VFXEventAttribute are stored in a queue.

Every update, one single event and its VFXEventAttribute is dequeued and output by the Spawn Context. This defers the burst over frames until depletion of the queue. The uint spawnCount attribute is multiplied by the Count Scale to obtain the actual count to spawn.

Hitting the Stop input of the context clears the queue.

image

Rate Multiplex FIFO

Rate Multiplex FIFO uses a First-in-first-out Queue to store incoming events that hit start, and for each of them, their VFXEventAttribute payload. For each Event, it creates internally a Source that will live for a given amount of time, defined in the Source LifeTime property (random min/max).

Every update, one source is updated, through cycling among all active sources. The source time is updated, and will spawn its particles accordingly. The source is discarded if reaching its lifetime limit.

Scaling limitations : The more sources, the less precise they become : for example in the case of 30 active sources, every one of them will be updated 1 frame out of 30, so particles sometimes can feel "burst" among sources. This also means that this system is not intended for handling large amount of sources.

Hitting the Stop input of the context clears all sources.

image

Burst N Times

Burst N Times is an helper that will perform N bursts of 1 particle, every frame, for N frames. This block can be used to generate directly Spawn Events with various state and use them in Multiplex FIFO nodes. For example in the example below, it will create 10 sources, each at a random position.

image