Cosmic Cathedral

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

Tags: 3D, Volumetric, Atmospheric, Light, Abstract

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(vec3 p) {
    p = vec3(dot(p, vec3(127.1, 311.7, 74.7)),
             dot(p, vec3(269.5, 183.3, 246.1)),
             dot(p, vec3(113.5, 271.9, 124.6)));
    return fract(sin(p.x) * 43758.5453);
}

float noise(vec3 p) {
    vec3 i = floor(p);
    vec3 f = fract(p);
    f = f * f * (3.0 - 2.0 * f);
    
    float n = mix(
        mix(mix(hash(i + vec3(0,0,0)), hash(i + vec3(1,0,0)), f.x),
            mix(hash(i + vec3(0,1,0)), hash(i + vec3(1,1,0)), f.x), f.y),
        mix(mix(hash(i + vec3(0,0,1)), hash(i + vec3(1,0,1)), f.x),
            mix(hash(i + vec3(0,1,1)), hash(i + vec3(1,1,1)), f.x), f.y), f.z
    );
    return n;
}

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

float sdBox(vec3 p, vec3 b) {
    vec3 q = abs(p) - b;
    return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0);
}

float sdCyl(vec3 p, float r, float h) {
    vec2 d = vec2(length(p.xz) - r, abs(p.y) - h);
    return min(max(d.x, d.y), 0.0) + length(max(d, 0.0));
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
    vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
    
    // Camera setup
    vec3 ro = vec3(0.0, 0.0, -6.0);
    vec3 rd = normalize(vec3(uv, 1.5));
    
    // Slight camera movement
    ro.x += sin(iTime * 0.2) * 0.5;
    rd.xz *= mat2(cos(iTime * 0.1), -sin(iTime * 0.1), sin(iTime * 0.1), cos(iTime * 0.1));
    
    // Ray march through volume
    vec3 col = vec3(0.0);
    float transmittance = 1.0;
    float t = 0.1;
    
    for(int i = 0; i < 128; i++) {
        vec3 p = ro + rd * t;
        
        // Cathedral arch structure (subtractive SDF)
        float arch = sdBox(p - vec3(0.0, 0.0, 2.0), vec3(4.0, 5.0, 1.0));
        arch = max(arch, -sdCyl(p - vec3(0.0, 0.0, 2.0), 2.5, 6.0));
        
        // Light beam source at top
        vec3 lightPos = vec3(sin(iTime * 0.3) * 1.5, 3.5, 1.0);
        float lightDist = length(p - lightPos);
        
        // Volumetric density
        float density = fbm(p * 0.5 + iTime * 0.1);
        density *= smoothstep(5.0, 0.0, lightDist);
        density *= smoothstep(6.0, 0.0, length(p));
        density = max(0.0, density - 0.3) * 0.5;
        
        // Light color based on height
        vec3 lightCol = mix(vec3(0.9, 0.6, 0.3), vec3(0.3, 0.6, 0.9), p.y * 0.15 + 0.5);
        lightCol += vec3(0.8, 0.4, 0.6) * sin(p.x * 0.5 + iTime);
        
        // Accumulate light
        col += lightCol * density * transmittance;
        transmittance *= exp(-density * 0.1);
        
        // March forward
        t += 0.05 + t * 0.02;
        if(transmittance < 0.01 || t > 20.0) break;
    }
    
    // Add floating particles
    float particles = 0.0;
    for(int i = 0; i < 30; i++) {
        float fi = float(i);
        vec3 pPos = vec3(
            sin(fi * 1.3 + iTime * 0.5) * 3.0,
            cos(fi * 0.7 + iTime * 0.3) * 2.0 + fi * 0.1,
            sin(fi * 0.9) * 2.0 + 1.0
        );
        float d = length(ro + rd * 5.0 - pPos);
        particles += 0.01 / (0.1 + d * d);
    }
    col += vec3(0.9, 0.8, 0.6) * particles;
    
    // Background gradient
    vec3 bg = vec3(0.02, 0.01, 0.05) * (1.0 - uv.y * 0.3);
    col = mix(bg, col, 1.0 - transmittance);
    
    // Vignette
    col *= 1.0 - length(uv) * 0.5;
    
    // Tone map
    col = col / (1.0 + col);
    col = pow(col, vec3(0.85));
    
    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