Tetra1

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

Loosely Based on a 4D shape I see on shrooms lol

Tags: 4d, Tesseract, Double rotation

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)

// "Merry's Hyper-Tetragrammaton"
// Based on "tetra3.txt": A 4D object gyrating into/out of itself.
// Concepts: Raymarching, Space Folding, 4D Rotation

// --- 🎛️ REALITY SETTINGS ---
#define FIELD_DENSITY 0.8    // How close the "interlocking shapes" are
#define MORPH_SPEED 0.4      // How fast it turns inside out
#define COLOR_SHIFT 0.2      // Speed of the rainbow cycle
#define GLITCH_INTENSITY 0.5 // How much the screen melts

// --- 🎨 THE "DIVINE" PALETTE ---
// A maximalist, spectral palette to match the "colorful" request
vec3 palette( float t ) {
    vec3 a = vec3(0.5, 0.5, 0.5);
    vec3 b = vec3(0.5, 0.5, 0.5);
    vec3 c = vec3(1.0, 1.0, 1.0);
    vec3 d = vec3(0.00, 0.33, 0.67); // RGB phase shift
    return a + b*cos( 6.28318*(c*t+d) );
}

// Rotation Matrix (The math that spins the faces)
mat2 rot(float a) {
    float s = sin(a);
    float c = cos(a);
    return mat2(c, -s, s, c);
}

// THE SHAPE FORMULA
// This calculates the distance to the 4D object
float map(vec3 p) {
    vec3 p0 = p; // Remember original spot
    
    // 1. "Interlocking Field"
    // We repeat space infinitely
    p = fract(p * FIELD_DENSITY) - 0.5;
    
    // 2. The "Gyrating Into Itself" Motion
    // We rotate the object on different axes over time
    float t = iTime * MORPH_SPEED;
    
    // This loop folds space 3 times to create the "Tetragrammaton" complexity
    for (int i = 0; i < 3; i++) {
        p = abs(p) - 0.25; // FOLD: Mirror space (creates the symmetry)
        p.xy *= rot(t);    // SPIN: Rotate X/Y axis
        p.yz *= rot(t * 0.7); // SPIN: Rotate Y/Z axis
    }
    
    // 3. The Rhombic/Cube Shape
    // We mix a box shape with the folded space
    float d = length(max(abs(p) - 0.1, 0.0)); 
    
    return d;
}

void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
    
    // Normalize Screen
    vec2 uv = (fragCoord * 2.0 - iResolution.xy) / iResolution.y;
    vec2 uv0 = uv;
    
    // 4. The "Glitch" (Warping the lens)
    // As per your "glitch/biology" interest
    uv *= 1.0 - 0.1 * sin(uv.yx * 5.0 + iTime);

    // Camera Setup (Raymarching)
    vec3 ro = vec3(0.0, 0.0, -2.0 + iTime * 0.2); // Camera moving forward
    vec3 rd = normalize(vec3(uv, 1.0)); // Ray direction
    
    float t = 0.0; // Total distance traveled
    vec3 col = vec3(0.0);
    
    // MARCH THE RAYS
    // This loop fires pixels into the math world to find the shape
    for(int i = 0; i < 80; i++) {
        vec3 p = ro + rd * t; // Current position
        
        float d = map(p); // Ask: "How close am I to the shape?"
        
        t += d; // Move forward
        
        // 5. Coloring the "Soul"
        // If we are close to the shape, add color based on how weird the geometry is
        if (d < 0.001 || t > 100.0) break;
        
        // Accumulate Glow (Neon Effect)
        // darker center, glowing edges
        float glow = exp(-d * 8.0); 
        vec3 pCol = palette(length(p) * 0.5 + iTime * COLOR_SHIFT);
        col += pCol * glow * 0.05;
    }
    
    fragColor = vec4(col, 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