88 lines
1.8 KiB
Text
88 lines
1.8 KiB
Text
%%VSHADER-HEAD%%
|
|
|
|
uniform vec2 a0;
|
|
uniform vec2 a1;
|
|
uniform vec2 a2;
|
|
uniform vec2 a3;
|
|
|
|
uniform vec2 pos;
|
|
|
|
uniform float timeshift;
|
|
uniform float wq;
|
|
uniform float hq;
|
|
uniform int span;
|
|
|
|
float pi = 2.0 * asin(1.0);
|
|
|
|
vec2 dir(float a) {
|
|
return vec2(cos(a), sin(a));
|
|
}
|
|
|
|
float angle(vec2 v) {
|
|
return atan(v.y, v.x);
|
|
}
|
|
|
|
vec2 posrule(float t) {
|
|
%%VSHADER-FOOT%%
|
|
}
|
|
|
|
void main(void) {
|
|
vec2 v = gl_Vertex.xy;
|
|
|
|
float t1 = gl_InstanceID-span/2;
|
|
float tail = span/1.9;
|
|
|
|
float s = -0.75/pow(tail,2)*(t1-tail)*(t1+tail);
|
|
|
|
vec2 pos = posrule(gl_InstanceID*0.5+timeshift);
|
|
vec2 d = pos - posrule(gl_InstanceID*0.5+timeshift-0.1);
|
|
|
|
float a = -angle(d);
|
|
mat2 m = mat2(cos(a), -sin(a), sin(a), cos(a));
|
|
|
|
v.x *= wq*1.5*length(d);
|
|
v.y *= hq*s;
|
|
|
|
gl_Position = gl_ModelViewProjectionMatrix*vec4(m*v+pos, 0.0, 1.0);
|
|
gl_TexCoord[0] = gl_MultiTexCoord0;
|
|
}
|
|
|
|
%%FSHADER-HEAD%%
|
|
|
|
#version 120
|
|
|
|
uniform sampler2D tex;
|
|
uniform vec4 clr;
|
|
|
|
void main(void) {
|
|
gl_FragColor = texture2D(tex, vec2(gl_TexCoord[0].xy))*clr;
|
|
}
|
|
|
|
%%linear%%
|
|
return pos + a0*t;
|
|
%%accelerated%%
|
|
return pos + a0*t + 0.5*a1*t*t;
|
|
%%maxwell%%
|
|
vec2 p = vec2(t, a2.x*t*0.02*sin(0.1*t+a2.y));
|
|
return pos + vec2(a0.x*p.x - a0.y*p.y, a0.x*p.y + a0.y*p.x);
|
|
%%sine%%
|
|
float s = (a2.x * t + a3.x);
|
|
return pos + dir(angle(a0) + a1.x * sin(s) / s) * t * length(a0);
|
|
%%sine_expanding%%
|
|
float s = (a2.x * t + a3.x);
|
|
return pos + dir(angle(a0) + a1.x * sin(s)) * t * length(a0);
|
|
%%turning%%
|
|
vec2 v0 = a0;
|
|
vec2 v1 = a1;
|
|
float begin = a2.x;
|
|
float end = a2.y;
|
|
float a = clamp((t - begin) / (end - begin), 0.0, 1.0);
|
|
a = 1.0 - (0.5 + 0.5 * cos(a * pi));
|
|
a = 1.0 - pow(1.0 - a, 2);
|
|
return pos + mix(v0, v1, a) * t;
|
|
%%circle%%
|
|
// XXX: should turn speed be in rad/sec or rad/frame? currently rad/sec.
|
|
float turn_speed = a0.x / 60;
|
|
float time_ofs = a0.y;
|
|
float radius = a1.x;
|
|
return pos + radius * dir((t + time_ofs) * turn_speed);
|