Arcane Buff Aura Vortex shader

arcane-buff-aura-vortex.glsl · 995 lines · GLSL ES 3.00 · MIT

Arcane Buff Aura VortexGame VFX3s Loop
Arcane Buff Aura Vortex WebGL2 procedural shader preview
FPS 60BUFFER 960×540SOURCE 995 linesSPEC GLSL ES 3.00

Seamless PNG Texture Baker
1-Click Engine Shader Export
WebGL2 .glsl
.glsl
Godot 4 .gdshader
Three.js GLSL3

Engine shader code & wrappers

Arcane Palette
arcane-buff-aura-vortex.glsl (995 lines)
#version 300 es
// Arcane Buff Aura Vortex (arcane-buff-aura-vortex.glsl)
// Upstream study: https://github.com/gokayfem/glsl-studies/blob/main/vfx_palette/lib/07_arcane_buff_aura_vortex.glsl
// License: MIT (Copyright 2026 Gokay Aydogan) + MIT/CC0 helpers — https://pixelfx.io/LICENSE-SHADERS.txt
// Uniforms: uResolution (vec2), uTime (float), uOpen (0..1), uLightMode (0..3), uCamMode (0..1)
precision highp float;
precision highp int;

uniform vec2 uResolution;
uniform float uTime;
uniform float uOpen;
uniform int uLightMode;
uniform int uCamMode;

out vec4 fragColor;

// ============================================================================
// UNIFIED ARCANE PALETTE (LOCKED)
// ============================================================================
const vec3 COL_OBSIDIAN   = vec3(0.03, 0.05, 0.12);
const vec3 COL_COBALT     = vec3(0.08, 0.32, 0.98);
const vec3 COL_CYAN       = vec3(0.10, 0.85, 1.00);
const vec3 COL_GOLD       = vec3(1.00, 0.68, 0.18);
const vec3 COL_WHITE_GOLD = vec3(1.00, 0.96, 0.86);

const float PI  = 3.14159265359;
const float TAU = 6.28318530718;

// ============================================================================
// MATH & NOISE UTILITIES
// ============================================================================
mat2 rot2D(float a) {
    float c = cos(a);
    float s = sin(a);
    return mat2(c, -s, s, c);
}

float hash11(float p) {
    p = fract(p * 0.1031);
    p *= p + 33.33;
    p *= p + p;
    return fract(p);
}

float hash12(vec2 p) {
    vec3 p3 = fract(vec3(p.xyx) * 0.1031);
    p3 += dot(p3, p3.yzx + 33.33);
    return fract((p3.x + p3.y) * p3.z);
}

float hash13(vec3 p3) {
    p3 = fract(p3 * 0.1031);
    p3 += dot(p3, p3.zyx + 31.32);
    return fract((p3.x + p3.y) * p3.z);
}

vec2 hash22(vec2 p) {
    vec3 p3 = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));
    p3 += dot(p3, p3.yzx + 33.33);
    return fract((p3.xx + p3.yz) * p3.zy);
}

float noise2D(vec2 p) {
    vec2 i = floor(p);
    vec2 f = fract(p);
    vec2 u = f * f * (3.0 - 2.0 * f);
    float a = hash12(i);
    float b = hash12(i + vec2(1.0, 0.0));
    float c = hash12(i + vec2(0.0, 1.0));
    float d = hash12(i + vec2(1.0, 1.0));
    return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);
}

float noise3D(vec3 p) {
    vec3 i = floor(p);
    vec3 f = fract(p);
    vec3 u = f * f * (3.0 - 2.0 * f);
    float n000 = hash13(i + vec3(0.0, 0.0, 0.0));
    float n100 = hash13(i + vec3(1.0, 0.0, 0.0));
    float n010 = hash13(i + vec3(0.0, 1.0, 0.0));
    float n110 = hash13(i + vec3(1.0, 1.0, 0.0));
    float n001 = hash13(i + vec3(0.0, 0.0, 1.0));
    float n101 = hash13(i + vec3(1.0, 0.0, 1.0));
    float n011 = hash13(i + vec3(0.0, 1.0, 1.0));
    float n111 = hash13(i + vec3(1.0, 1.0, 1.0));
    float nx00 = mix(n000, n100, u.x);
    float nx10 = mix(n010, n110, u.x);
    float nx01 = mix(n001, n101, u.x);
    float nx11 = mix(n011, n111, u.x);
    return mix(mix(nx00, nx10, u.y), mix(nx01, nx11, u.y), u.z);
}

float fbm2D(vec2 p) {
    float v = 0.0;
    float a = 0.5;
    mat2 m = mat2(0.80, -0.60, 0.60, 0.80);
    for (int i = 0; i < 4; i++) {
        v += a * noise2D(p);
        p = m * p * 2.03 + vec2(17.1, 31.7);
        a *= 0.5;
    }
    return v;
}

float fbm3D(vec3 p) {
    float v = 0.0;
    float a = 0.5;
    for (int i = 0; i < 3; i++) {
        v += a * noise3D(p);
        p = p * 2.07 + vec3(13.3, 29.1, 7.7);
        a *= 0.5;
    }
    return v;
}

// Voronoi edge distance for sculpted stone fracture cracks
float voronoiEdge2D(vec2 x) {
    vec2 n = floor(x);
    vec2 f = fract(x);
    vec2 mg, mr;
    float md = 8.0;
    for (int j = -1; j <= 1; j++) {
        for (int i = -1; i <= 1; i++) {
            vec2 g = vec2(float(i), float(j));
            vec2 o = hash22(n + g);
            vec2 r = g + o - f;
            float d = dot(r, r);
            if (d < md) {
                md = d;
                mr = r;
                mg = g;
            }
        }
    }
    md = 8.0;
    for (int j = -1; j <= 1; j++) {
        for (int i = -1; i <= 1; i++) {
            vec2 g = mg + vec2(float(i), float(j));
            vec2 o = hash22(n + g);
            vec2 r = g + o - f;
            if (dot(mr - r, mr - r) > 0.0001) {
                md = min(md, dot(0.5 * (mr + r), normalize(r - mr)));
            }
        }
    }
    return md;
}

float smin(float a, float b, float k) {
    float h = max(k - abs(a - b), 0.0) / max(k, 1e-5);
    return min(a, b) - h * h * k * 0.25;
}

float smax(float a, float b, float k) {
    return -smin(-a, -b, k);
}

// ============================================================================
// SOLID GEOMETRY SDF: HEXAGONAL STONE ALTAR + WET OBSIDIAN TILED FLOOR
// ============================================================================
float sdHexPrismY(vec3 p, float r, float h, float bevel) {
    const vec3 k = vec3(-0.866025404, 0.5, 0.577350269);
    vec2 q = abs(p.xz);
    q -= 2.0 * min(dot(k.xy, q), 0.0) * k.xy;
    vec2 d = vec2(
        length(q - vec2(clamp(q.x, -k.z * r, k.z * r), r)) * sign(q.y - r),
        abs(p.y) - h
    );
    return min(max(d.x, d.y), 0.0) + length(max(d, 0.0)) - bevel;
}

// Weathering fracture mask on the hexagonal altar
float altarCrackField(vec3 p) {
    float ang = atan(p.z, p.x);
    vec2 uv = vec2(ang * 1.45, p.y * 2.8);
    // Warp slightly for organic chiseled stone cracks
    uv += (fbm2D(uv * 2.2) - 0.5) * 0.35;
    float e1 = voronoiEdge2D(uv * 1.55 + vec2(1.3, 0.7));
    float e2 = voronoiEdge2D(uv * 3.10 + vec2(4.2, 2.1));
    float crack1 = 1.0 - smoothstep(0.0, 0.065, e1);
    float crack2 = 1.0 - smoothstep(0.0, 0.040, e2);
    // Stronger diagonal fractures on the middle shaft & capstone edge
    float shaftZone = smoothstep(0.18, 0.34, p.y) * smoothstep(1.03, 0.88, p.y);
    return clamp(crack1 * 0.85 + crack2 * 0.35, 0.0, 1.0) * (0.35 + 0.65 * shaftZone);
}

// Returns vec2(distance, materialID)
// matID: 1.0 = wet obsidian floor, 2.0 = sculpted stone altar, 3.0 = glowing cyan nexus disc
vec2 mapSolid(vec3 p) {
    // 1. Wet tiled obsidian floor (y = 0) with subtle mortar grooves
    vec2 tileUV = rot2D(0.52) * p.xz * 1.05;
    vec2 tileF = fract(tileUV) - 0.5;
    vec2 tileEdge = abs(tileF);
    float groove = smoothstep(0.465, 0.495, max(tileEdge.x, tileEdge.y));
    float tileH = -0.008 * groove;
    // Slight per-tile height micro-variation
    vec2 tileID = floor(tileUV);
    tileH += (hash12(tileID) - 0.5) * 0.004;
    float dFloor = p.y - tileH;

    // 2. Sculpted weathered hexagonal stone altar
    vec3 q = p;
    q.xz = rot2D(0.42) * q.xz;

    // Bounding optimization outside altar cylinder
    float dAltar = length(q - vec3(0.0, 0.52, 0.0)) - 1.15;
    float dNexus = 1e5;

    if (dAltar < 0.35) {
        // Tier 1: Wide hexagonal lower plinth
        float dBase1 = sdHexPrismY(q - vec3(0.0, 0.075, 0.0), 0.72, 0.065, 0.022);
        // Tier 2: Stepped hexagonal upper plinth
        float dBase2 = sdHexPrismY(q - vec3(0.0, 0.195, 0.0), 0.59, 0.055, 0.020);
        // Tier 3: Main hexagonal column shaft with slight taper
        float taper = mix(0.51, 0.47, clamp((q.y - 0.24) / 0.54, 0.0, 1.0));
        float dShaft = sdHexPrismY(q - vec3(0.0, 0.52, 0.0), taper, 0.28, 0.022);
        // Tier 4: Flared bevel collar beneath crown
        float dCollar = sdHexPrismY(q - vec3(0.0, 0.80, 0.0), 0.57, 0.045, 0.024);
        // Tier 5: Thick sculpted hexagonal capstone
        float dCrown = sdHexPrismY(q - vec3(0.0, 0.93, 0.0), 0.66, 0.075, 0.028);

        dAltar = smin(dBase1, dBase2, 0.025);
        dAltar = smin(dAltar, dShaft, 0.022);
        dAltar = smin(dAltar, dCollar, 0.030);
        dAltar = smin(dAltar, dCrown, 0.022);

        // Recessed circular nexus basin on top of capstone
        float rTop = length(q.xz);
        float dBasin = max(rTop - 0.43, -(q.y - 0.965));
        dAltar = smax(dAltar, -dBasin, 0.022);

        // Secondary shallow bevel ring around the nexus basin
        float dRim = max(abs(rTop - 0.46) - 0.035, -(q.y - 1.005));
        dAltar = smax(dAltar, -dRim, 0.012);

        // Sculpted stone weathering: chipped corners + fracture cracks + rock grain
        float crack = altarCrackField(q);
        float chip = (fbm3D(q * 4.5 + vec3(2.1, 0.0, 5.3)) - 0.5) * 0.024;
        float grain = (noise3D(q * 18.0) - 0.5) * 0.004;
        // Keep the top nexus lip cleanly readable
        float topProtect = smoothstep(0.42, 0.54, rTop) + smoothstep(0.95, 0.85, q.y);
        topProtect = clamp(topProtect, 0.0, 1.0);
        dAltar += (crack * 0.018 + chip * 0.75 + grain) * topProtect;

        // 3. Glowing cyan nexus disc seated inside the basin
        float dDisc = max(rTop - 0.415, abs(q.y - 0.968) - 0.016);
        dNexus = dDisc;
    }

    vec2 res = vec2(dFloor, 1.0);
    if (dAltar < res.x) res = vec2(dAltar, 2.0);
    if (dNexus < res.x) res = vec2(dNexus, 3.0);
    return res;
}

float mapDist(vec3 p) {
    return mapSolid(p).x;
}

// Unit-weight tetrahedral normal (exact QA rule: const vec2 k = vec2(1., -1.);)
vec3 calcNormal(vec3 p) {
    const float eps = 0.0018;
    const vec2 k = vec2(1.0, -1.0);
    return normalize(
        k.xyy * mapDist(p + k.xyy * eps) +
        k.yyx * mapDist(p + k.yyx * eps) +
        k.yxy * mapDist(p + k.yxy * eps) +
        k.xxx * mapDist(p + k.xxx * eps)
    );
}

float calcAO(vec3 pos, vec3 nor) {
    float occ = 0.0;
    float sca = 1.0;
    for (int i = 0; i < 5; i++) {
        float h = 0.02 + 0.11 * float(i) / 4.0;
        float d = mapDist(pos + h * nor);
        occ += (h - d) * sca;
        sca *= 0.82;
    }
    return clamp(1.0 - 2.6 * occ, 0.05, 1.0);
}

float calcSoftShadow(vec3 ro, vec3 rd, float mint, float maxt, float k) {
    float res = 1.0;
    float t = mint;
    for (int i = 0; i < 28; i++) {
        float h = mapDist(ro + rd * t);
        if (h < 0.001) return 0.0;
        res = min(res, k * h / t);
        t += clamp(h, 0.02, 0.25);
        if (t > maxt) break;
    }
    return clamp(res, 0.0, 1.0);
}

// ============================================================================
// PIXAR-STYLE 3D TRANSLUCENT COBALT-TO-CYAN SPIRAL WIND-RIBBONS
// ============================================================================
// Evaluates local ribbon volumetric emission & opacity at world point p.
// Returns vec4(emissiveRGB, density)
vec4 evalVortexRibbons(vec3 p, float phase, float openAmt) {
    vec3 col = vec3(0.0);
    float dens = 0.0;

    // ------------------------------------------------------------------------
    // RIBBON A: Grand Sweeping Ascending Magic Ribbon (matches upper-left arc)
    // ------------------------------------------------------------------------
    {
        // Slightly tilt the grand ribbon plane to match the dynamic Pixar sweep
        vec3 q = p - vec3(-0.08, 1.05, 0.0);
        q.xy = rot2D(0.24) * q.xy;
        q.yz = rot2D(-0.18) * q.yz;

        float r = length(q.xz);
        float ang = atan(q.z, q.x);

        // Spiral rises from y = -0.10 to y = 2.05 * openScale
        float openScale = mix(0.48, 1.0, openAmt);
        float pitch = 0.92 * openScale; // vertical rise per full turn

        // Evaluate 2 nearest spiral turns for seamless 3D ribbon continuity
        float baseTurn = floor((q.y / max(pitch, 0.05)) - (ang + phase) / TAU + 0.5);
        for (int k = 0; k < 2; k++) {
            float turn = baseTurn + float(k) - 0.5;
            float theta = ang + phase + turn * TAU;
            // Normalized progress s along ribbon: 0 at nexus, 1 at upper-left crest
            float s = (theta - phase + 0.4) / (1.85 * TAU);
            if (s > -0.05 && s < 1.08) {
                float sClamp = clamp(s, 0.0, 1.0);
                // Radius expands gracefully from nexus (0.34) to wide sweeping arc (1.62)
                float targetR = mix(0.34, 1.62 * openScale, smoothstep(0.0, 0.88, sClamp));
                // Subtle organic wind wave
                targetR += 0.09 * sin(sClamp * 9.4247 - phase * 2.0) * sClamp;
                float targetY = -0.06 + sClamp * 1.98 * openScale + 0.08 * cos(sClamp * 6.2831 - phase);

                // Local cross-section coordinates (dr, dy) twisted along ribbon
                vec2 dCross = vec2(r - targetR, q.y - targetY);
                float twist = 0.55 + sClamp * 0.95;
                dCross = rot2D(twist) * dCross;

                // Ribbon is wide in v (dCross.y) and thin in w (dCross.x)
                float ribbonWidth = mix(0.11, 0.34, sin(sClamp * PI)) * mix(0.65, 1.0, openAmt);
                float ribbonThick = mix(0.035, 0.065, sClamp);

                float vNorm = dCross.y / max(ribbonWidth, 0.02);
                float wNorm = dCross.x / max(ribbonThick, 0.01);

                float env = exp(-wNorm * wNorm * 1.65) * exp(-vNorm * vNorm * 1.35);
                // Smooth head and tail fade
                float ends = smoothstep(0.0, 0.12, sClamp) * smoothstep(1.0, 0.80, sClamp);
                env *= ends;

                if (env > 0.004) {
                    // Flowing silky streaks along the ribbon (looping seamlessly in 3s!)
                    float flowU = sClamp * 6.0 - phase / TAU * 2.0;
                    float streak1 = 0.5 + 0.5 * sin(vNorm * 7.5 + sin(flowU * TAU) * 1.2);
                    float streak2 = fbm2D(vec2(flowU * 3.2, vNorm * 2.8 + 1.7));
                    float silky = mix(0.45, 1.35, streak2 * 0.65 + streak1 * 0.35);

                    // Crisp electric-cyan energy vein tracing along the ribbon
                    float veinPos = 0.32 * sin(sClamp * 18.8495 - phase * 2.0) + 0.14 * cos(sClamp * 31.4159 + phase);
                    float vein = exp(-pow((vNorm - veinPos) * 7.5, 2.0)) * exp(-wNorm * wNorm * 2.5);

                    // Outer cobalt glow -> cyan silky body -> white-gold/cyan electric core
                    vec3 rCol = mix(COL_COBALT, COL_CYAN, smoothstep(-0.2, 0.85, silky * exp(-vNorm * vNorm * 0.5)));
                    rCol = mix(rCol, COL_WHITE_GOLD, vein * 0.85);

                    // Rim-bright edges for translucent ribbon feel
                    float edgeHighlight = exp(-pow((abs(vNorm) - 0.78) * 5.0, 2.0)) * 0.55;
                    rCol += COL_CYAN * edgeHighlight;

                    float intensity = env * (0.85 * silky + 1.85 * vein + edgeHighlight) * mix(0.45, 1.15, openAmt);
                    col += rCol * intensity;
                    dens += env * 0.55;
                }
            }
        }
    }

    // ------------------------------------------------------------------------
    // RIBBON B: Iconic Central Coiled Spiral Eye (above the nexus disc)
    // ------------------------------------------------------------------------
    {
        // Positioned at y = 1.68, tilted toward the camera so the spiral eye reads clearly
        vec3 q = p - vec3(-0.02, 1.66 * mix(0.82, 1.0, openAmt), 0.06);
        q.yz = rot2D(0.92) * q.yz;
        q.xz = rot2D(0.18) * q.xz;

        float r = length(q.xz);
        float ang = atan(q.z, q.x);
        float zDist = abs(q.y);

        if (r < 1.15 && zDist < 0.45) {
            // Double-arm logarithmic spiral coiling into the center
            float spiralLog = log(max(r, 0.035)) * 3.1;
            float armPhase = ang * 2.0 - spiralLog - phase * 2.0;
            float armWave = 0.5 + 0.5 * cos(armPhase);
            float armSharp = pow(armWave, 2.4);
            float armCore  = pow(armWave, 8.0);

            float radialEnv = smoothstep(0.02, 0.14, r) * smoothstep(0.92 * mix(0.6, 1.0, openAmt), 0.22, r);
            float thickness = mix(0.055, 0.13, r);
            float planeEnv = exp(-pow(zDist / thickness, 2.0));

            // Funnel stem connecting the spiral eye down into the glowing nexus disc
            float swirlDens = radialEnv * planeEnv * (0.28 + 0.95 * armSharp);
            vec3 sCol = mix(COL_COBALT, COL_CYAN, armSharp);
            sCol = mix(sCol, COL_WHITE_GOLD, armCore * 0.72);

            col += sCol * swirlDens * mix(0.55, 1.45, openAmt);
            dens += swirlDens * 0.45;
        }
    }

    // ------------------------------------------------------------------------
    // RIBBON C: Rising Plume Funnel (connecting nexus disc to spiral eye)
    // ------------------------------------------------------------------------
    {
        vec3 q = p - vec3(0.0, 0.98, 0.0);
        if (q.y > -0.02 && q.y < 0.95) {
            float hNorm = clamp(q.y / 0.85, 0.0, 1.0);
            float r = length(q.xz);
            float ang = atan(q.z, q.x);
            float targetR = mix(0.26, 0.46, smoothstep(0.0, 1.0, hNorm)) + 0.05 * sin(hNorm * 6.2831 - phase);
            float shell = exp(-pow((r - targetR) / 0.11, 2.0));
            float coreFill = exp(-pow(r / 0.28, 2.0)) * (1.0 - hNorm * 0.65);
            float twist = 0.5 + 0.5 * sin(ang * 3.0 - hNorm * 7.5 - phase * 2.0);
            float plume = (shell * (0.45 + 0.75 * twist) + coreFill * 0.55) * smoothstep(0.0, 0.08, hNorm) * smoothstep(1.0, 0.65, hNorm);
            vec3 pCol = mix(COL_CYAN, COL_WHITE_GOLD, clamp(coreFill * 0.85 + pow(twist, 4.0) * 0.4, 0.0, 1.0));
            col += pCol * plume * mix(0.60, 1.25, openAmt);
            dens += plume * 0.35;
        }
    }

    // ------------------------------------------------------------------------
    // RIBBON D: Low Ground-Hugging Orbital Ribbon (sweeping around pedestal)
    // ------------------------------------------------------------------------
    {
        vec3 q = p - vec3(0.12, 0.48, -0.05);
        q.xy = rot2D(-0.22) * q.xy;
        q.yz = rot2D(0.14) * q.yz;

        float r = length(q.xz);
        float ang = atan(q.z, q.x);
        float targetR = 1.28 * mix(0.85, 1.0, openAmt) + 0.18 * sin(ang - phase);
        float targetY = 0.12 * sin(ang - phase + 0.6);

        vec2 dCross = rot2D(0.35) * vec2(r - targetR, q.y - targetY);
        float wNorm = dCross.x / 0.055;
        float vNorm = dCross.y / 0.17;
        float env = exp(-wNorm * wNorm * 1.8) * exp(-vNorm * vNorm * 1.4);

        // Fade slightly on the very front-left so the pedestal base stays super clear
        float arcMask = 0.55 + 0.45 * sin(ang - 0.8);
        env *= arcMask;

        if (env > 0.004) {
            float flow = 0.5 + 0.5 * sin(ang * 4.0 - phase * 2.0 + vNorm * 3.0);
            float thinLine = exp(-pow((vNorm - 0.35) * 6.0, 2.0));
            vec3 lCol = mix(COL_COBALT, COL_CYAN, 0.35 + 0.65 * flow);
            lCol = mix(lCol, COL_WHITE_GOLD, thinLine * 0.55);
            col += lCol * env * (0.65 + 0.85 * thinLine) * mix(0.40, 0.95, openAmt);
            dens += env * 0.35;
        }
    }

    return vec4(col, dens);
}

// ============================================================================
// LEVITATING GLOWING AMBER-GOLD GLYPH TABLETS / CARDS (EXACT 3D RAY-QUAD)
// ============================================================================
float sdSegment2D(vec2 p, vec2 a, vec2 b) {
    vec2 pa = p - a;
    vec2 ba = b - a;
    float h = clamp(dot(pa, ba) / max(dot(ba, ba), 1e-5), 0.0, 1.0);
    return length(pa - ba * h);
}

// Draws crisp glowing golden arcane rune sigil inside local card UV q in [-1, 1]^2
float evalGlyphPattern(vec2 q, int variant) {
    // Outer card border (tall diamond-tablet / tarot proportion)
    vec2 b = abs(q) - vec2(0.76, 0.90);
    float boxD = length(max(b, 0.0)) + min(max(b.x, b.y), 0.0);
    float border = smoothstep(0.11, 0.025, abs(boxD));
    // Subtle inner fill
    float fill = smoothstep(0.02, -0.05, boxD) * 0.14;

    // Inner rune sigil
    float dRune = 1e5;
    if (variant == 0) {
        // Hourglass / Gemini arcane sigil
        dRune = min(dRune, sdSegment2D(q, vec2(-0.42, 0.52), vec2(0.42, 0.52)));
        dRune = min(dRune, sdSegment2D(q, vec2(-0.42, -0.52), vec2(0.42, -0.52)));
        dRune = min(dRune, sdSegment2D(q, vec2(-0.34, 0.50), vec2(0.34, -0.50)));
        dRune = min(dRune, sdSegment2D(q, vec2(0.34, 0.50), vec2(-0.34, -0.50)));
        dRune = min(dRune, abs(length(q) - 0.22));
    } else if (variant == 1) {
        // Compass diamond star sigil
        float diam = abs(q.x) * 1.15 + abs(q.y) * 0.85 - 0.52;
        dRune = min(dRune, abs(diam));
        dRune = min(dRune, sdSegment2D(q, vec2(0.0, -0.62), vec2(0.0, 0.62)));
        dRune = min(dRune, sdSegment2D(q, vec2(-0.46, 0.0), vec2(0.46, 0.0)));
    } else if (variant == 2) {
        // Circled arcane eye / sun sigil
        dRune = min(dRune, abs(length(q) - 0.42));
        dRune = min(dRune, abs(length(q) - 0.15));
        dRune = min(dRune, sdSegment2D(q, vec2(-0.45, -0.45), vec2(0.45, 0.45)));
        dRune = min(dRune, sdSegment2D(q, vec2(-0.45, 0.45), vec2(0.45, -0.45)));
    } else {
        // Twin-arc hourglass rune (no outer box, floating rune sigil!)
        border *= 0.25;
        fill *= 0.2;
        dRune = min(dRune, sdSegment2D(q, vec2(-0.48, 0.60), vec2(0.48, 0.60)));
        dRune = min(dRune, sdSegment2D(q, vec2(-0.48, -0.60), vec2(0.48, -0.60)));
        float arcL = abs(length(q - vec2(-0.62, 0.0)) - 0.44);
        float arcR = abs(length(q - vec2(0.62, 0.0)) - 0.44);
        if (abs(q.y) < 0.60) {
            dRune = min(dRune, min(arcL, arcR));
        }
    }

    float runeGlow = smoothstep(0.11, 0.02, dRune);
    return clamp(border * 0.95 + runeGlow * 1.15 + fill, 0.0, 1.5);
}

vec3 evalGlyphTablets(vec3 ro, vec3 rd, float maxT, float phase, float openAmt) {
    vec3 accum = vec3(0.0);
    const int NUM_CARDS = 16;

    for (int i = 0; i < NUM_CARDS; i++) {
        float fi = float(i);
        float h1 = hash11(fi * 13.7 + 1.3);
        float h2 = hash11(fi * 29.1 + 4.7);

        // Three orbital tiers: upper grand arc (0..7), mid swirl (8..11), low floor ring (12..15)
        vec3 center;
        float cardSize;
        if (i < 8) {
            float a = (fi / 8.0) * TAU + phase * 1.0 + 0.3;
            float r = mix(1.25, 1.85, h1) * mix(0.65, 1.0, openAmt);
            float y = mix(1.55, 2.95, h2) * mix(0.75, 1.0, openAmt) + 0.12 * sin(phase + fi * 1.7);
            center = vec3(cos(a) * r - 0.08, y, sin(a) * r);
            cardSize = mix(0.11, 0.16, h1);
        } else if (i < 12) {
            float a = ((fi - 8.0) / 4.0) * TAU - phase * 1.0 + 0.8;
            float r = mix(0.62, 1.10, h1) * mix(0.70, 1.0, openAmt);
            float y = mix(1.05, 1.85, h2) + 0.08 * cos(phase + fi * 2.1);
            center = vec3(cos(a) * r, y, sin(a) * r);
            cardSize = mix(0.085, 0.12, h2);
        } else {
            float a = ((fi - 12.0) / 4.0) * TAU + phase * 1.0 + 1.4;
            float r = mix(1.25, 1.78, h1);
            float y = mix(0.22, 0.62, h2) + 0.06 * sin(phase + fi * 2.3);
            center = vec3(cos(a) * r, y, sin(a) * r);
            cardSize = mix(0.12, 0.165, h1);
        }

        // Oriented card basis: tangent + tilted slightly toward camera
        vec3 toCenter = normalize(vec3(center.x, 0.0, center.z) + vec3(0.001));
        vec3 normal = normalize(mix(toCenter, normalize(ro - center), 0.55));
        vec3 up = normalize(vec3(sin(fi * 2.3 + phase) * 0.35, 1.0, cos(fi * 1.7) * 0.35));
        vec3 right = normalize(cross(up, normal));
        up = cross(normal, right);

        // Analytical ray-plane intersection
        float denom = dot(rd, normal);
        if (abs(denom) > 0.02) {
            float t = dot(center - ro, normal) / denom;
            if (t > 0.15 && t < maxT) {
                vec3 hit = ro + rd * t;
                vec3 rel = hit - center;
                vec2 uv = vec2(dot(rel, right), dot(rel, up)) / cardSize;

                // Soft bloom halo around card
                float radialDist = length(uv);
                if (radialDist < 2.2) {
                    float halo = exp(-radialDist * radialDist * 1.8) * 0.22;
                    float glyph = 0.0;
                    if (abs(uv.x) < 1.05 && abs(uv.y) < 1.15) {
                        glyph = evalGlyphPattern(uv, i & 3);
                    }
                    float pulse = 0.85 + 0.15 * sin(phase * 2.0 + fi * 1.9);
                    vec3 gCol = mix(COL_GOLD, COL_WHITE_GOLD, clamp(glyph * 0.65, 0.0, 1.0));
                    accum += gCol * (glyph * 1.65 + halo) * pulse * mix(0.45, 1.0, openAmt);
                }
            }
        }
    }
    return accum;
}

// ============================================================================
// SPARKLING GOLDEN STARDUST MOTES (ANALYTICAL RAY-POINT PROXIMITY)
// ============================================================================
vec3 evalStardust(vec3 ro, vec3 rd, float maxT, float phase, float openAmt) {
    vec3 accum = vec3(0.0);
    const int NUM_MOTES = 36;

    for (int i = 0; i < NUM_MOTES; i++) {
        float fi = float(i);
        float h1 = hash11(fi * 19.3 + 0.7);
        float h2 = hash11(fi * 37.9 + 2.1);
        float h3 = hash11(fi * 53.1 + 5.9);

        vec3 mp;
        float size;
        if (i < 18) {
            // Dense shimmering golden stardust pooling around the pedestal base
            float a = (fi / 18.0) * TAU + phase * 1.0 + h1 * 0.6;
            float r = mix(0.76, 1.38, h2);
            float y = mix(0.04, 0.52, h3 * h3) + 0.04 * sin(phase * 2.0 + fi * 3.1);
            mp = vec3(cos(a) * r, y, sin(a) * r);
            size = mix(0.012, 0.024, h1);
        } else {
            // Golden stardust trailing along the upper sweeping ribbons
            float a = ((fi - 18.0) / 18.0) * TAU + phase * 1.0 + h2 * 0.9;
            float r = mix(0.85, 1.82, h1) * mix(0.65, 1.0, openAmt);
            float y = mix(1.20, 2.95, h3) * mix(0.75, 1.0, openAmt) + 0.08 * cos(phase + fi * 2.7);
            mp = vec3(cos(a) * r - 0.06, y, sin(a) * r);
            size = mix(0.011, 0.022, h2);
        }

        // Closest point on ray to mote position
        vec3 toM = mp - ro;
        float t = dot(toM, rd);
        if (t > 0.1 && t < maxT) {
            vec3 closest = ro + rd * t;
            float d = length(closest - mp);
            float core = exp(-pow(d / size, 2.0));
            float glow = exp(-pow(d / (size * 4.2), 2.0)) * 0.28;
            float twinkle = 0.65 + 0.35 * sin(phase * 3.0 + fi * 4.7);
            vec3 mCol = mix(COL_GOLD, COL_WHITE_GOLD, core);
            accum += mCol * (core * 2.2 + glow) * twinkle * mix(0.55, 1.0, openAmt);
        }
    }
    return accum;
}

// ============================================================================
// MATERIAL SHADING & LIGHTING
// ============================================================================
vec3 shadeSolid(vec3 p, vec3 n, vec3 v, float matID, float phase, float openAmt, float emissiveScale) {
    // Key, fill, and rim directions depending on uLightMode
    vec3 keyDir  = normalize(vec3(-0.55, 0.78, 0.42));
    vec3 keyCol  = vec3(0.62, 0.70, 0.88) * 1.15;
    vec3 fillCol = vec3(0.14, 0.20, 0.34);

    if (uLightMode == 1) {
        // Pure neutral studio grayscale clay mode
        keyDir  = normalize(vec3(0.55, 0.82, 0.52));
        keyCol  = vec3(1.15);
        fillCol = vec3(0.28);
    } else if (uLightMode == 2) {
        // Dramatic grazing raking light
        keyDir  = normalize(vec3(0.92, 0.22, 0.32));
        keyCol  = vec3(1.15, 0.92, 0.72) * 1.55;
        fillCol = vec3(0.08, 0.12, 0.22);
    } else if (uLightMode == 3) {
        // Strong backlit rim silhouette
        keyDir  = normalize(vec3(-0.18, 0.42, -0.88));
        keyCol  = vec3(0.55, 0.85, 1.15) * 1.85;
        fillCol = vec3(0.08, 0.12, 0.20);
    }

    float ao = calcAO(p, n);
    float shadow = calcSoftShadow(p + n * 0.012, keyDir, 0.03, 5.0, 10.0);
    float ndl = max(dot(n, keyDir), 0.0);
    vec3 hVec = normalize(keyDir + v);
    float ndh = max(dot(n, hVec), 0.0);
    float ndv = max(dot(n, v), 0.001);

    // Local arcane emissive point lights:
    // 1. Cyan nexus light at top of altar (0, 1.12, 0)
    vec3 nexusPos = vec3(0.0, 1.12, 0.0);
    vec3 toNexus = nexusPos - p;
    float dNexus = length(toNexus);
    vec3 lNexus = toNexus / max(dNexus, 0.001);
    float attNexus = 1.0 / (1.0 + 0.55 * dNexus * dNexus);
    float ndlNexus = max(dot(n, lNexus), 0.0);

    // 2. Upper cyan vortex ribbon glow light (-0.1, 2.05, 0.0)
    vec3 vortexPos = vec3(-0.10, 2.05, 0.0);
    vec3 toVortex = vortexPos - p;
    float dVortex = length(toVortex);
    vec3 lVortex = toVortex / max(dVortex, 0.001);
    float attVortex = 1.0 / (1.0 + 0.28 * dVortex * dVortex);
    float ndlVortex = max(dot(n, lVortex), 0.0);

    // 3. Warm golden stardust ring light around the pedestal base
    float rXZ = length(p.xz);
    float goldRingDist = length(vec2(rXZ - 0.92, p.y - 0.12));
    float attGold = 1.0 / (1.0 + 2.8 * goldRingDist * goldRingDist);

    vec3 col = vec3(0.0);

    if (matID < 1.5) {
        // --------------------------------------------------------------------
        // MATERIAL 1: WET OBSIDIAN TILED ARENA FLOOR
        // --------------------------------------------------------------------
        vec2 tileUV = rot2D(0.52) * p.xz * 1.05;
        vec2 tileID = floor(tileUV);
        vec2 tileF  = fract(tileUV) - 0.5;
        float groove = smoothstep(0.455, 0.495, max(abs(tileF.x), abs(tileF.y)));

        // Wet puddle mask & micro-roughness variation
        float puddle = fbm2D(p.xz * 1.45 + vec2(3.1, 7.4));
        float tileVar = hash12(tileID);
        float roughness = mix(0.08, 0.34, smoothstep(0.32, 0.72, puddle) * (1.0 - groove * 0.5));
        roughness = mix(roughness, 0.72, groove);

        // Micro-bump normal perturbation on wet tiles
        float microN = fbm2D(p.xz * 12.0);
        n = normalize(n + vec3(microN - 0.5, 0.0, fbm2D(p.xz * 12.0 + 9.2) - 0.5) * mix(0.025, 0.09, roughness));

        vec3 albedo = COL_OBSIDIAN * (0.75 + 0.45 * tileVar) * (1.0 - 0.65 * groove);
        if (uLightMode == 1) {
            albedo = vec3(0.24) * (0.85 + 0.25 * tileVar) * (1.0 - 0.5 * groove);
        }

        // Diffuse + Specular
        float specPow = mix(96.0, 12.0, roughness);
        float fresnel = 0.04 + 0.96 * pow(1.0 - ndv, 4.0);
        float specKey = pow(ndh, specPow) * mix(1.4, 0.2, roughness);

        col = albedo * (fillCol * ao + keyCol * ndl * shadow);
        col += keyCol * specKey * shadow * (0.4 + 0.8 * fresnel);

        // Emissive reflections & pools on the wet obsidian floor
        if (emissiveScale > 0.01) {
            // Cyan/cobalt vortex reflection on wet floor
            vec3 reflDir = reflect(-v, n);
            vec3 rSample1 = p + reflDir * clamp((1.55 - p.y) / max(reflDir.y, 0.15), 0.1, 4.0);
            vec3 rSample2 = p + reflDir * clamp((2.25 - p.y) / max(reflDir.y, 0.15), 0.1, 5.5);
            vec4 vRefl = evalVortexRibbons(rSample1, phase, openAmt) * 0.55
                       + evalVortexRibbons(rSample2, phase, openAmt) * 0.45;

            float gloss = 1.0 - roughness;
            col += vRefl.rgb * gloss * (0.28 + 0.75 * fresnel) * emissiveScale * (1.0 - 0.6 * groove);

            // Subtle slate-blue ambient sky reflection on wet tiles (matches top-right sheen in ref)
            vec3 skyRefl = mix(COL_OBSIDIAN * 1.4, vec3(0.14, 0.24, 0.42), smoothstep(0.0, 0.7, reflDir.y));
            col += skyRefl * gloss * fresnel * 0.45 * ao;

            // Direct cyan vortex + nexus bounce lighting on floor
            col += albedo * COL_CYAN * ndlVortex * attVortex * 1.15 * emissiveScale * mix(0.45, 1.0, openAmt);

            // Warm golden stardust glow pool around pedestal base on wet tiles
            float goldPool = exp(-pow((rXZ - 0.92) / 0.48, 2.0)) * (0.65 + 0.35 * sin(atan(p.z, p.x) * 3.0 + phase));
            col += (albedo * 2.0 + vec3(0.08)) * COL_GOLD * goldPool * (0.45 + 0.85 * gloss) * emissiveScale * mix(0.5, 1.0, openAmt);
        }

        // Distance atmospheric depth fade (keep floor above pure black)
        float distFade = smoothstep(3.5, 16.0, length(p.xz));
        vec3 horizonCol = (uLightMode == 1) ? vec3(0.12) : COL_OBSIDIAN * 0.95;
        col = mix(col, horizonCol, distFade * 0.78);
    } else if (matID < 2.5) {
        // --------------------------------------------------------------------
        // MATERIAL 2: SCULPTED WEATHERED HEXAGONAL STONE ALTAR
        // --------------------------------------------------------------------
        vec3 q = p;
        q.xz = rot2D(0.42) * q.xz;
        float crack = altarCrackField(q);
        float grain = fbm3D(q * 11.0);
        float fineGrain = noise3D(q * 34.0);

        // Weathered warm-cool limestone albedo
        vec3 stoneBase = mix(vec3(0.46, 0.44, 0.41), vec3(0.64, 0.61, 0.56), grain);
        stoneBase *= 0.88 + 0.22 * fineGrain;
        // Darken crevices & fractures
        stoneBase *= mix(1.0, 0.32, smoothstep(0.15, 0.75, crack));

        // Subtle olive-moss patina tucked at the plinth-to-shaft seam (matches 07.png!)
        float mossZone = exp(-pow((p.y - 0.24) / 0.085, 2.0)) * smoothstep(0.32, 0.72, fbm3D(q * 6.5 + 3.1));
        vec3 mossCol = vec3(0.24, 0.31, 0.14);
        vec3 albedo = mix(stoneBase, mossCol, mossZone * 0.78);

        if (uLightMode == 1) {
            float l = dot(albedo, vec3(0.299, 0.587, 0.114));
            albedo = vec3(l);
        }

        float spec = pow(ndh, 24.0) * 0.18 * (1.0 - crack * 0.7);
        col = albedo * (fillCol * ao + keyCol * ndl * shadow) + keyCol * spec * shadow;

        // Rim light accent on chiseled edges
        float rim = pow(1.0 - ndv, 3.0) * ao;
        col += ((uLightMode == 1) ? vec3(0.20) : vec3(0.16, 0.36, 0.58)) * rim * (uLightMode == 3 ? 1.6 : 0.45);

        // Emissive arcane bounce lighting on the sculpted stone
        if (emissiveScale > 0.01) {
            // Bright cyan inner glow on the top nexus basin rim & upper capstone
            float topMask = smoothstep(0.72, 1.01, p.y);
            float basinProximity = smoothstep(0.66, 0.40, length(p.xz)) * smoothstep(0.86, 1.0, p.y);
            col += albedo * COL_CYAN * (ndlNexus * attNexus * 2.2 + basinProximity * 2.6) * emissiveScale;
            col += albedo * mix(COL_COBALT, COL_CYAN, 0.5) * ndlVortex * attVortex * 1.1 * (0.4 + 0.6 * topMask) * emissiveScale * mix(0.5, 1.0, openAmt);

            // Warm golden stardust up-lighting on lower plinth & shaft facets
            float lowMask = smoothstep(0.75, 0.05, p.y);
            col += albedo * COL_GOLD * attGold * lowMask * 1.15 * emissiveScale * mix(0.5, 1.0, openAmt);
        }
    } else {
        // --------------------------------------------------------------------
        // MATERIAL 3: GLOWING CYAN NEXUS DISC (CROWN OF ALTAR)
        // --------------------------------------------------------------------
        float r = length(p.xz);
        float rNorm = clamp(r / 0.415, 0.0, 1.0);
        float ang = atan(p.z, p.x);

        // Concentric pulsing cyan energy rings + spiral ripple
        float ripple = 0.5 + 0.5 * sin(rNorm * 18.8495 - phase * 2.0);
        float swirl = 0.5 + 0.5 * sin(ang * 2.0 + rNorm * 8.0 - phase * 2.0);
        float coreGlow = exp(-rNorm * rNorm * 2.8);

        vec3 nexusCol = mix(COL_COBALT, COL_CYAN, smoothstep(1.0, 0.15, rNorm));
        nexusCol = mix(nexusCol, COL_WHITE_GOLD, clamp(coreGlow * 0.95 + ripple * 0.25 * (1.0 - rNorm), 0.0, 1.0));
        float intensity = (1.35 + 1.85 * coreGlow + 0.45 * ripple * swirl) * mix(0.65, 1.25, openAmt);

        if (uLightMode == 1) {
            col = vec3(0.45 + 0.20 * coreGlow) * (0.5 + 0.5 * ndl) * ao;
        } else {
            col = nexusCol * intensity * emissiveScale + vec3(0.08, 0.14, 0.20) * (1.0 - emissiveScale);
        }
    }

    return col;
}

// ============================================================================
// ACES FILMIC TONE MAPPING
// ============================================================================
vec3 acesToneMap(vec3 x) {
    x = max(x, vec3(0.0));
    const float a = 2.51;
    const float b = 0.03;
    const float c = 2.43;
    const float d = 0.59;
    const float e = 0.14;
    return clamp((x * (a * x + b)) / (x * (c * x + d) + e), 0.0, 1.0);
}

// ============================================================================
// MAIN RENDER ENTRY
// ============================================================================
void main() {
    vec2 res = max(uResolution, vec2(1.0));
    vec2 uv = (gl_FragCoord.xy - 0.5 * res) / min(res.x, res.y);

    // Seamless 3.0s loop phase
    float phase = TAU * fract(uTime / 3.0);
    float openAmt = clamp(uOpen, 0.0, 1.0);
    float emissiveScale = (uLightMode == 1) ? 0.0 : 1.0;

    // Camera setup: 0 = Hero Pixar 3/4 wide, 1 = ~2.5x Macro on sculpted altar & nexus
    vec3 ro, ta;
    float focal;
    if (uCamMode == 1) {
        ro = vec3(0.42, 1.68, 1.88);
        ta = vec3(0.0, 0.86, 0.0);
        focal = 2.05;
    } else {
        ro = vec3(0.22, 2.55, 4.45);
        ta = vec3(-0.02, 1.32, 0.0);
        focal = 1.62;
    }

    vec3 cw = normalize(ta - ro);
    vec3 cu = normalize(cross(cw, vec3(0.0, 1.0, 0.0)));
    vec3 cv = cross(cu, cw);
    vec3 rd = normalize(uv.x * cu + uv.y * cv + focal * cw);

    // Background deep obsidian studio/arena gradient
    vec3 bgCol = mix(COL_OBSIDIAN * 0.72, COL_OBSIDIAN * 1.45, smoothstep(-0.2, 0.55, rd.y));
    if (uLightMode == 1) {
        bgCol = vec3(0.11 + 0.06 * smoothstep(-0.2, 0.6, rd.y));
    }

    // ------------------------------------------------------------------------
    // 1. RAYMARCH SOLID GEOMETRY (HEXAGONAL ALTAR + WET OBSIDIAN FLOOR)
    // ------------------------------------------------------------------------
    float tSolid = 0.0;
    float matID = 0.0;
    bool hitSolid = false;
    const float MAX_DIST = 26.0;

    for (int i = 0; i < 84; i++) {
        vec3 p = ro + rd * tSolid;
        vec2 resMap = mapSolid(p);
        if (resMap.x < 0.0012) {
            matID = resMap.y;
            hitSolid = true;
            break;
        }
        tSolid += resMap.x * 0.92;
        if (tSolid > MAX_DIST) break;
    }

    vec3 col = bgCol;
    if (hitSolid) {
        vec3 p = ro + rd * tSolid;
        vec3 n = calcNormal(p);
        col = shadeSolid(p, n, -rd, matID, phase, openAmt, emissiveScale);
    } else {
        tSolid = MAX_DIST;
    }

    // ------------------------------------------------------------------------
    // 2. VOLUMETRIC RAYMARCH: TRANSLUCENT COBALT-TO-CYAN SPIRAL WIND-RIBBONS
    // ------------------------------------------------------------------------
    // Intersect ray with bounding sphere around vortex (center (0, 1.55, 0), radius 2.55)
    vec3 vCenter = vec3(0.0, 1.55, 0.0);
    float vRadius = 2.55;
    vec3 oc = ro - vCenter;
    float b = dot(oc, rd);
    float c = dot(oc, oc) - vRadius * vRadius;
    float disc = b * b - c;

    if (disc > 0.0) {
        float sqrtD = sqrt(max(disc, 0.0));
        float tNear = max(0.1, -b - sqrtD);
        float tFar  = min(tSolid, -b + sqrtD);

        if (tFar > tNear) {
            const int VOL_STEPS = 44;
            float dt = (tFar - tNear) / float(VOL_STEPS);
            // Blue-noise-like per-pixel jitter to eliminate slice banding
            float jitter = hash12(gl_FragCoord.xy + vec2(fract(uTime * 13.7) * 100.0));
            float t = tNear + dt * jitter;

            vec3 volAccum = vec3(0.0);
            float transmittance = 1.0;

            for (int i = 0; i < VOL_STEPS; i++) {
                vec3 vp = ro + rd * t;
                vec4 vr = evalVortexRibbons(vp, phase, openAmt);
                if (vr.w > 0.002) {
                    if (uLightMode == 1) {
                        // Muted subtle translucent mist silhouette in grayscale mode
                        float gLum = dot(vr.rgb, vec3(0.299, 0.587, 0.114)) * 0.14;
                        volAccum += vec3(gLum) * dt * transmittance;
                        transmittance *= exp(-vr.w * dt * 0.25);
                    } else {
                        volAccum += vr.rgb * dt * 1.45 * transmittance;
                        // Gentle translucent absorption so overlapping ribbons have depth
                        transmittance *= exp(-vr.w * dt * 0.55);
                    }
                    if (transmittance < 0.04) break;
                }
                t += dt;
            }

            col = col * mix(1.0, transmittance, 0.65) + volAccum;
        }
    }

    // ------------------------------------------------------------------------
    // 3. LEVITATING GLOWING AMBER-GOLD GLYPH TABLETS & SPARKLING STARDUST
    // ------------------------------------------------------------------------
    if (emissiveScale > 0.01) {
        vec3 glyphs = evalGlyphTablets(ro, rd, tSolid, phase, openAmt);
        vec3 dust   = evalStardust(ro, rd, tSolid, phase, openAmt);
        col += glyphs + dust;

        // Soft atmospheric cyan halo blooming from the nexus core
        vec3 toCore = vec3(0.0, 1.08, 0.0) - ro;
        float tCore = dot(toCore, rd);
        if (tCore > 0.0 && tCore < tSolid + 0.6) {
            float dCore = length(ro + rd * tCore - vec3(0.0, 1.08, 0.0));
            float halo = exp(-dCore * dCore * 3.8) * 0.32 * mix(0.5, 1.0, openAmt);
            col += mix(COL_CYAN, COL_WHITE_GOLD, exp(-dCore * dCore * 10.0)) * halo;
        }
    }

    // ------------------------------------------------------------------------
    // 4. POST-PROCESSING: ACES TONE MAP + GAMMA + SUBTLE VIGNETTE
    // ------------------------------------------------------------------------
    if (uLightMode == 1) {
        // Guarantee pure neutral grayscale output in mode 1
        float lum = dot(col, vec3(0.299, 0.587, 0.114));
        col = vec3(lum);
    }

    // Subtle filmic vignette preserving brightness (>2% black guard)
    float vig = 1.0 - 0.22 * dot(uv, uv);
    col *= clamp(vig, 0.68, 1.0);

    // Exposure & ACES filmic curve
    col = acesToneMap(col * 0.92);

    // Gamma correction (sRGB approx)
    col = pow(max(col, vec3(0.0)), vec3(1.0 / 2.2));

    // Lift deep floor slightly to ensure <2% pure black while keeping wet obsidian richness
    col = max(col, vec3(0.012, 0.016, 0.028) * (uLightMode == 1 ? 0.0 : 1.0) + vec3(0.015) * (uLightMode == 1 ? 1.0 : 0.0));

    fragColor = vec4(col, 1.0);
}

Mathematical models & shader specifications

Identifierarcane-buff-aura-vortex
CategoryGame VFX Shaders · Arcane Palette
Upstream studyvfx_palette/lib/07_arcane_buff_aura_vortex.glsl (commit 913ad1c)
Animation cycle3.0 s seamless harmonic loop
Declared uniformsuResolution, uTime, uOpen, uLightMode, uCamMode
Source size995 lines · 40.7 KB standalone GLSL ES 3.00
PNG baker outputs512px · 1024px · 2048px RGBA8 (4-tap seamless + alpha key)
Companion pixel VFXFree MIT status sprite sheets
LicenseMIT License + CC0 / MIT Helpers

Physical & shading models implemented

Voronoi/Worley cellular fields (Voronoi 1908; Worley 1996); GGX microfacet specular (Trowbridge–Reitz 1975; Walter et al. 2007); Schlick Fresnel reflectance (1994); Beer–Lambert volumetric absorption/attenuation

Adapted upstream mathematical helpers

David Hoskins, hash · Krzysztof Narkowicz, filmic curve · Inigo Quilez, quadratic distance blend · Inigo Quilez, tetrahedral SDF normal

All game vfx shaders