maxAge of particle is now halfAge and it lives for 5*halfAge time.

This commit is contained in:
Andreas Ortmann 2016-09-30 21:48:15 +02:00
parent a6b9078c21
commit 3a30a20043
5 changed files with 17 additions and 15 deletions

View file

@ -21,14 +21,15 @@ void main()
discard;
}
float d = decay/(1.0+max(0.0, 1.0-explCenterDist));
float d = decay/(1.0+max(0.0, 1.0-2.0*explCenterDist));
float h = (1.0-d)/6.0;
float v = max(0.0, (1.0-log(d)));
float s = 1.0;
float s = max(0.0, min(30.0 * sqrt(decay) * explCenterDist, 1.0));
//v /= decay * 10.0*length(vertex-explCenter);
//v /= 1.0+2.0*length(vertex-explCenter);
v /= 1.0 + max(0.0, min(35.0*(decay-0.2), 1.0)) * 15.0 * explCenterDist;
//v /= 1.0 + max(0.0, min(35.0*(decay-0.2), 1.0)) + 10.0 * explCenterDist;
v /= 1.0 + 10.0 * explCenterDist;
gl_FragColor = vec4(hsv2rgb(vec3(h, s, v)), 1.0);

View file

@ -6,7 +6,7 @@ attribute vec3 in_velocity;
uniform float age;
uniform float size;
uniform float maxVelocity;
uniform float maxAge;
uniform float halfAge;
uniform vec3 explCenter;
varying float decay;
@ -17,15 +17,16 @@ varying float explCenterDist;
// TODO: rotate to face the user!
void main()
{
//decay = min(1.0, age+5.0*length(velocity)) / maxAge;
//decay = min(1.0, age+5.0*length(velocity)) / halfAge;
//decay = max(decay*decay, sqrt(decay));
decay = age / maxAge;
decay = age / halfAge;
// faster particles are smaller
float s = size * (1.0-length(in_velocity)/maxVelocity);
//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 = log(1.0+age) * in_velocity + in_position;
vec3 offset = (0.1*age + log(1.0+age*5.0)) * in_velocity + in_position;
p += offset;
gl_Position = vec4(p, 1.0);