Particle system lifetimes in OpenGL ES 2

I don't know how to work with my particle's lifetimes. My design is simple: each particle has a position, a speed and a lifetime. At each frame, each particle should update its position like this:

position.y = position.y + INCREMENT * speed.y


However, I'm having difficulties in choosing my INCREMENT. If I set it to some sort of FRAME_COUNT, it looks fine until FRAME_COUNT has to be set back to 0. The effect will be that all particles start over at the same time, which I don't want to happen. I want my particles sort of live "independent" of each other.

That's the reason I need a lifetime, but I don't know how to make use of it. I added a lifetime for each particle in the particle buffer, but I also need an individual increment that's updated on each frame, so that when PARTICLE_INCREMENT = PARTICLE_LIFETIME, each increment goes back to 0.

How can I achieve something like that?

Are you attempting to implement a stateless particle system in a shader? You need an extra vertex attribute: timeoffset. Pick a random timeoffset value for each particle.

startpos // vec per vertex
velocity // vec per vertex
timeoffset // scalar per vertex (N random values in [0..lifetime])


and you have the uniform variables:

currenttime. // scalar, one value for all vertices
lifetime. // scalar, one value for all vertices


t = currenttime + timeoffset;