Created
March 18, 2018 23:30
-
-
Save nikibobi/cfe54a5aab6f65cb5b7e5c7a347860fa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef GL_FRAGMENT_PRECISION_HIGH | |
precision highp float; | |
#else | |
precision mediump float; | |
#endif | |
uniform vec2 resolution; | |
uniform int pointerCount; | |
uniform vec3 pointers[10]; | |
uniform float battery; | |
const float radius = 50.0; | |
const float stages = 8.0; | |
const vec3 b = vec3(0.325, 0.0, 0.5); | |
const vec3 w = vec3(0.325, 1.0, 0.0); | |
float metaball(vec2 x) { | |
x /= battery * 100.0; | |
return 1.0 / (dot(x, x) + .00001); | |
} | |
void main(void) { | |
float p = 0.0; | |
for (int n = 0; n < pointerCount; ++n) { | |
p += metaball(gl_FragCoord.xy - pointers[n].xy); | |
} | |
p = ceil(p * radius) / stages; | |
gl_FragColor.rgb = w * p + b; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment