Diamond sway

GLSL shader by merrypranxter · created 2026-02-12 · 10s loop · 2 passes

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.  //1 degree
#define time iTime*2.*pi/10. //sin(time) loops 10 seconds
#define R iResolution.xy //shorthand
#define ar R.x/R.y //aspect ratio
#define M iMouse //shorthand
#define xm (M.xy/R) //normalized mouse
#define nm ((xm.xy-0.5)*vec2(ar,1.)+0.5) //aspect ratio correction
vec3 cs = vec3(1.,2.,3.);
mat2 r2d(float a) {
    return mat2(cos(a),sin(a),-sin(a),cos(a));
}

Buffer A (iChannel0)

// --- 1. THE DEFINES (NEW BIOME SETTINGS) ---
#define ITERATIONS 8.0   // HOW DEEP THE CITY GOES
#define SPEED iTime * 0.2
#define SHINE_EDGE 3.0   // RAZOR SHARP HIGHLIGHTS
#define ACID_LEVEL 1.2   // SATURATION OVERLOAD

// --- 2. THE MATH ENGINE (RECTILINEAR LOGIC) ---

mat2 rot(float a) { return mat2(cos(a), -sin(a), sin(a), cos(a)); }

// HASH FOR DIGITAL GRIT
float hash(vec2 p) {
    p = fract(p * vec2(123.34, 456.21));
    p += dot(p, p + 45.32);
    return fract(p.x * p.y);
}

// THE LISA FRANK OXIDE PALETTE
vec3 bismuth_palette(float t) {
    vec3 a = vec3(0.5, 0.5, 0.5);
    vec3 b = vec3(0.5, 0.5, 0.5);
    // The Bismuth Spectrum: Gold, Pink, Cyan, Purple
    vec3 c = vec3(1.0, 1.0, 1.0);
    vec3 d = vec3(0.0, 0.33, 0.67); 
    return a + b * cos(6.28318 * (c * t + d + iTime * 0.1));
}

// --- 3. THE RENDERER (THE CRYSTAL CITY) ---

void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
    // 1. Normalize
    vec2 uv = (fragCoord * 2.0 - iResolution.xy) / iResolution.y;
    vec2 uv0 = uv;
    
    // 2. THE "GROWTH" LOOP
    vec3 final_col = vec3(0.0);
    float d = 0.0;
    float scale = 1.0;
    
    // Pre-warp for that "Melting" feel
    uv += vec2(sin(uv.y * 2.0 + SPEED), cos(uv.x * 2.0 + SPEED)) * 0.1;

    for(float i = 0.0; i < ITERATIONS; i++) {
        // --- THE GEOMETRY SHIFT ---
        // Instead of Rhombs, we use SQUARES and BOXES
        
        // 1. Space Folding (Kaleidoscope effect)
        uv = abs(uv) - 0.4 / scale; // Shrink the fold as we go deeper
        
        // 2. Rectilinear Rotation (Snap to grid feel)
        uv *= rot(SPEED * 0.5 + i * 0.785); // 0.785 is approx 45 degrees
        
        // 3. The Shape (Box Distance)
        // max(abs(x), abs(y)) creates squares!
        float box = max(abs(uv.x), abs(uv.y));
        
        // 4. Update Distance
        d = box * exp(-length(uv0)); 
        
        // 5. THE COLOR ACCUMULATION
        // Calculate the "Oxide Layer" thickness
        float oxide = abs(sin(d * 10.0 + iTime));
        
        // Get the color
        vec3 col = bismuth_palette(d * 4.0 + i * 0.2 + oxide);
        
        // 6. THE SHINE (EDGE DETECTION)
        // Make the edges of the squares glow white hot
        float edge = 0.01 / abs(box - 0.2); // Glowing square ring
        edge = pow(edge, 1.2); // Sharpen it
        
        // Accumulate
        final_col += col * edge * scale * 0.4;
        
        // Prepare for next layer
        scale *= 1.1; // Grow slightly
    }
    
    // 3. THE TEXTURE (DIGITAL DUST)
    // Add that "Intricate Little Texture" feel
    float grit = hash(uv * 100.0 + iTime);
    final_col += (grit - 0.5) * 0.2;
    
    // 4. THE SPARKLE (CORNER FLASHES)
    // Flash where the squares overlap
    float sparkle = smoothstep(0.98, 1.0, hash(uv0 * 20.0 + iTime));
    final_col += vec3(1.5) * sparkle * bismuth_palette(sparkle);

    // 5. FINAL POLISH (ACID BATH)
    // Boost saturation and contrast
    final_col = pow(final_col, vec3(1.2)); // Contrast
    final_col *= ACID_LEVEL; // Brightness
    
    // Vignette to frame the city
    final_col *= 1.2 - length(uv0) * 0.6;

    fragColor = vec4(clamp(final_col, 0.0, 1.0), 1.0);
}

Image

Not used

More shaders by merrypranxter

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

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

Account

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