I want to move my particles by a few given attributes. The particles should slow down to a stop as they reach the end of their lifetime

```result = a_pos + a_direction * lifetime * mix(a_speed, a_speed_end, normalized_lifetime);
result.w = 1.0;
gl_Position = u_projection * u_model_view * result;
```

This doesn't work as I'd hoped it would because it doesn't consider previous movements, so when normalized_lifetime reaches 1, the particle is basically set to a_pos again since a_speed_end is 0. How do I go about this?

a_pos = startposition

a_direction = normalized direction vector

a_speed, a_speed_end = desired start/end speed

They should move on a straight line along the direction vector, no CPU updates

you want a equation like -a_deceleration*t^2+a_initial*t+a_pos

a bit of physics:

initial speed is a_speed a_speed_end is a_speed - a_deceleration*total_life so -a_deceleration = (a_speed_end-a_speed)/total_life

```result = a_pos + a_direction * lifetime * a_speed
```

edit: looking at the formulas in wikipedia there is an easier one

```result = a_pos + a_direction * lifetime * (a_speed + mix(a_speed, a_speed_end, normalized_lifetime))/2
```

Thanks for ratchet freak for pointing me to the right direction, helped a lot! The final solution was to calculate the acceleration first

```a_acceleration = (endspeed - startspeed) / total_lifetime;
```

The final formula is then:

```pos = a_pos + ((0.5 * a_acceleration * current_lifetime * current_lifetime) + (a_start_speed * current_lifetime)) * a_direction;
pos.w = 1.0;
gl_Position = u_projection * u_model_view * pos;
```

For example, with a startspeed of 5, endspeed of 0 and lifetime of 5 the particle will slowly decelerate and come to a total stop after 5 seconds.