Back to shaders
Shader test bench
Nebula Dust Cloud
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(31.7,91.1)))*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.03+0.05*sin(time);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*2.2+vec2(time*0.025,-time*0.015));
float d=smoothstep(0.78,0.2,length(uv));
vec3 col=mix(vec3(0.03,0.02,0.08), vec3(0.85,0.18,0.65), n);
col=mix(col, vec3(0.12,0.55,1.0), smoothstep(0.45,0.85,fbm(uv*4.0-time*0.02)));
gl_FragColor=vec4(col*n*d,1.0);
}