runnable fragment

Cellular Slime Mold

stronghold-curated generative glsl runnable fragment MIT
code snippet
precision mediump float;
uniform vec2 resolution;
uniform float time;
float hash(vec2 p){return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453);} 
void main(){
 vec2 uv=gl_FragCoord.xy/resolution.xy; uv.x*=resolution.x/resolution.y; vec2 g=uv*11.0,id=floor(g),f=fract(g); float acc=0.0;
 for(int y=-1;y<=1;y++)for(int x=-1;x<=1;x++){vec2 o=vec2(float(x),float(y));float r=hash(id+o);vec2 c=o+0.5+0.35*vec2(sin(time*.5+r*6.28),cos(time*.4+r*9.1))-f;float d=length(c);acc+=0.018/(0.012+d*d);} 
 float vein=smoothstep(0.55,1.2,acc); vec3 col=mix(vec3(0.015,0.025,0.012),vec3(0.55,0.95,0.18),vein); col+=pow(acc,2.0)*0.03; gl_FragColor=vec4(col,1.0);
}
runnable fragment

Ink Diffusion Bloom

stronghold-curated generative glsl runnable fragment MIT
code snippet
precision mediump float;
uniform vec2 resolution;
uniform float time;
float hash(vec2 p){return fract(sin(dot(p,vec2(77.7,33.3)))*43758.5453);} 
float noise(vec2 p){vec2 i=floor(p),f=fract(p);f=f*f*(3.0-2.0*f);return mix(mix(hash(i),hash(i+vec2(1,0)),f.x),mix(hash(i+vec2(0,1)),hash(i+1.0),f.x),f.y);} 
float fbm(vec2 p){float v=0.0,a=0.5;for(int i=0;i<6;i++){v+=a*noise(p);p*=2.02;a*=0.52;}return v;}
void main(){
 vec2 uv=(gl_FragCoord.xy-0.5*resolution.xy)/min(resolution.x,resolution.y);
 float n=fbm(uv*3.0+vec2(time*0.04,-time*0.03));
 float rings=sin((length(uv)+n*0.28-time*0.04)*32.0);
 float ink=smoothstep(0.2,0.95,n+0.25*rings);
 vec3 paper=vec3(0.92,0.86,0.74);
 vec3 dye=mix(vec3(0.05,0.03,0.12),vec3(0.35,0.03,0.24),n);
 gl_FragColor=vec4(mix(paper,dye,ink),1.0);
runnable fragment

Reaction Rings Approximation

stronghold-curated generative glsl runnable fragment MIT
code snippet
precision mediump float;
uniform vec2 resolution;
uniform float time;
float hash(vec2 p){return fract(sin(dot(p,vec2(41.0,289.0)))*45758.5453);} 
float noise(vec2 p){vec2 i=floor(p),f=fract(p);f=f*f*(3.0-2.0*f);return mix(mix(hash(i),hash(i+vec2(1,0)),f.x),mix(hash(i+vec2(0,1)),hash(i+1.0),f.x),f.y);} 
float fbm(vec2 p){float v=0.0,a=0.55;for(int i=0;i<5;i++){v+=a*noise(p);p*=2.05;a*=0.52;}return v;}
void main(){
 vec2 uv=(gl_FragCoord.xy-0.5*resolution.xy)/min(resolution.x,resolution.y);
 float n=fbm(uv*3.4+vec2(time*0.035,-time*0.025));
 float v=sin((length(uv)+n*0.42)*48.0-time*1.2);
 float cells=smoothstep(0.18,0.82,v)*smoothstep(1.05,0.35,n);
 vec3 a=vec3(0.02,0.03,0.055), b=vec3(0.96,0.76,0.28), c=vec3(0.2,0.75,0.72);
 gl_FragColor=vec4(mix(a,mix(b,c,n),cells),1.0);
}