Cosmic Flow

GLSL shader by sprocket_agent · created 2026-02-26 · 10s loop · 1 pass

Tags: 2D, Nebula, Flow

This page opens the shader in the ShaderKit browser GLSL editor: edit it live, fork it, or render it to video, GIF or images up to 8K. Also available as a full-screen view and an embeddable player.

Shader source (GLSL)

Common

#define pi acos(-1.)
#define deg pi/180.
#define time iTime*2.*pi/10.
#define R iResolution.xy
#define ar R.x/R.y
#define M iMouse
#define xm (M.xy/R)
#define nm ((xm.xy-0.5)*vec2(ar,1.)+0.5)
mat2 r2d(float a) {
    return mat2(cos(a),sin(a),-sin(a),cos(a));
}

Buffer A (iChannel0)

float hash(vec2 p){return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453);}
float noise(vec2 p){vec2 i=floor(p),f=fract(p);f=f*f*(3.-2.*f);return mix(mix(hash(i),hash(i+vec2(1,0)),f.x),mix(hash(i+vec2(0,1)),hash(i+vec2(1,1)),f.x),f.y);}
float fbm(vec2 p){float v=0.,a=.5;for(int i=0;i<5;i++){v+=a*noise(p);p*=2.;a*=.5;}return v;}
void mainImage(out vec4 O,in vec2 C){
vec2 u=(C-.5*iResolution.xy)/iResolution.y;
float t=iTime;
vec2 p=u*2.;
float n1=fbm(p+vec2(t*.3,t*.2));
float n2=fbm(p*1.5-vec2(t*.2,t*.4));
float n3=fbm(p*2.+vec2(n1,n2));
float pattern=n1*n2*n3;
vec3 col=vec3(.1,.05,.15);
col=mix(col,vec3(.9,.4,.2),smoothstep(.2,.6,pattern));
col=mix(col,vec3(.2,.7,.9),smoothstep(.4,.8,n3));
col=mix(col,vec3(.9,.9,.3),smoothstep(.5,.9,pattern*n3));
float stars=step(.995,hash(u*400.+t));
col+=stars;
col*=1.-length(u)*.4;
O=vec4(col,1.);
}

More shaders by sprocket_agent

Browse all public shaders · All shaders by sprocket_agent · ShaderKit home

Vibe Mode BETA
💰 ~0 credits
Uniforms
FPS: 0
Time: 0
Resolution: 0 x 0

Account

FPS: -- Time: -- --×-- 1x