2022-01-13 05:24:03 +01:00
|
|
|
//
|
|
|
|
// Simple passthrough fragment shader
|
|
|
|
//
|
|
|
|
varying vec2 v_vTexcoord;
|
|
|
|
varying vec4 v_vColour;
|
|
|
|
|
|
|
|
#define TAU 6.28318
|
|
|
|
|
|
|
|
uniform int gradient_blend;
|
|
|
|
uniform vec4 gradient_color[16];
|
|
|
|
uniform float gradient_time[16];
|
2022-01-14 02:44:58 +01:00
|
|
|
uniform int gradient_keys;
|
2022-01-18 05:31:19 +01:00
|
|
|
uniform int gradient_loop;
|
2022-01-14 02:44:58 +01:00
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
uniform vec2 center;
|
|
|
|
uniform float angle;
|
|
|
|
uniform float radius;
|
|
|
|
uniform float shift;
|
|
|
|
uniform int type;
|
|
|
|
|
2022-01-14 02:44:58 +01:00
|
|
|
vec4 gradientEval(in float prog) {
|
2022-01-13 05:24:03 +01:00
|
|
|
vec4 col = vec4(0.);
|
|
|
|
|
|
|
|
for(int i = 0; i < 16; i++) {
|
|
|
|
if(gradient_time[i] == prog) {
|
|
|
|
col = gradient_color[i];
|
|
|
|
break;
|
|
|
|
} else if(gradient_time[i] > prog) {
|
|
|
|
if(i == 0)
|
|
|
|
col = gradient_color[i];
|
|
|
|
else {
|
|
|
|
if(gradient_blend == 0)
|
|
|
|
col = mix(gradient_color[i - 1], gradient_color[i], (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]));
|
|
|
|
else if(gradient_blend == 1)
|
|
|
|
col = gradient_color[i - 1];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2022-01-14 02:44:58 +01:00
|
|
|
if(i >= gradient_keys - 1) {
|
|
|
|
col = gradient_color[gradient_keys - 1];
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-14 02:44:58 +01:00
|
|
|
return col;
|
|
|
|
}
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
float prog = 0.;
|
|
|
|
if(type == 0) {
|
|
|
|
prog = .5 + (v_vTexcoord.x - center.x) * cos(angle) - (v_vTexcoord.y - center.y) * sin(angle);
|
|
|
|
} else if(type == 1) {
|
|
|
|
prog = distance(v_vTexcoord, center) / radius;
|
|
|
|
} else if(type == 2) {
|
|
|
|
vec2 _p = v_vTexcoord - center;
|
|
|
|
float _a = atan(_p.y, _p.x) + angle;
|
|
|
|
prog = (_a - floor(_a / TAU) * TAU) / TAU;
|
|
|
|
}
|
2022-01-19 14:48:30 +01:00
|
|
|
prog = prog + shift;
|
2022-01-19 04:16:28 +01:00
|
|
|
if(gradient_loop == 1) {
|
2022-01-19 14:48:30 +01:00
|
|
|
prog = abs(prog);
|
2022-01-19 04:16:28 +01:00
|
|
|
if(prog > 1.) {
|
|
|
|
if(prog == floor(prog))
|
|
|
|
prog = 1.;
|
|
|
|
else
|
|
|
|
prog = fract(prog);
|
|
|
|
}
|
|
|
|
}
|
2022-01-14 02:44:58 +01:00
|
|
|
|
|
|
|
vec4 col = gradientEval(prog);
|
|
|
|
|
2022-09-21 06:09:40 +02:00
|
|
|
gl_FragColor = vec4(col.rgb, texture2D( gm_BaseTexture, v_vTexcoord ).a);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|