Neon Nebula

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

3D volumetric gas clouds with glowing neon filaments.

Tags: 3D, Volume, Nebula, 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)

// Neon Nebula - 3D raymarched volumetric gas clouds
// Glowing ionized gases with neon colors

#define MAX_STEPS 80
#define MAX_DIST 30.0
#define SURF_DIST 0.005

// Rotation matrix
mat2 rot(float a) {
    float s = sin(a), c = cos(a);
    return mat2(c, -s, s, c);
}

// 3D hash
float hash(vec3 p) {
    return fract(sin(dot(p, vec3(127.1, 311.7, 74.7))) * 43758.5453);
}

// 3D noise
float noise(vec3 p) {
    vec3 i = floor(p);
    vec3 f = fract(p);
    f = f * f * (3.0 - 2.0 * f);
    
    return mix(mix(mix(hash(i), 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);
}

// Fbm for nebula density
float fbm(vec3 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;
}

// Nebula density field (not SDF - for volume rendering)
float nebulaDensity(vec3 p, float t) {
    // Domain warp for organic shapes
    vec3 q = vec3(fbm(p * 0.5 + t * 0.1), fbm(p * 0.5 + vec3(5.2, 1.3, 2.8)));
    vec3 r = vec3(fbm(p * 0.5 + q * 1.5 + t * 0.15), fbm(p * 0.5 + q * 1.5 + vec3(1.7, 9.2, 3.4)));
    
    float d = fbm(p * 1.5 + r * 0.5 + t * 0.05);
    
    // Create filament structure
    d = smoothstep(0.3, 0.7, d) * smoothstep(0.9, 0.5, d);
    
    return d;
}

// Soft sphere SDF for containment
float sdSphere(vec3 p, float r) {
    return length(p) - r;
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
    vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
    float t = iTime * 0.1;
    
    // Camera
    vec3 ro = vec3(0.0, 0.0, -8.0);
    vec3 rd = normalize(vec3(uv, 1.2));
    
    // Rotate camera slowly
    ro.xz *= rot(t * 0.2);
    rd.xz *= rot(t * 0.2);
    ro.xy *= rot(sin(t * 0.1) * 0.1);
    rd.xy *= rot(sin(t * 0.1) * 0.1);
    
    // Volume raymarch
    vec3 col = vec3(0.0);
    float transp = 1.0;
    
    float d = 0.0;
    for(int i = 0; i < 60; i++) {
        vec3 p = ro + rd * d;
        
        // Container sphere
        if(sdSphere(p, 6.0) > 0.0) break;
        
        float density = nebulaDensity(p, t);
        
        // Neon colors based on position
        vec3 neon = vec3(
            0.5 + 0.5 * sin(p.x * 0.5 + t),
            0.5 + 0.5 * cos(p.y * 0.3 + t * 0.7),
            0.5 + 0.5 * sin(p.z * 0.4 + t * 0.5)
        );
        neon = pow(neon, vec3(0.7));
        
        // Emission
        col += neon * density * transp * 0.15;
        transp *= (1.0 - density * 0.1);
        
        if(transp < 0.01) break;
        
        d += 0.15;
        if(d > MAX_DIST) break;
    }
    
    // Background stars
    vec3 starPos = vec3(uv * 200.0, 0.0);
    float s = hash(starPos);
    s = pow(s, 50.0) * 2.0;
    col += vec3(0.9, 0.95, 1.0) * s * (1.0 - transp);
    
    // Tone map
    col = col / (1.0 + col * 0.8);
    col = pow(col, vec3(0.9));
    
    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