GPUParticleSystem with CustomParticleEmitter and LifeTime

Hello world :slight_smile:

I have two questions about GPUParticleSystem and CustomParticleEmitter.

  1. I use these properties for GPUParticleSystem to control lifetime with a custom particle emitter.
let particletime = 0;

        if (ps.maxLifeTime < 0.21)
            particletime = 0.25;
        else if (ps.maxLifeTime.between(0.2, 0.5))
            particletime = 0.1;
        else if (ps.maxLifeTime.between(0.5, 2))
            particletime = 0.07;
        else if (ps.maxLifeTime.between(2, 5))
            particletime = 0.04;
        else if (ps.maxLifeTime.between(5, 10))
            particletime = 0.03;
        else if (ps.maxLifeTime.between(10, 20))
            particletime = 0.02;
        else if (ps.maxLifeTime.between(20, 30))
            particletime = 0.013;
        else if (ps.maxLifeTime > 30)
            particletime = 0.009;

        ps.addSizeGradient(0, ps.maxSize);
        ps.addSizeGradient(particletime / 2, ps.minSize);
        ps.addSizeGradient(particletime, 0);

Anyone got a better solution instead of this “hack” ?

  1. Is plans to support a path of positions for custom particle emitter, or is this not possible ?
1 Like

Hello world to you! :smiley: Let’s see what I can do for you.

  1. I use these properties for GPUParticleSystem to control lifetime with a custom particle emitter.

I’d like to understand more what your intention is? Looks like you’re setting the size relative to the life time of the particle. Another solution is would be to just create an equation that converts the maxLifeTime to a particleTime . For example:

let particletime = 1 / ps.maxLifeTime;
This number gets smaller as maxLifeTimer goes up which is the relation you have in your example.

  1. Is plans to support a path of positions for custom particle emitter, or is this not possible ?

Is the intention for the emitter to go along a certain path? This I’m sure can be done. Take a look at this demo. https://playground.babylonjs.com/#36UHXZ#34

Here is a another demo showing manipulations you can do particle systems and even animations you can add to the emitter (line 160-170) https://playground.babylonjs.com/#ZHL9ZF

OR do you want to make a path is the particles themselves? I know it is is possible to set the position of particles in solid particle system (SPS). https://playground.babylonjs.com/#GLZ1PX#8

Take a look at line 42 for instance:
particle.position.y = particle.props.range * (1 + Math.cos(particle.props.angle))

Let me know if you have questions to this. :slight_smile:

3 Likes

What a helpful world :smiley:

This looks interesting and I have overlooked the updateFunction. This function seems very helpful to control the particles :slight_smile:

Thank you very much!

2 Likes