Back to shaders
Shader test bench
Iridescent Oil Slick
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(12.989,78.233)))*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);}
void main(){
vec2 uv=gl_FragCoord.xy/resolution.xy; uv.x*=resolution.x/resolution.y;
float n=noise(uv*5.0+time*0.05)+0.5*noise(uv*13.0-time*0.04);
float phase=n*8.0+uv.x*4.0-uv.y*3.0+time*0.15;
vec3 rainbow=0.5+0.5*cos(phase+vec3(0.0,2.09,4.18));
float sheen=smoothstep(0.2,1.0,n);
gl_FragColor=vec4(mix(vec3(0.015,0.012,0.018), rainbow, sheen),1.0);
}