2013-12-29 13:23:36 -05:00
|
|
|
uniform int dt;
|
2013-12-30 08:57:55 -05:00
|
|
|
uniform mat4 sourcematrix;
|
2014-01-06 13:05:21 -05:00
|
|
|
uniform int level;
|
2014-01-06 17:58:04 -05:00
|
|
|
uniform float size_increase_factor;
|
2013-12-29 13:23:36 -05:00
|
|
|
|
2014-09-09 19:42:51 -04:00
|
|
|
#if __VERSION__ >= 330
|
2014-08-13 16:26:52 -04:00
|
|
|
layout (location = 4) in vec3 particle_position_initial;
|
|
|
|
layout (location = 5) in float lifetime_initial;
|
|
|
|
layout (location = 6) in vec3 particle_velocity_initial;
|
|
|
|
layout (location = 7) in float size_initial;
|
2013-12-31 12:25:10 -05:00
|
|
|
|
2014-08-13 16:26:52 -04:00
|
|
|
layout (location = 0) in vec3 particle_position;
|
|
|
|
layout (location = 1) in float lifetime;
|
|
|
|
layout (location = 2) in vec3 particle_velocity;
|
|
|
|
layout (location = 3) in float size;
|
2014-09-09 19:42:51 -04:00
|
|
|
#else
|
|
|
|
in vec3 particle_position_initial;
|
|
|
|
in float lifetime_initial;
|
|
|
|
in vec3 particle_velocity_initial;
|
|
|
|
in float size_initial;
|
|
|
|
|
|
|
|
in vec3 particle_position;
|
|
|
|
in float lifetime;
|
|
|
|
in vec3 particle_velocity;
|
|
|
|
in float size;
|
|
|
|
#endif
|
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)
|
|
|
|
{
|
2014-01-12 13:40:04 -05:00
|
|
|
float updated_lifetime = lifetime + (float(dt)/lifetime_initial);
|
2014-01-12 14:49:23 -05:00
|
|
|
if (updated_lifetime > 1.)
|
2014-01-12 13:40:04 -05:00
|
|
|
{
|
2014-01-12 14:49:23 -05:00
|
|
|
if (gl_VertexID <= level)
|
|
|
|
{
|
|
|
|
float dt_from_last_frame = fract(updated_lifetime) * lifetime_initial;
|
|
|
|
vec4 updated_initialposition = sourcematrix * vec4(particle_position_initial, 1.0);
|
|
|
|
vec4 updated_initial_velocity = sourcematrix * vec4(particle_position_initial + particle_velocity_initial, 1.0) - updated_initialposition;
|
|
|
|
new_particle_position = updated_initialposition.xyz + updated_initial_velocity.xyz * float(dt_from_last_frame);
|
|
|
|
new_particle_velocity = updated_initial_velocity.xyz;
|
|
|
|
new_lifetime = fract(updated_lifetime);
|
|
|
|
new_size = mix(size_initial, size_initial * size_increase_factor, fract(updated_lifetime));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
new_lifetime = fract(updated_lifetime);
|
|
|
|
new_size = 0;
|
|
|
|
}
|
2014-01-12 13:40:04 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
new_particle_position = particle_position + particle_velocity.xyz * float(dt);
|
|
|
|
new_particle_velocity = particle_velocity;
|
|
|
|
new_lifetime = updated_lifetime;
|
2014-01-13 11:05:26 -05:00
|
|
|
new_size = (size == 0) ? 0. : mix(size_initial, size_initial * size_increase_factor, updated_lifetime);
|
2014-01-12 13:40:04 -05:00
|
|
|
}
|
2013-12-29 13:23:36 -05:00
|
|
|
gl_Position = vec4(0.);
|
|
|
|
}
|