KlassischeKeplerKriege/data/shader/particle.vert

38 lines
No EOL
869 B
GLSL

#version 120
attribute vec2 in_vertex;
attribute vec3 in_position;
attribute vec3 in_velocity;
uniform float age;
uniform float size;
uniform float maxVelocity;
uniform float halfAge;
uniform vec3 explCenter;
varying float decay;
varying vec3 velocity;
varying vec2 vertex;
varying float explCenterDist;
// TODO: rotate to face the user!
void main()
{
//decay = min(1.0, age+5.0*length(velocity)) / halfAge;
//decay = max(decay*decay, sqrt(decay));
decay = age / halfAge;
// faster particles are smaller
//float s = size * (1.0-length(in_velocity)/maxVelocity);
float s = size;
vec2 base = in_vertex;
vec3 p = s*vec3(base, 0.0);
vec3 offset = (0.1*age + log(1.0+age*5.0)) * in_velocity + in_position;
p += offset;
gl_Position = vec4(p, 1.0);
vertex = base.xy;
velocity = in_velocity;
explCenterDist = length(explCenter-offset);
}