Skip to content

Instantly share code, notes, and snippets.

@nikibobi
Created March 18, 2018 23:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikibobi/cfe54a5aab6f65cb5b7e5c7a347860fa to your computer and use it in GitHub Desktop.
Save nikibobi/cfe54a5aab6f65cb5b7e5c7a347860fa to your computer and use it in GitHub Desktop.
#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