Back to shaders
Shader test bench
Lava Lamp Cells
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;
void main(){
vec2 uv=(gl_FragCoord.xy*2.0-resolution.xy)/min(resolution.x,resolution.y);
float field=0.0;
for(int i=0;i<7;i++){
float fi=float(i);
vec2 c=vec2(sin(time*(0.25+fi*0.04)+fi*1.8), cos(time*(0.31+fi*0.03)+fi*2.4))*0.62;
field += (0.05+0.015*sin(time+fi))/max(0.015, dot(uv-c,uv-c));
}
float lava=smoothstep(0.8,2.2,field);
vec3 col=mix(vec3(0.04,0.0,0.02), vec3(1.0,0.18,0.02), lava);
col += vec3(1.0,0.75,0.12)*smoothstep(2.6,5.0,field);
gl_FragColor=vec4(col,1.0);
}