The Trails VFX asset shows an example of how to make the appearance of trails from a VFX Quad Output. Since we currently only support quads as an output, the way to achieve a connected trails look is to carefully stack particles one after the other, making them move along the same path, but offset from one another.
We will do this in two steps. The first is to come up with a random number per-trail, and the second is to offset the particles along the trail.
For step one, we need to come up with our own per-trail seed value. This just means a random number for each trail. We’ll use the random number to make each trail have its own starting position.
To do this, let’s consider this pseudocode:
// define the "trail length"
int numParticlesPerTrail = 10
// divide the particle ID by the trail length
trailRamp = particle ID / numParticlesPerTrail
// floor the trailRamp to get an integer value for each individual trail
trailID = floor(trailRamp)
// our seed is the trailID
trailSeed = rand(trailID * 0.0001)
// finally, we get our final 0-1 trail ramp value by using fract
trailRamp = fract(trailRamp)
At this point, we just need to make three random trailSeed values, based on trailID, to create a vec3. This is the starting point for the trail: all particles in the trail start at the same location. This is important!
The second step is we need to offset the particles from each other to form what appears to be a trail. To begin, we uncheck the Simulate check box on the Update container. This will disable the internal simulation integration. We’re going to be updating the particle position manually.
Using a modified noise force subgraph, we take the noise vector (which will be exactly the same for each particle in the trail since they start at the same location) and just scale down the intensity of the force for the first 10% of the particle's life.
Think of it like you have 10 runners on a track who run at exactly the same speed when the race starts. All we're doing is slowing down the runners at the beginning of the race: the first runner gets slowed down the least, and the last runner gets slowed down the most. After the beginning of the race, we let them all run at the exact same speed again.
Since the vector field is static and particles in the trail started in the same location, the particles will flow through the vector field in unison after the initial offset at the beginning. By controlling how much of a percentage of the particle's life we slow them down by, we can control how spaced out they are.
Finally, the connected look is aided by velocity stretch in the Align to Camera subgraph. We’re not actually using the velocity attribute in a traditional sense since we’re updating particle positions manually. We set the velocity to be the strength of the noise force, which doesn’t do anything except to tell velocity stretch what to do at the very end.