2013-12-29 13:23:36 -05:00
|
|
|
#version 130
|
|
|
|
uniform int dt;
|
2013-12-30 08:57:55 -05:00
|
|
|
uniform mat4 sourcematrix;
|
2014-01-01 14:13:57 -05:00
|
|
|
uniform mat4 tinvsourcematrix;
|
2014-01-06 13:05:21 -05:00
|
|
|
uniform int level;
|
2013-12-29 13:23:36 -05:00
|
|
|
|
2013-12-31 12:25:10 -05:00
|
|
|
in vec3 particle_position_initial;
|
|
|
|
in float lifetime_initial;
|
2013-12-31 20:11:44 -05:00
|
|
|
in vec3 particle_velocity_initial;
|
|
|
|
in float size_initial;
|
2013-12-31 12:25:10 -05:00
|
|
|
|
2013-12-29 13:23:36 -05:00
|
|
|
in vec3 particle_position;
|
|
|
|
in float lifetime;
|
2013-12-31 20:11:44 -05:00
|
|
|
in vec3 particle_velocity;
|
|
|
|
in float size;
|
2013-12-29 13:23:36 -05:00
|
|
|
|
|
|
|
out vec3 new_particle_position;
|
|
|
|
out float new_lifetime;
|
2013-12-31 20:11:44 -05:00
|
|
|
out vec3 new_particle_velocity;
|
|
|
|
out float new_size;
|
2013-12-29 13:23:36 -05:00
|
|
|
|
|
|
|
void main(void)
|
|
|
|
{
|
2013-12-31 12:25:10 -05:00
|
|
|
vec4 initialposition = sourcematrix * vec4(particle_position_initial, 1.0);
|
2014-01-01 14:13:57 -05:00
|
|
|
vec4 adjusted_initial_velocity = tinvsourcematrix * vec4(particle_velocity_initial, 1.0);
|
|
|
|
adjusted_initial_velocity /= adjusted_initial_velocity.w;
|
2014-01-02 12:20:26 -05:00
|
|
|
float adjusted_lifetime = lifetime + (float(dt)/lifetime_initial);
|
2014-01-06 13:05:21 -05:00
|
|
|
bool reset = (adjusted_lifetime > 1.) && (gl_VertexID <= level);
|
|
|
|
reset = reset || (lifetime < 0.);
|
|
|
|
new_particle_position = !reset ? particle_position + particle_velocity.xyz * float(dt) : initialposition.xyz;
|
|
|
|
new_lifetime = !reset ? adjusted_lifetime : 0.;
|
|
|
|
new_particle_velocity = !reset ? particle_velocity : adjusted_initial_velocity.xyz;
|
|
|
|
new_size = !reset ? size : size_initial;
|
2013-12-29 13:23:36 -05:00
|
|
|
gl_Position = vec4(0.);
|
|
|
|
}
|