Solar Gold Holy Smite Pillar shader

solar-gold-holy-smite-pillar.glsl · 704 lines · GLSL ES 3.00 · MIT

Solar Gold Holy Smite PillarGame VFX
Solar Gold Holy Smite Pillar WebGL2 procedural shader preview
FPS 60BUFFER 960×540SOURCE 704 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

Stylized Cel VFX
solar-gold-holy-smite-pillar.glsl (704 lines)
#version 300 es
// Solar Gold Holy Smite Pillar (solar-gold-holy-smite-pillar.glsl)
// Upstream study: https://github.com/gokayfem/glsl-studies/blob/main/vfx_stylized/lib/03_solar_gold_holy_smite_pillar.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;

// ============================================================================
// CONSTANTS & STYLIZED SOLAR-GOLD PALETTE
// ============================================================================
const float PI  = 3.14159265359;
const float TAU = 6.28318530718;

// Dark matte ink-grouted charcoal floor base (linearized to match sRGB ~0.08,0.09,0.12)
const vec3 COL_FLOOR_BASE   = vec3(0.08, 0.09, 0.12);
const vec3 COL_INK          = vec3(0.0045, 0.0042, 0.0060); // deep Spider-Verse ink (non-zero, 0% pure black)
const vec3 COL_CRIMSON_TRIM = vec3(0.24, 0.035, 0.045);

// 3-band cel-shaded solar gold & cream-white palette (linear space)
const vec3 COL_CREAM_WHITE  = vec3(1.00, 0.97, 0.86);
const vec3 COL_GOLD_HI      = vec3(1.00, 0.86, 0.34);
const vec3 COL_GOLD_MID     = vec3(0.95, 0.56, 0.08);
const vec3 COL_GOLD_SHAD    = vec3(0.46, 0.19, 0.03);
const vec3 COL_OCHRE_SPILL  = vec3(0.96, 0.54, 0.10);
const vec3 COL_LEMON_GLOW   = vec3(1.00, 0.92, 0.42);

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

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 vnoise2(vec2 p) {
    vec2 i = floor(p);
    vec2 f = fract(p);
    vec2 u = f * f * (3.0 - 2.0 * f);
    return mix(
        mix(hash12(i + vec2(0.0, 0.0)), hash12(i + vec2(1.0, 0.0)), u.x),
        mix(hash12(i + vec2(0.0, 1.0)), hash12(i + vec2(1.0, 1.0)), u.x),
        u.y
    );
}

float fbm2(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 * vnoise2(p);
        p = m * p * 2.04 + vec2(11.3, 7.1);
        a *= 0.5;
    }
    return v;
}

// ============================================================================
// OCTAGONAL & PRIMITIVE SDFs
// ============================================================================
// Exact 2D regular octagon SDF with apothem r
float sdOctagon(vec2 p, float r) {
    const vec3 k = vec3(-0.9238795325, 0.3826834323, 0.4142135623);
    p = abs(p);
    p -= 2.0 * min(dot(vec2( k.x, k.y), p), 0.0) * vec2( k.x, k.y);
    p -= 2.0 * min(dot(vec2(-k.x, k.y), p), 0.0) * vec2(-k.x, k.y);
    p -= vec2(clamp(p.x, -k.z * r, k.z * r), r);
    return length(p) * sign(p.y);
}

// Extruded hollow octagonal ring with crisp chamfer bevel
float sdOctRing(vec3 p, float r, float halfW, float halfH, float bevel) {
    float d2 = abs(sdOctagon(p.xz, r)) - halfW;
    vec2 w = vec2(d2, abs(p.y) - halfH);
    return min(max(w.x, w.y), 0.0) + length(max(w, 0.0)) - bevel;
}

// Extruded solid octagonal slab
float sdOctPrism(vec3 p, float r, float halfH, float bevel) {
    float d2 = sdOctagon(p.xz, r);
    vec2 w = vec2(d2, abs(p.y) - halfH);
    return min(max(w.x, w.y), 0.0) + length(max(w, 0.0)) - bevel;
}

// 4-way radial bridge struts connecting double octagonal halo frames
float sdHaloBridges(vec3 p, float rIn, float rOut, float halfW, float halfH) {
    vec2 q = abs(p.xz);
    // Align struts along X and Z axes
    vec2 b1 = vec2(abs(q.x - 0.5 * (rIn + rOut)) - 0.5 * (rOut - rIn), q.y - halfW);
    vec2 b2 = vec2(abs(q.y - 0.5 * (rIn + rOut)) - 0.5 * (rOut - rIn), q.x - halfW);
    float d1 = min(max(b1.x, b1.y), 0.0) + length(max(b1, 0.0));
    float d2 = min(max(b2.x, b2.y), 0.0) + length(max(b2, 0.0));
    float dXZ = min(d1, d2);
    vec2 w = vec2(dXZ, abs(p.y) - halfH);
    return min(max(w.x, w.y), 0.0) + length(max(w, 0.0)) - 0.008;
}

// Double-frame floating octagonal halo ring
float sdDoubleHalo(vec3 p, float rOut, float wOut, float rIn, float wIn, float halfH, float ang) {
    vec3 q = p;
    q.xz = rot2(ang) * q.xz;
    float outerR = sdOctRing(q, rOut, wOut, halfH, 0.010);
    float innerR = sdOctRing(q, rIn, wIn, halfH * 0.78, 0.008);
    float bridges = sdHaloBridges(q, rIn, rOut, 0.032, halfH * 0.65);
    return min(min(outerR, innerR), bridges);
}

// ============================================================================
// SCENE MAP
// matId:
//   1.0 = Charcoal ink-grouted arena floor
//   2.0 = Stepped octagonal golden floor pedestal rings
//   3.0 = Recessed glowing golden pedestal channels
//   4.0 = Upper floating octagonal golden double-halo ring
//   5.0 = Lower floating octagonal golden double-halo ring
// ============================================================================
vec2 opMin(vec2 a, vec2 b) {
    return (a.x < b.x) ? a : b;
}

vec2 mapScene(vec3 p, float tLoop, float openAmt) {
    vec2 res = vec2(p.y, 1.0); // Floor at y = 0

    // Slight rotation offset so an octagon flat face faces the camera cleanly
    vec3 pPed = p;
    pPed.xz = rot2(PI / 8.0) * pPed.xz;

    // 1. Stepped geometric octagonal golden floor pedestal (3 nested rings)
    float rOuter = sdOctRing(pPed - vec3(0.0, 0.125, 0.0), 1.38, 0.115, 0.115, 0.012);
    float rMid   = sdOctRing(pPed - vec3(0.0, 0.145, 0.0), 0.94, 0.098, 0.135, 0.011);
    float rInner = sdOctRing(pPed - vec3(0.0, 0.165, 0.0), 0.56, 0.082, 0.155, 0.010);
    // Subtle outer chamfered foot lip
    float rFoot  = sdOctRing(pPed - vec3(0.0, 0.032, 0.0), 1.48, 0.045, 0.025, 0.006);
    float dPed   = min(min(rOuter, rMid), min(rInner, rFoot));
    res = opMin(res, vec2(dPed, 2.0));

    // Recessed glowing energy bed inside the pedestal between the stepped rings
    float dGlowBed = sdOctPrism(pPed - vec3(0.0, 0.042, 0.0), 1.32, 0.038, 0.005);
    res = opMin(res, vec2(dGlowBed, 3.0));

    // 2. Floating rotating octagonal golden halo rings (seamless 3s loop via octagon symmetry)
    float bobUp = 0.045 * sin(tLoop) + 0.10 * openAmt;
    float bobLo = 0.040 * sin(tLoop + 2.094) + 0.05 * openAmt;
    float haloScale = 1.0 + 0.055 * openAmt + 0.012 * sin(tLoop);

    // Upper double-frame halo ring (rotates +PI/2 over 3s -> 2/8 octagon symmetry = seamless)
    vec3 pUp = p - vec3(0.0, 2.52 + bobUp, 0.0);
    float angUp = tLoop * 0.25 + PI / 8.0;
    float dUpHalo = sdDoubleHalo(pUp, 1.24 * haloScale, 0.078, 0.94 * haloScale, 0.046, 0.058, angUp);
    res = opMin(res, vec2(dUpHalo, 4.0));

    // Lower double-frame halo ring (counter-rotates -PI/2 over 3s -> seamless)
    vec3 pLo = p - vec3(0.0, 1.80 + bobLo, 0.0);
    float angLo = -tLoop * 0.25;
    float dLoHalo = sdDoubleHalo(pLo, 0.88 * haloScale, 0.062, 0.67 * haloScale, 0.036, 0.048, angLo);
    res = opMin(res, vec2(dLoHalo, 5.0));

    return res;
}

// Geometry-only distance (excludes floor) for crisp ink silhouette outlines
float mapGoldGeom(vec3 p, float tLoop, float openAmt) {
    vec3 pPed = p;
    pPed.xz = rot2(PI / 8.0) * pPed.xz;
    float rOuter = sdOctRing(pPed - vec3(0.0, 0.125, 0.0), 1.38, 0.115, 0.115, 0.012);
    float rMid   = sdOctRing(pPed - vec3(0.0, 0.145, 0.0), 0.94, 0.098, 0.135, 0.011);
    float rInner = sdOctRing(pPed - vec3(0.0, 0.165, 0.0), 0.56, 0.082, 0.155, 0.010);
    float rFoot  = sdOctRing(pPed - vec3(0.0, 0.032, 0.0), 1.48, 0.045, 0.025, 0.006);
    float dPed   = min(min(rOuter, rMid), min(rInner, rFoot));

    float bobUp = 0.045 * sin(tLoop) + 0.10 * openAmt;
    float bobLo = 0.040 * sin(tLoop + 2.094) + 0.05 * openAmt;
    float haloScale = 1.0 + 0.055 * openAmt + 0.012 * sin(tLoop);

    vec3 pUp = p - vec3(0.0, 2.52 + bobUp, 0.0);
    float dUpHalo = sdDoubleHalo(pUp, 1.24 * haloScale, 0.078, 0.94 * haloScale, 0.046, 0.058, tLoop * 0.25 + PI / 8.0);

    vec3 pLo = p - vec3(0.0, 1.80 + bobLo, 0.0);
    float dLoHalo = sdDoubleHalo(pLo, 0.88 * haloScale, 0.062, 0.67 * haloScale, 0.036, 0.048, -tLoop * 0.25);

    return min(dPed, min(dUpHalo, dLoHalo));
}

// ============================================================================
// UNIT-WEIGHT TETRAHEDRON NORMAL & CREASE INK DETECTION
// ============================================================================
vec3 calcNormal(vec3 p, float tLoop, float openAmt) {
    const float h = 0.0016;
    const vec2 k = vec2(1.0, -1.0);
    vec3 n = k.xyy * mapScene(p + k.xyy * h, tLoop, openAmt).x
           + k.yyx * mapScene(p + k.yyx * h, tLoop, openAmt).x
           + k.yxy * mapScene(p + k.yxy * h, tLoop, openAmt).x
           + k.xxx * mapScene(p + k.xxx * h, tLoop, openAmt).x;
    return normalize(n + vec3(0.0, 1e-6, 0.0));
}

// Measures sharp dihedral creases (edges between octagonal facets, top/side bevels)
float calcCreaseInk(vec3 p, vec3 n, float tLoop, float openAmt, float distToCam) {
    float eps = clamp(0.0065 * distToCam, 0.012, 0.032);
    vec3 t1 = normalize(abs(n.y) < 0.9 ? cross(n, vec3(0.0, 1.0, 0.0)) : cross(n, vec3(1.0, 0.0, 0.0)));
    vec3 t2 = cross(n, t1);

    vec3 n1 = calcNormal(p + t1 * eps, tLoop, openAmt);
    vec3 n2 = calcNormal(p - t1 * eps, tLoop, openAmt);
    vec3 n3 = calcNormal(p + t2 * eps, tLoop, openAmt);
    vec3 n4 = calcNormal(p - t2 * eps, tLoop, openAmt);

    float diff = max(
        max(1.0 - dot(n, n1), 1.0 - dot(n, n2)),
        max(1.0 - dot(n, n3), 1.0 - dot(n, n4))
    );
    // Crisp ink line along every 45-deg octagonal corner and 90-deg top/side bevel
    return smoothstep(0.11, 0.26, diff);
}

// ============================================================================
// LIGHTING DIRECTION PER uLightMode
// ============================================================================
vec3 getKeyLightDir(int lightMode) {
    if (lightMode == 2) return normalize(vec3(-0.72, 0.65, 0.35));
    if (lightMode == 3) return normalize(vec3(0.15, 0.45, -0.88));
    return normalize(vec3(0.55, 0.78, 0.38)); // Hero Spider-Verse / Hades key
}

// ============================================================================
// SHADING: DARK MATTE INK-GROUTED CHARCOAL TILED ARENA FLOOR
// ============================================================================
vec3 shadeFloor(vec3 pos, vec3 nor, vec3 rd, float tLoop, float openAmt, int lightMode) {
    // Rotate floor tile grid slightly for dynamic graphic composition like reference
    vec2 gPos = rot2(-0.30) * pos.xz;
    vec2 tileSize = vec2(1.42, 1.42);
    vec2 tileId = floor(gPos / tileSize);
    vec2 tileUv = fract(gPos / tileSize);

    // Distance-scaled crisp black ink grout lines
    float camDist = length(pos);
    float groutW = mix(0.022, 0.032, clamp(camDist * 0.08, 0.0, 1.0));
    float gx = min(tileUv.x, 1.0 - tileUv.x);
    float gy = min(tileUv.y, 1.0 - tileUv.y);
    float groutInk = 1.0 - smoothstep(groutW * 0.55, groutW, min(gx, gy));

    // Secondary thin architectural panel seam inside tiles
    float subSeam = 1.0 - smoothstep(0.004, 0.010, abs(tileUv.y - 0.5));
    float subMask = step(0.45, hash12(tileId + 7.1));

    // Subtle matte tile tonal variation & comic ink scuff speckles
    float tileTone = 0.88 + 0.24 * hash12(tileId * 1.37);
    float scuff = fbm2(gPos * 5.2);
    float speck = smoothstep(0.68, 0.76, scuff) * 0.22;

    // Linearized dark matte charcoal base matching sRGB ~vec3(0.08, 0.09, 0.12)
    vec3 floorCol = pow(COL_FLOOR_BASE, vec3(2.2)) * tileTone * (1.0 - speck * 0.45);
    floorCol += vec3(0.002, 0.0022, 0.003) * (1.0 - scuff);

    // Distant circular arena rim & thin crimson-rust accent track (from reference background)
    float rWorld = length(pos.xz);
    float arenaRimLine = 1.0 - smoothstep(0.04, 0.08, abs(rWorld - 5.15));
    float arenaCrimson = 1.0 - smoothstep(0.06, 0.14, abs(rWorld - 5.38));
    floorCol = mix(floorCol, COL_CRIMSON_TRIM * 0.42, arenaCrimson * 0.85);
    floorCol = mix(floorCol, COL_INK, arenaRimLine * 0.9);

    // Sub-tile seams & bold ink grout lines
    floorCol = mix(floorCol, COL_INK, subSeam * subMask * 0.45);
    floorCol = mix(floorCol, COL_INK, groutInk * 0.92);

    if (lightMode == 1) {
        // Neutral grayscale clay mode
        float lum = dot(floorCol, vec3(0.299, 0.587, 0.114));
        vec3 clay = vec3(lum * 2.8 + 0.04);
        clay = mix(clay, vec3(0.025), groutInk * 0.85);
        return clay;
    }

    // ---- WARM OCHRE / SOLAR-GOLD QUANTIZED CEL FLOOR SPILL ----
    float pulse = 1.0 + 0.08 * sin(tLoop) + 0.28 * openAmt;
    float rSpill = rWorld / pulse;

    // 3 quantized cel-shaded radial spill bands around the octagonal pedestal
    float bandOuter = 1.0 - smoothstep(2.65, 2.78, rSpill);
    float bandMid   = 1.0 - smoothstep(2.05, 2.16, rSpill);
    float bandInner = 1.0 - smoothstep(1.66, 1.74, rSpill);

    // Crisp concentric decorative floor ring line at spill edge
    float spillRing = 1.0 - smoothstep(0.015, 0.032, abs(rSpill - 1.92));

    // Stylized vertical specular floor reflection stripe extending toward camera (+Z)
    float frontMask = smoothstep(-0.2, 0.6, pos.z);
    float reflStripe = (1.0 - smoothstep(0.26, 0.34, abs(pos.x))) * frontMask * (1.0 - smoothstep(1.2, 3.6, pos.z));

    vec3 spillCol = vec3(0.0);
    spillCol = mix(spillCol, COL_OCHRE_SPILL * 0.42, bandOuter);
    spillCol = mix(spillCol, COL_GOLD_MID * 0.78,    bandMid);
    spillCol = mix(spillCol, COL_LEMON_GLOW * 1.15,  bandInner);
    spillCol += COL_LEMON_GLOW * reflStripe * 0.42 * (0.85 + 0.35 * openAmt);
    spillCol = mix(spillCol, COL_GOLD_HI * 0.95, spillRing * 0.55);

    // Crisp drop-shadow directly beneath the outer octagonal pedestal wall
    vec2 pPed = rot2(PI / 8.0) * pos.xz;
    float octD = sdOctagon(pPed, 1.52);
    float pedShadow = 1.0 - smoothstep(-0.02, 0.14, octD);
    spillCol *= (1.0 - 0.68 * pedShadow * smoothstep(-0.08, 0.02, octD));

    // Preserve bold ink grout lines right through the golden floor spill!
    vec3 litFloor = floorCol + spillCol * (0.95 + 0.35 * openAmt);
    litFloor = mix(litFloor, COL_INK * 1.5, groutInk * 0.88);
    litFloor = mix(litFloor, COL_INK * 2.2, subSeam * subMask * 0.38);

    // Soft far-distance atmospheric charcoal fade
    float fog = smoothstep(5.5, 11.5, rWorld);
    vec3 skyCharcoal = pow(vec3(0.06, 0.068, 0.095), vec3(2.2));
    litFloor = mix(litFloor, skyCharcoal, fog * 0.82);

    return litFloor;
}

// ============================================================================
// SHADING: 3-BAND CEL-SHADED OCTAGONAL GOLD PEDESTAL & FLOATING HALO RINGS
// ============================================================================
vec3 shadeGoldCel(vec3 pos, vec3 nor, vec3 rd, float matId, float tLoop, float openAmt, int lightMode, float hitT) {
    vec3 V = -rd;
    vec3 L = getKeyLightDir(lightMode);

    // Recessed glowing energy bed inside the pedestal
    if (matId > 2.5 && matId < 3.5) {
        if (lightMode == 1) return vec3(0.45);
        float r = length(pos.xz);
        float coreGlow = 1.0 - smoothstep(0.35, 1.25, r);
        float pulse = 1.0 + 0.12 * sin(tLoop) + 0.45 * openAmt;
        vec3 gCol = mix(COL_GOLD_HI * 0.95, COL_CREAM_WHITE * 1.45, coreGlow) * pulse;
        return gCol;
    }

    // Direction toward the central pillar (internal golden bounce light!)
    vec3 toCenter = normalize(vec3(-pos.x, 0.15, -pos.z) + vec3(1e-5, 0.0, 0.0));
    float pillarBounce = max(dot(nor, toCenter), 0.0);

    // Key diffuse + top-face highlight bias (matches crisp flat-shaded graphic look in ref)
    float ndl = dot(nor, L);
    float topBias = smoothstep(0.65, 0.85, nor.y);
    float celInput = clamp(ndl * 0.65 + 0.35 + topBias * 0.32 + pillarBounce * 0.25, 0.0, 1.0);

    // Quantized 3-band cel shading with razor-clean transitions
    float band1 = smoothstep(0.34, 0.37, celInput);
    float band2 = smoothstep(0.70, 0.73, celInput);

    // Specular graphic slash on top bevels
    vec3 H = normalize(L + V);
    float spec = smoothstep(0.90, 0.92, dot(nor, H));

    vec3 col;
    if (lightMode == 1) {
        // Neutral grayscale clay mode with 3-band cel steps
        col = mix(vec3(0.14), vec3(0.38), band1);
        col = mix(col, vec3(0.68), band2);
        col += vec3(0.10) * spec;
    } else {
        col = mix(COL_GOLD_SHAD, COL_GOLD_MID, band1);
        col = mix(col, COL_GOLD_HI, band2);
        // Cream-white blazing rim on top faces closest to the pillar
        float innerRim = topBias * (1.0 - smoothstep(0.45, 1.35, length(pos.xz)));
        col = mix(col, COL_CREAM_WHITE * 1.08, clamp(innerRim * 0.75 + spec * 0.65, 0.0, 1.0));
        // Inner-facing rim glow from the holy smite pillar
        float smiteBoost = 0.85 + 0.12 * sin(tLoop) + 0.38 * openAmt;
        col += COL_LEMON_GLOW * smoothstep(0.45, 0.65, pillarBounce) * 0.35 * smiteBoost;

        if (lightMode == 3) {
            float fres = pow(1.0 - max(dot(nor, V), 0.0), 3.0);
            col += COL_CREAM_WHITE * fres * 0.55;
        }
    }

    // ---- BOLD BLACK-INK CONTOUR & CREASE OUTLINES ----
    float creaseInk = calcCreaseInk(pos, nor, tLoop, openAmt, hitT);
    // Grazing Fresnel silhouette ink on curved bevels
    float ndv = max(dot(nor, V), 0.0);
    float fresInk = 1.0 - smoothstep(0.14, 0.24, ndv);
    float inkMask = clamp(max(creaseInk * 0.95, fresInk * 0.85), 0.0, 1.0);

    col = mix(col, COL_INK, inkMask);
    return col;
}

// ============================================================================
// 3-BAND CEL-SHADED VERTICAL HOLY SMITE ENERGY COLUMN (EXACT DEPTH OCCLUSION)
// ============================================================================
vec4 evalSmitePillar(vec3 ro, vec3 rd, float hitT, float tLoop, float openAmt, int lightMode) {
    if (lightMode == 1) return vec4(0.0);

    float pulse = 1.0 + 0.045 * sin(tLoop) + 0.18 * openAmt;
    float rBeam = 0.38 * pulse;
    float rGlow = 0.78 * pulse;

    // Closest approach of ray to Y-axis (vertical pillar x=0, z=0)
    vec2 ro2 = ro.xz;
    vec2 rd2 = rd.xz;
    float a = dot(rd2, rd2);
    if (a < 1e-6) return vec4(0.0);

    float tClosest = -dot(ro2, rd2) / a;
    if (tClosest < 0.0) return vec4(0.0);

    vec3 pClosest = ro + rd * tClosest;
    // Pillar exists from pedestal center y = 0.14 upward to infinity
    if (pClosest.y < 0.08) return vec4(0.0);

    float dAxis = length(pClosest.xz);
    float yMask = smoothstep(0.10, 0.22, pClosest.y);

    // Exact cylinder intersection for front/back occlusion against floating halo rings
    float disc = rBeam * rBeam - dAxis * dAxis;
    vec3 pillarCol = vec3(0.0);
    float alpha = 0.0;

    if (disc > 0.0) {
        float halfChord = sqrt(max(disc, 0.0)) / sqrt(max(a, 1e-6));
        float tNear = tClosest - halfChord;
        float tFar  = tClosest + halfChord;

        // Visible if front of pillar is in front of opaque hitT (or hitT is behind pillar center)
        if (tNear < hitT && tFar > 0.0) {
            // Smooth transition where pillar meets pedestal or passes behind front halo ring
            float depthVis = smoothstep(tNear - 0.02, tNear + 0.08, hitT);
            float u = clamp(dAxis / max(rBeam, 1e-5), 0.0, 1.0);

            // Upward-streaming graphic Valorant/Hades chevron & vertical panel cutouts (seamless 3s loop)
            float scrollY = pClosest.y * 1.15 - (tLoop / TAU) * 3.0;
            float panelY = fract(scrollY * 0.5);
            float chev = abs(u - 0.55) * 1.8 + abs(panelY - 0.5);
            float techLine = 1.0 - smoothstep(0.015, 0.030, abs(u - 0.62));
            float diagCut  = 1.0 - smoothstep(0.02, 0.045, abs(fract(scrollY * 0.5 + u * 0.65) - 0.5));

            // 3-band quantized cel energy column:
            //   Band 0 (0.00..0.38): Blazing cream-white core
            //   Band 1 (0.38..0.72): Lemon-gold energy jacket with tech lines
            //   Band 2 (0.72..1.00): Rich solar-gold / amber outer cel shell
            float coreBand = 1.0 - smoothstep(0.35, 0.39, u);
            float midBand  = 1.0 - smoothstep(0.71, 0.75, u);
            float outBand  = 1.0 - smoothstep(0.95, 1.00, u);

            vec3 c = mix(COL_GOLD_MID * 1.15, COL_GOLD_HI * 1.25, midBand);
            // Graphic angular notch lines inside mid-gold band
            c = mix(c, COL_GOLD_MID * 0.72, (techLine * 0.45 + diagCut * 0.25) * (1.0 - coreBand) * midBand);
            c = mix(c, COL_CREAM_WHITE * (1.85 + 0.55 * openAmt), coreBand);

            // Crisp golden-white vertical edge rim highlight
            float rimLine = (1.0 - smoothstep(0.02, 0.05, abs(u - 0.94))) * 0.55;
            c += COL_LEMON_GLOW * rimLine;

            // Subtle energy shimmer along height
            float shimmer = 0.94 + 0.06 * sin(pClosest.y * 4.0 - tLoop * 2.0);
            pillarCol = c * shimmer * (0.95 + 0.32 * openAmt);
            alpha = outBand * depthVis * yMask;
        }
    }

    // Outer warm solar-gold aura glow around the beam (occluded by front halo geometry)
    if (tClosest < hitT + 0.45 && dAxis < rGlow) {
        float gVis = smoothstep(tClosest - 0.55, tClosest + 0.15, hitT);
        float g = 1.0 - smoothstep(rBeam * 0.75, rGlow, dAxis);
        float haloGlow = pow(max(g, 0.0), 2.4) * (0.58 + 0.35 * openAmt) * yMask * gVis;
        pillarCol += mix(COL_GOLD_MID, COL_LEMON_GLOW, g) * haloGlow;
        alpha = max(alpha, clamp(haloGlow * 0.65, 0.0, 1.0));
    }

    return vec4(pillarCol, alpha);
}

// ============================================================================
// SHARP 4-POINT / 8-POINT COMIC STAR FLARES & UPPER HALO STARBURST
// ============================================================================
// Evaluates a razor-sharp 8-point comic star (4 long cardinal spikes + 4 shorter diagonal spikes)
vec3 evalComicStar2D(vec2 d, float radius, float diagScale, float rotAng, float intensity) {
    vec2 p = rot2(rotAng) * d;
    float r = length(p);
    if (r > radius * 1.45) return vec3(0.0);

    // Cardinal 4-point razor star SDF-like field
    vec2 a = abs(p);
    float sCard = (a.x * a.y) / max(radius * radius * 0.032, 1e-6) + (r / max(radius, 1e-5));
    float cardShape = 1.0 - smoothstep(0.72, 0.96, sCard);

    // Diagonal 4-point star (rotated 45 deg, shorter spikes)
    vec2 pd = abs(rot2(PI * 0.25) * p);
    float rDiag = radius * diagScale;
    float sDiag = (pd.x * pd.y) / max(rDiag * rDiag * 0.028, 1e-6) + (r / max(rDiag, 1e-5));
    float diagShape = 1.0 - smoothstep(0.72, 0.96, sDiag);

    float starBody = max(cardShape, diagShape);

    // Thin golden-amber comic outline/rim around the crisp white star
    float rimCard = 1.0 - smoothstep(0.92, 1.24, sCard);
    float rimDiag = 1.0 - smoothstep(0.92, 1.24, sDiag);
    float starRim = max(rimCard, rimDiag);

    // Soft warm golden glow halo
    float glow = exp(-r * (5.2 / max(radius, 1e-4))) * 0.55;

    vec3 col = COL_GOLD_MID * glow;
    col = mix(col, COL_GOLD_HI * 1.25, starRim);
    col = mix(col, COL_CREAM_WHITE * 1.95, starBody);
    return col * intensity;
}

// Blazing multi-spike solar starburst where the pillar pierces the upper halo ring
vec3 evalUpperStarburst(vec2 uv, vec3 ro, vec3 cu, vec3 cv, vec3 cw, float fov, float tLoop, float openAmt) {
    float bobUp = 0.045 * sin(tLoop) + 0.10 * openAmt;
    vec3 burstWorld = vec3(0.0, 2.50 + bobUp, 0.0);
    vec3 rel = burstWorld - ro;
    float z = dot(rel, cw);
    if (z <= 0.1) return vec3(0.0);

    vec2 screenPos = vec2(dot(rel, cu), dot(rel, cv)) * (fov / z);
    vec2 d = uv - screenPos;
    float r = length(d);

    float scale = (0.34 + 0.04 * sin(tLoop) + 0.12 * openAmt) * (4.2 / z);
    if (r > scale * 1.8) return vec3(0.0);

    float ang = atan(d.y, d.x);

    // 8 primary razor spikes + 8 fine secondary sun-rays
    float raysPrimary   = pow(max(abs(cos(ang * 4.0 + tLoop * 0.125)), 0.0), 10.0);
    float raysSecondary = pow(max(abs(cos(ang * 4.0 + PI * 0.25 - tLoop * 0.125)), 0.0), 14.0) * 0.72;
    float rayLen = scale * (0.36 + 0.85 * max(raysPrimary, raysSecondary));

    float coreMask = 1.0 - smoothstep(scale * 0.18, scale * 0.34, r);
    float spikeMask = 1.0 - smoothstep(rayLen * 0.78, rayLen, r);
    float outerFlare = exp(-r / max(scale * 0.42, 1e-4));

    vec3 col = COL_GOLD_MID * outerFlare * 0.78;
    col += COL_LEMON_GLOW * spikeMask * 1.05;
    col = mix(col, COL_CREAM_WHITE * (2.05 + 0.45 * openAmt), clamp(coreMask + spikeMask * 0.52, 0.0, 1.0));
    return col * (0.95 + 0.30 * openAmt);
}

// Project 3 floating 4-point/8-point comic stars around the mid-pillar (matching reference composition)
vec3 evalFloatingStars(vec2 uv, vec3 ro, vec3 cu, vec3 cv, vec3 cw, float fov, float tLoop, float openAmt) {
    vec3 total = vec3(0.0);

    // Star 1: Left-mid large 8-point comic star
    vec3 p1 = vec3(-1.05, 1.56 + 0.06 * sin(tLoop + 0.4), 0.35);
    // Star 2: Lower-left smaller comic star
    vec3 p2 = vec3(-0.78, 0.96 + 0.05 * sin(tLoop + 2.5), 0.55);
    // Star 3: Right-mid medium 8-point comic star
    vec3 p3 = vec3( 1.04, 1.18 + 0.06 * sin(tLoop + 4.4), 0.22);

    vec3 stars[3];
    stars[0] = p1;
    stars[1] = p2;
    stars[2] = p3;

    float radii[3];
    radii[0] = 0.125;
    radii[1] = 0.082;
    radii[2] = 0.112;

    float phases[3];
    phases[0] = 0.0;
    phases[1] = 2.094;
    phases[2] = 4.188;

    for (int i = 0; i < 3; i++) {
        vec3 rel = stars[i] - ro;
        float z = dot(rel, cw);
        if (z > 0.1) {
            vec2 sp = vec2(dot(rel, cu), dot(rel, cv)) * (fov / z);
            float twinkle = 0.86 + 0.22 * sin(tLoop + phases[i]) + 0.28 * openAmt;
            float rad = radii[i] * (4.4 / z) * (0.92 + 0.12 * sin(tLoop + phases[i]) + 0.16 * openAmt);
            total += evalComicStar2D(uv - sp, rad, 0.56, 0.0, twinkle);
        }
    }
    return total;
}

// ============================================================================
// ACES FILMIC TONE MAPPING (SOFT HIGHLIGHT ROLLOFF -> <1% CLIP)
// ============================================================================
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, 0.985);
}

// ============================================================================
// MAIN RENDERER
// ============================================================================
void main() {
    vec2 uv = (gl_FragCoord.xy - 0.5 * uResolution.xy) / max(uResolution.y, 1.0);

    // 3-second seamless loop phase (0..TAU)
    float tLoop = mod(uTime, 3.0) * (TAU / 3.0);
    float openAmt = clamp(uOpen, 0.0, 1.0);

    // Camera setup: uCamMode 0 = Hero 3/4 view matching reference; 1 = ~2.2x close-up macro on halo rings
    vec3 ro, ta;
    float fov;
    if (uCamMode == 1) {
        ro  = vec3(0.08, 2.75, 2.38);
        ta  = vec3(0.00, 2.12, 0.00);
        fov = 1.65;
    } else {
        ro  = vec3(0.00, 3.45, 4.35);
        ta  = vec3(0.00, 1.48, 0.00);
        fov = 1.45;
    }

    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 + fov * cw);

    // Raymarch scene + track closest approach to golden geometry for crisp silhouette ink outlines
    float t = 0.0;
    float matId = 0.0;
    float minGeomD = 1e5;
    float minGeomT = 1e5;
    const float tMax = 16.0;

    for (int i = 0; i < 96; i++) {
        vec3 p = ro + rd * t;
        vec2 h = mapScene(p, tLoop, openAmt);
        float dg = mapGoldGeom(p, tLoop, openAmt);
        if (dg < minGeomD) {
            minGeomD = dg;
            minGeomT = t;
        }
        if (h.x < 0.0012) {
            matId = h.y;
            break;
        }
        t += h.x * 0.85;
        if (t > tMax) break;
    }

    vec3 col;
    float hitT = tMax;

    if (matId > 0.5) {
        hitT = t;
        vec3 pos = ro + rd * t;
        vec3 nor = calcNormal(pos, tLoop, openAmt);
        if (matId < 1.5) {
            col = shadeFloor(pos, nor, rd, tLoop, openAmt, uLightMode);
        } else {
            col = shadeGoldCel(pos, nor, rd, matId, tLoop, openAmt, uLightMode, hitT);
        }
    } else {
        // Dark matte charcoal-indigo sky behind upper arena
        col = (uLightMode == 1) ? vec3(0.08) : pow(vec3(0.06, 0.066, 0.092), vec3(2.2));
    }

    // Crisp Spider-Verse outer black-ink silhouette halo around floating halo rings & pedestal
    if (matId < 1.5 || matId > 2.5) {
        float inkWidth = clamp(0.0042 * minGeomT, 0.009, 0.024);
        float silInk = 1.0 - smoothstep(inkWidth * 0.45, inkWidth, minGeomD);
        // Only draw silhouette ink when the grazing ring is actually in front of what we hit
        if (minGeomT < hitT + 0.05) {
            col = mix(col, COL_INK, silInk * 0.94);
        }
    }

    // Composite towering 3D solar-gold & cream-white holy smite pillar with accurate depth occlusion
    vec4 pillar = evalSmitePillar(ro, rd, hitT, tLoop, openAmt, uLightMode);
    col = mix(col, pillar.rgb, clamp(pillar.a, 0.0, 1.0));
    if (uLightMode != 1) {
        // Soft additive bloom lift from the energy column
        col += pillar.rgb * pillar.a * 0.14;
    }

    // Blazing upper halo starburst & sharp floating 4-point/8-point comic star flares
    if (uLightMode != 1) {
        col += evalUpperStarburst(uv, ro, cu, cv, cw, fov, tLoop, openAmt);
        col += evalFloatingStars(uv, ro, cu, cv, cw, fov, tLoop, openAmt);
    }

    // Subtle graphic vignette & safe floor-lift (ensures <2% pure black)
    float vig = 1.0 - 0.16 * dot(uv, uv);
    col *= clamp(vig, 0.72, 1.0);
    col = max(col, vec3(0.0038, 0.0040, 0.0055));

    // Exposure & ACES filmic tone mapping (<1% clip)
    col = acesToneMap(col * 0.88);

    // Linear -> sRGB gamma
    col = pow(max(col, vec3(0.0)), vec3(1.0 / 2.2));

    fragColor = vec4(col, 1.0);
}

Mathematical models & shader specifications

Identifiersolar-gold-holy-smite-pillar
CategoryGame VFX Shaders · Stylized Cel VFX
Upstream studyvfx_stylized/lib/03_solar_gold_holy_smite_pillar.glsl (commit f5bfb61)
Animation cycleContinuous procedural uTime
Declared uniformsuResolution, uTime, uOpen, uLightMode, uCamMode
Source size704 lines · 29.1 KB standalone GLSL ES 3.00
PNG baker outputs512px · 1024px · 2048px RGBA8 (4-tap seamless + alpha key)
Companion pixel VFXFree MIT holy sprite sheets
LicenseMIT License + CC0 / MIT Helpers

Physical & shading models implemented

Schlick Fresnel reflectance (1994); Beer–Lambert volumetric absorption/attenuation

Adapted upstream mathematical helpers

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

All game vfx shaders