Make particles go toward center of SphereEmitter with GPUParticleSystem

I’ve been reading the particle system docs and experimenting but I haven’t figured out how to make particles go “inward” from the edge of the sphere emitter without using the startDirectionFunction, which isn’t supported by the GPUParticleSystem.

In the normal particle system I do this:

particleSystem.createSphereEmitter(1, 1);

const position = new Vector3();
particleSystem.emitter = position;

particleSystem.startDirectionFunction = (
  worldMatrix: Matrix,
  directionToUpdate: Vector3,
  particle: Particle,
  isLocal: boolean
) => {
  const particlePosition: Vector3 = particle.position;
  const sphereCenter = position;
  const direction: Vector3 = sphereCenter.subtract(particlePosition).normalize();
  directionToUpdate.copyFrom(direction);
};

And with GPU I tried this:

particleSystem.direction1 = new Vector3(0, 0, 0);
particleSystem.direction2 = new Vector3(0, 0, 0);

But I don’t think that’s right because it seems that would send every particle in the same direction.

You can tune the combination of lifetime, (negative) emit power, and sphere radius parameters:

2 Likes

Awesome! I hadn’t considered negative emit power. That makes sense!