Galactic Center

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

Milky Way core with supermassive black hole and accretion disk.

Tags: 2D, Space, Galaxy, Black Hole

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)

// Galactic Center - Milky Way core with supermassive black hole
// Accretion disk and star clouds

float hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }

float noise(vec2 p) {
    vec2 i = floor(p);
    vec2 f = fract(p);
    f = f * f * (3.0 - 2.0 * f);
    return mix(mix(hash(i), hash(i + vec2(1.0, 0.0)), f.x),
               mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), f.x), f.y);
}

float fbm(vec2 p) {
    float v = 0.0, a = 0.5;
    for(int i = 0; i < 5; i++) {
        v += a * noise(p);
        p *= 2.0; a *= 0.5;
    }
    return v;
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
    vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
    float t = iTime * 0.1;
    
    // Deep space
    vec3 col = vec3(0.0, 0.01, 0.03);
    
    // Dense starfield
    float star = hash(uv * 400.0);
    star = pow(star, 25.0);
    col += vec3(0.9, 0.95, 1.0) * star;
    
    float r = length(uv);
    
    // Galactic bulge (central star cluster)
    float bulge = exp(-r * 3.0) * fbm(uv * 5.0 + t);
    vec3 bulgeCol = mix(vec3(1.0, 0.9, 0.7), vec3(0.9, 0.7, 0.5), bulge);
    col += bulgeCol * bulge * 0.8;
    
    // Spiral arms (Milky Way structure)
    float angle = atan(uv.y, uv.x);
    for(int arm = 0; arm < 4; arm++) {
        float armOffset = float(arm) * 1.57; // 90 degrees per arm
        float spiral = sin(angle * 2.0 + r * 4.0 - armOffset + t);
        spiral = smoothstep(0.3, 0.7, spiral) * smoothstep(0.8, 0.3, r);
        
        float armStars = fbm(uv * 8.0 + float(arm) * 10.0);
        armStars = pow(armStars, 2.0) * spiral;
        
        vec3 armCol = mix(
            vec3(0.6, 0.8, 1.0), // Blue young stars
            vec3(1.0, 0.9, 0.6), // Yellow old stars
            float(arm) / 4.0
        );
        
        col += armCol * armStars * 0.4;
    }
    
    // Central black hole shadow
    float blackHole = smoothstep(0.05, 0.0, r);
    col *= 1.0 - blackHole * 0.9;
    
    // Accretion disk
    float diskInner = 0.06;
    float diskOuter = 0.15;
    float inDisk = smoothstep(diskOuter, diskInner, r) * smoothstep(diskInner * 0.5, diskInner, r);
    
    // Hot accretion disk colors
    vec3 diskCol = mix(
        vec3(1.0, 0.9, 0.5), // Inner: hot yellow
        vec3(0.9, 0.3, 0.1), // Outer: cooler red
        (r - diskInner) / (diskOuter - diskInner)
    );
    
    float diskTurbulence = fbm(uv * 20.0 - t * 2.0);
    col += diskCol * inDisk * (0.5 + 0.5 * diskTurbulence) * 1.5;
    
    // Photon ring (gravitational lensing effect)
    float photonRing = smoothstep(0.065, 0.06, r) * smoothstep(0.055, 0.06, r);
    col += vec3(1.0, 0.95, 0.9) * photonRing * 0.8;
    
    // Doppler beaming (brighter on one side)
    float doppler = smoothstep(-0.5, 0.5, uv.x) * inDisk;
    col += diskCol * doppler * 0.3;
    
    fragColor = vec4(col, 1.0);
}

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