2017-10-22 08:21:04 +07:00
|
|
|
#ifdef GL_ES
|
2017-12-27 05:58:20 +07:00
|
|
|
precision highp float;
|
|
|
|
precision highp int;
|
2017-10-22 08:21:04 +07:00
|
|
|
#endif
|
|
|
|
|
2017-11-28 13:00:59 +07:00
|
|
|
#define MAX_HITS 64
|
|
|
|
#define HIT_RADIUS 12.0
|
2017-12-06 00:21:08 +07:00
|
|
|
#define ALPHA 0.18
|
2017-11-28 13:00:59 +07:00
|
|
|
|
2017-10-22 08:21:04 +07:00
|
|
|
uniform sampler2D u_texture;
|
|
|
|
|
|
|
|
uniform vec4 u_color;
|
|
|
|
uniform vec2 u_texsize;
|
|
|
|
uniform float u_time;
|
2017-11-21 07:02:35 +07:00
|
|
|
uniform float u_scaling;
|
2017-12-27 05:58:20 +07:00
|
|
|
uniform float u_dp;
|
2017-10-22 08:21:04 +07:00
|
|
|
uniform vec2 u_offset;
|
2017-11-28 13:00:59 +07:00
|
|
|
uniform int u_hitamount;
|
|
|
|
uniform vec3 u_hits[MAX_HITS];
|
2017-10-22 08:21:04 +07:00
|
|
|
|
|
|
|
varying vec4 v_color;
|
|
|
|
varying vec2 v_texCoord;
|
|
|
|
|
2017-12-27 05:58:20 +07:00
|
|
|
float round(float f){
|
|
|
|
return float(int(f));
|
|
|
|
}
|
|
|
|
|
2017-10-22 08:21:04 +07:00
|
|
|
void main() {
|
|
|
|
|
|
|
|
vec2 T = v_texCoord.xy;
|
2017-10-25 01:11:58 +07:00
|
|
|
|
2017-10-22 08:21:04 +07:00
|
|
|
vec2 coords = (T * u_texsize) + u_offset;
|
|
|
|
|
2017-12-27 05:58:20 +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
|
|
|
|
2017-12-27 05:58:20 +07:00
|
|
|
float si = 1.0 + sin(u_time / 20.0) / 8.0;
|
2017-10-22 08:21:04 +07:00
|
|
|
|
|
|
|
vec4 color = texture2D(u_texture, T) * vec4(si, si, si, 1.0);
|
|
|
|
|
|
|
|
vec2 v = vec2(1.0/u_texsize.x, 1.0/u_texsize.y);
|
|
|
|
|
|
|
|
bool any = false;
|
|
|
|
|
|
|
|
float thickness = 1.0;
|
2017-10-25 01:11:58 +07:00
|
|
|
float step = 1.5;
|
2017-10-22 08:21:04 +07:00
|
|
|
|
|
|
|
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){
|
|
|
|
gl_FragColor = u_color * vec4(si, si, si, 1.0);
|
|
|
|
}else{
|
2017-12-27 05:58:20 +07:00
|
|
|
|
2017-10-22 08:21:04 +07:00
|
|
|
if(color.a > 0.1){
|
2017-12-27 05:58:20 +07:00
|
|
|
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){
|
2017-10-23 03:24:49 +07:00
|
|
|
color *= 1.65;
|
2017-10-22 08:21:04 +07:00
|
|
|
}
|
|
|
|
|
2017-12-06 00:21:08 +07:00
|
|
|
color.a = ALPHA;
|
2017-11-28 13:00:59 +07:00
|
|
|
|
2017-12-09 08:59:40 +07:00
|
|
|
for(int i = 0; i < MAX_HITS; i ++){
|
|
|
|
if(i >= u_hitamount) break;
|
2017-11-28 13:00:59 +07:00
|
|
|
vec3 hit = u_hits[i];
|
|
|
|
float rad = hit.z * HIT_RADIUS;
|
2018-04-06 09:30:25 +07:00
|
|
|
float fin = 1.0 - hit.z;
|
2017-11-28 13:00:59 +07:00
|
|
|
|
|
|
|
if(abs(distance(vec2(hit.x, hit.y), coords - u_texsize/2.0) - rad) < 1.0){
|
2018-04-06 09:30:25 +07:00
|
|
|
color = mix(color, u_color* vec4(si, si, si, 1.0), (1.0 * fin));
|
|
|
|
color.a = ALPHA + 0.82 *fin;
|
2017-11-28 13:00:59 +07:00
|
|
|
}
|
|
|
|
}
|
2017-10-22 08:21:04 +07:00
|
|
|
}
|
2017-11-28 13:00:59 +07:00
|
|
|
|
2017-10-22 08:21:04 +07:00
|
|
|
gl_FragColor = color;
|
|
|
|
}
|
|
|
|
}
|