Back to shaders

Shader test bench

SDF Soft Blobs

stronghold-curated sdf glsl runnable fragment MIT
Source
runnable fragment

Complete GLSL fragment shader. Stronghold runs it directly when the browser can compile it.

Code

precision mediump float;
uniform vec2 resolution;
uniform float time;
float circle(vec2 p, vec2 c, float r){ return length(p-c)-r; }
void main(){
 vec2 uv=(gl_FragCoord.xy*2.0-resolution.xy)/min(resolution.x,resolution.y);
 float d=10.0;
 for(int i=0;i<6;i++){
   float fi=float(i);
   vec2 c=0.48*vec2(sin(time*(0.4+fi*0.07)+fi*1.7), cos(time*(0.35+fi*0.05)+fi*2.1));
   d=min(d, circle(uv,c,0.22+0.04*sin(time+fi)));
 }
 float fill=smoothstep(0.035,-0.025,d);
 float glow=0.018/max(0.018,abs(d));
 vec3 col=mix(vec3(0.02,0.03,0.08), vec3(0.4,0.9,1.0), fill) + glow*vec3(0.25,0.45,0.9);
 gl_FragColor=vec4(col,1.0);
}