Last active
August 29, 2015 14:20
-
-
Save tado/a4e6ec6e284d2a2fdbcd to your computer and use it in GitHub Desktop.
Draw metaball-like circles.
This file contains 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
uniform float time; | |
uniform vec2 resolution; | |
uniform vec2 touches[10]; | |
float circle(vec2 p, vec2 center, float r) { | |
float d = distance(p, center); | |
return 1.0 * r / d; | |
} | |
void main( void ) { | |
vec2 position = ( gl_FragCoord.xy / resolution.xy ); | |
vec3 color = vec3(0.0, 0.0, 0.0); | |
for(int i=0; i<10; i++){ | |
float cr = circle(position, vec2(touches[i].x, touches[i].y), 0.02); | |
float cg = circle(position, vec2(touches[i].x, touches[i].y), 0.3); | |
float cb = circle(position, vec2(touches[i].x, touches[i].y), 0.4); | |
color.r += cr; | |
color.g += cg * 0.2; | |
color.b += cb * 0.5; | |
} | |
gl_FragColor = vec4( color.r, color.g * (sin(time*1.2) * 0.1 + 0.9), color.b * (cos(time*1.5) * 0.1 + 0.9), 0.5 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment