KlassischeKeplerKriege/data/shader/particle.frag
2016-09-30 20:19:10 +02:00

27 lines
No EOL
650 B
GLSL

#version 120
varying vec2 vertex;
varying vec2 velocity;
varying float decay;
vec3 hsv2rgb(vec3 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
void main()
{
gl_FragColor = vec4(0.5+0.5*vertex.x, 0.5+0.5*vertex.y, 0.0, 1.0);
float r = length(vertex);
if (r > 1.0) {
discard;
}
float d = decay;
float h = (1.0-d)/6.0;
float v = max(0.0, (1.0-d/2.0) - 0.1*(d*d*d));
float s = 1.0;
gl_FragColor = vec4(hsv2rgb(vec3(h, s, v)), 1.0);
//gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0);
}