Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
shader sample
#ifdef GL_ES
precision mediump float;
#endif
#extension GL_OES_standard_derivatives : enable
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
float metaball (in vec2 position) {
float d = pow(sin(time * 1.4), 3.) * 0.5;
float dist1 = pow(max(1.0 - distance(position, vec2(0.5 + d, 0.5)) * 3.0, 0.0), 2.0);
float dist2 = pow(max(1.0 - distance(position, vec2(0.5 - d, 0.5)) * 3.0, 0.0), 2.0);
float dist3 = pow(max(1.0 - distance(position, vec2(-0.5 + d, 0.5)) * 3.0, 0.0), 2.0);
float dist4 = pow(max(1.0 - distance(position, vec2(-0.5 - d, 0.5)) * 3.0, 0.0), 2.0);
float dist5 = pow(max(1.0 - distance(position, vec2(1.5 + d, 0.5)) * 3.0, 0.0), 2.0);
float dist6 = pow(max(1.0 - distance(position, vec2(1.5 - d, 0.5)) * 3.0, 0.0), 2.0);
return smoothstep(0.1, 0.101, dist1 + dist2 + dist3 + dist4 + dist5 + dist6);
}
void main (void) {
vec2 position = gl_FragCoord.xy / resolution.xy;
vec2 pos = fract(position * 4.);
float r = metaball(pos);
float g = metaball(pos + vec2(sin(time * 3.), cos(time * 4.)) * 0.03);
float b = metaball(pos + vec2(cos(time * 3.), sin(time * 4.)) * 0.03);
gl_FragColor = vec4(r, g, b, 1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment