xxxxxxxxxx
48
precision mediump float;
varying vec2 vTexCoord;
uniform sampler2D texture;
uniform vec3 balls[50];
uniform float width;
uniform float height;
void main() {
vec2 uv = vTexCoord;
uv.y = 1.0 - uv.y;
vec3 col;
vec4 _col = texture2D(texture, uv);
col = _col.rgb;
float x = gl_FragCoord.x;
float y = gl_FragCoord.y;
float sum = 0.0;
for (int i = 0; i < 50; i++) {
vec3 ball = balls[i];
float dx = ball.x - x;
float dy = ball.y - y;
float radius = ball.z;
sum += (radius * radius) / (dx * dx + dy * dy);
}
// glitch
vec2 offset = vec2(0.5*0.05, 0.0)://noise * 0.05, 0.0);
col.r = texture2D(texture, uv+offset).r;
col.g = texture2D(texture, uv).g;
col.b = texture2D(texture, uv-offset).b;
if (sum >= 0.99) {
vec3 col1 = mix(vec3(x / width, y / height, 1.0), vec3(0, 0, 0), max(0.0, 1.0 - (sum - 0.99) * 100.0));
vec3 col2 = step(col1, col
gl_FragColor = vec4(col2, 1.0);
return;
}
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
}