Mindustry/core/assets/shaders/shield.fragment

64 lines
1.4 KiB
Plaintext
Raw Normal View History

#ifdef GL_ES
precision highp float;
precision highp int;
#endif
#define MAX_HITS 64
#define HIT_RADIUS 12.0
2017-12-06 00:21:08 +07:00
#define ALPHA 0.18
uniform sampler2D u_texture;
uniform vec4 u_color;
uniform vec2 u_texsize;
uniform float u_time;
uniform float u_scaling;
uniform float u_dp;
uniform vec2 u_offset;
varying vec4 v_color;
varying vec2 v_texCoord;
float round(float f){
return float(int(f));
}
void main() {
vec2 T = v_texCoord.xy;
2017-10-25 01:11:58 +07:00
vec2 coords = (T * u_texsize) + u_offset;
2018-09-08 10:24:55 +07:00
T += vec2(sin(coords.y / 3.0 + u_time / 20.0) / 240.0, sin(coords.x / 3.0 + u_time / 20.0) / 240.0) * u_scaling;
2017-10-25 01:11:58 +07:00
2018-09-08 10:24:55 +07:00
float si = sin(u_time / 20.0) / 8.0;
2018-09-08 10:24:55 +07:00
vec4 color = texture2D(u_texture, T);
vec2 v = vec2(1.0/u_texsize.x, 1.0/u_texsize.y);
bool any = false;
float thickness = 1.0;
2018-09-08 10:24:55 +07:00
float step = 2.0;
if(texture2D(u_texture, T).a < 0.1 &&
(texture2D(u_texture, T + vec2(0, step) * v).a > 0.1 || texture2D(u_texture, T + vec2(0, -step) * v).a > 0.1 ||
texture2D(u_texture, T + vec2(step, 0) * v).a > 0.1 || texture2D(u_texture, T + vec2(-step, 0) * v).a > 0.1))
any = true;
if(any){
2018-09-08 10:24:55 +07:00
gl_FragColor = mix(u_color, vec4(1.0), si);
}else{
if(color.a > 0.1){
if(mod(coords.x / u_dp + coords.y / u_dp + sin(round(coords.x / u_dp) / 5.0) * 3.0 + sin(round(coords.y / u_dp) / 5.0) * 3.0 + u_time / 4.0, 10.0) < 2.0){
color *= 1.65;
}
2017-12-06 00:21:08 +07:00
color.a = ALPHA;
}
gl_FragColor = color;
}
}