pixijs / particle-emitter

A particle system for PixiJS
http://pixijs.io/particle-emitter/docs
MIT License
800 stars 128 forks source link

Best practice for continuous trail on a fast-moving object? #210

Closed reececomo closed 10 months ago

reececomo commented 10 months ago

Hey there 👋

-I've got a fast-moving object (a ball)

Is there a way to emit based on distance traveled, instead of once-per-draw-at-the-current-position?

Would the best alternative be drawing it manually using PIXI.Graphics?

Example

(Excuse the bad MS Paint.)

particles

The top image is roughly

In ^this specific example, there's actually two emitters, but same applies for one emitter.

reececomo commented 10 months ago

For reference, just increasing emission rate results in patchy trails like this:

image

(While also adding some performance overhead on mobile)

reececomo commented 10 months ago

Update: I think the gaps was caused by using a third-party interpolation renderer library (for smoothing 30Hz/120Hz/144Hz/etc.). I've wrapped Emitter so that Emitter.setOwnerPos() is triggered on the corresponding draw frames to the interpolated location and it looks considerably better now.

Still not great, a little patchy, looks ok when playing realtime, but still noticable in stills/screenshots:

gameplay snap
reececomo commented 10 months ago

Another quick update: Performance is pretty horrendous on lower and middle-end devices, its only about ~2000 particles. Still investigating.

andrewstart commented 10 months ago

You can reduce the impact of this library on performance by using a LinkedListContainer (from this library) as the parent to your emitted particles. Basic particle emission will never get you a true trail, though, as that is typically a different mesh-based effect.

reececomo commented 10 months ago

Tinkering around with thicker particles and not changing the scale, just the alpha - got the number of particles down from ~2300 to around 500 which has improved performance for now.

as that is typically a different mesh-based effect.

Ah thank you, that's probably a good place for me to look.

You can reduce the impact of this library on performance by using a LinkedListContainer

Nice, will have a look at that too.

image