taisei/shader/laser_snippets
laochailan a8251b1966 Merge branch 'master' into stage6
Conflicts:
	shader/laser_snippets
	src/CMakeLists.txt
	src/global.h
	src/projectile.c
	src/stage.c
	src/stage.h
	src/stages/stage3.c
	src/stages/stage3_events.c
	src/stages/stage4_events.c
2012-08-03 16:55:10 +02:00

75 lines
1.4 KiB
Text

%%VSHADER-HEAD%%
#version 120
#extension GL_EXT_draw_instanced : enable
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);