Electric Storm

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

Forked lightning with ionization glow and storm atmosphere.

Tags: 2D, Lightning, Storm, Atmospheric

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)

// Electric Storm - Lightning discharge with plasma channels
// Forked lightning with ionization glow

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);
}

// Lightning bolt path
float lightning(vec2 uv, float seed) {
    float x = uv.x;
    float y = uv.y;
    
    // Main channel jitter
    float jitter = 0.0;
    float freq = 5.0;
    float amp = 0.1;
    
    for(int i = 0; i < 4; i++) {
        jitter += sin(x * freq + seed * 10.0 + float(i)) * amp;
        freq *= 2.0;
        amp *= 0.5;
    }
    
    // Distance from bolt center
    float d = abs(y - jitter);
    
    // Bolt thickness varies
    float thickness = 0.02 + noise(vec2(x * 20.0, seed)) * 0.02;
    
    return smoothstep(thickness, 0.0, d);
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
    vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
    float t = iTime * 5.0; // Fast lightning
    
    vec3 col = vec3(0.0, 0.02, 0.05);
    
    // Storm clouds (dark background)
    float clouds = noise(uv * 3.0 + t * 0.1);
    col = mix(col, vec3(0.05, 0.07, 0.1), clouds * 0.5);
    
    // Multiple lightning bolts
    for(int b = 0; b < 5; b++) {
        float fb = float(b);
        float seed = fb * 12.34 + floor(t * 0.5) * 10.0; // Change bolts over time
        
        // Forked lightning
        vec2 boltUV = uv;
        boltUV.x += fb * 0.5 - 1.0; // Spread bolts
        
        // Main bolt
        float mainBolt = lightning(boltUV, seed);
        
        // Forks
        float fork1 = lightning(boltUV - vec2(0.3, 0.2), seed + 1.0) * smoothstep(0.3, 0.0, boltUV.x);
        float fork2 = lightning(boltUV - vec2(0.5, -0.3), seed + 2.0) * smoothstep(0.5, 0.0, boltUV.x);
        
        float bolt = max(mainBolt, max(fork1 * 0.7, fork2 * 0.5));
        
        // Electric blue/white color
        vec3 boltCol = mix(vec3(0.8, 0.9, 1.0), vec3(0.6, 0.8, 1.0), noise(boltUV * 10.0));
        col += boltCol * bolt * 2.0;
        
        // Ionization glow around bolt
        float glow = bolt * 0.3;
        col += vec3(0.3, 0.6, 1.0) * glow * 0.5;
    }
    
    // Lightning flash illumination
    float flash = noise(vec2(t * 0.1, 0.0));
    flash = pow(flash, 5.0) * 0.3;
    col += vec3(0.9, 0.9, 1.0) * flash;
    
    // Rain streaks
    float rain = noise(vec2(uv.x * 50.0, uv.y * 10.0 + t * 5.0));
    rain = pow(rain, 10.0) * 0.3;
    col += vec3(0.7, 0.8, 1.0) * rain * smoothstep(0.0, -0.3, uv.y);
    
    // Tone map
    col = col / (1.0 + col * 0.5);
    col = pow(col, vec3(0.95));
    
    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