Back to shaders
Shader test bench
Cellular Slime Mold
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 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);
}