2016-09-29 02:24:14 +00:00
|
|
|
#version 120
|
|
|
|
attribute vec2 in_vertex;
|
2016-09-30 19:24:06 +00:00
|
|
|
attribute vec3 in_position;
|
|
|
|
attribute vec3 in_velocity;
|
2016-09-30 18:19:10 +00:00
|
|
|
|
2016-09-30 19:24:06 +00:00
|
|
|
uniform float age;
|
|
|
|
uniform float size;
|
|
|
|
uniform float maxVelocity;
|
2016-09-30 19:48:15 +00:00
|
|
|
uniform float halfAge;
|
2016-09-30 19:24:06 +00:00
|
|
|
uniform vec3 explCenter;
|
|
|
|
|
2016-09-30 18:19:10 +00:00
|
|
|
varying float decay;
|
2016-09-30 19:24:06 +00:00
|
|
|
varying vec3 velocity;
|
|
|
|
varying vec2 vertex;
|
|
|
|
varying float explCenterDist;
|
|
|
|
|
|
|
|
// TODO: rotate to face the user!
|
2016-09-29 02:24:14 +00:00
|
|
|
void main()
|
|
|
|
{
|
2016-09-30 19:48:15 +00:00
|
|
|
//decay = min(1.0, age+5.0*length(velocity)) / halfAge;
|
2016-09-30 18:19:10 +00:00
|
|
|
//decay = max(decay*decay, sqrt(decay));
|
2016-09-30 19:48:15 +00:00
|
|
|
decay = age / halfAge;
|
2016-09-30 18:19:10 +00:00
|
|
|
|
2016-09-30 19:24:06 +00:00
|
|
|
// faster particles are smaller
|
2016-09-30 19:48:15 +00:00
|
|
|
//float s = size * (1.0-length(in_velocity)/maxVelocity);
|
|
|
|
float s = size;
|
2016-09-30 18:19:10 +00:00
|
|
|
vec2 base = in_vertex;
|
2016-09-30 19:24:06 +00:00
|
|
|
vec3 p = s*vec3(base, 0.0);
|
2016-09-30 19:48:15 +00:00
|
|
|
vec3 offset = (0.1*age + log(1.0+age*5.0)) * in_velocity + in_position;
|
2016-09-30 19:24:06 +00:00
|
|
|
p += offset;
|
|
|
|
|
|
|
|
gl_Position = vec4(p, 1.0);
|
2016-09-29 07:05:35 +00:00
|
|
|
|
2016-09-30 19:24:06 +00:00
|
|
|
vertex = base.xy;
|
2016-09-29 07:05:35 +00:00
|
|
|
velocity = in_velocity;
|
2016-09-30 19:24:06 +00:00
|
|
|
|
|
|
|
explCenterDist = length(explCenter-offset);
|
2016-09-29 10:28:35 +00:00
|
|
|
}
|