Project_2026-02-16_16-20-19

GLSL shader by scry · created 2026-02-17 · updated 2026-06-18 · 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)

float sdBox(in vec2 p, in vec2 b) {
    vec2 d = abs(p)-b;
    return length(max(d,0.0)) + min(max(d.x,d.y),0.0);
}

vec2 calcNormal2D(vec2 p, vec2 b) {
    vec2 e = vec2(0.001, 0.0);
    return normalize(vec2(
        sdBox(p + e.xy, b) - sdBox(p - e.xy, b),
        sdBox(p + e.yx, b) - sdBox(p - e.yx, b)
    ));
}

float lighting2D(vec2 normal, vec2 lightDir) {
    float diff = max(dot(normal, lightDir), 0.0);
    vec2 viewDir = vec2(0.0, 0.0) - normalize(vec2(0.0, 1.0));
    vec2 halfDir = normalize(lightDir + viewDir);
    float spec = pow(max(dot(normal, halfDir), 0.0), 16.0);
    return diff * 0.7 + spec * 0.3 + 0.2;
}

vec3 c1(vec2 uv, float t) {
    vec3 col = vec3(0.);
    uv *= 1.09;
    uv *= 3.;
    float s = 4.6;
    vec2 gb = floor(uv*s-0.5)+1.;
    uv = (fract(uv*s-0.5)-0.5)/s;
    float b = sdBox(uv, vec2(0.1, 0.1));
    

    vec2 fc = gb;
    fc = abs(fc);
    fc *= r2d(deg*45.);
    vec2 gc = abs(gb)/2.;
    vec4 cg = vec4(sin(t+gc.x),cos(t+gc.y),sin(t*2.-gc.x),cos(t*2.-gc.y));
    float edgeDist = abs(b);
    float isEdge = smoothstep(0.035, 0.005, edgeDist);
    vec2 n = isEdge > 0.5 ? calcNormal2D(uv, vec2(0.1, 0.1)) : vec2(0.0, 1.0);
    vec2 lightDir = normalize(vec2(cos(t * 1.+gc.x*pi), sin(t * 1.+gc.x*pi)));
    float lit = mix(1.0, lighting2D(n, lightDir), isEdge);
    col = vec3(smoothstep(0.01, 0.0, abs(b+0.02)))*0.5*(sin(cs+t*2.+fc.y*pi)*0.5+0.2+cg.x*-cg.w);
    col += (smoothstep(0.01, 0.0, abs(b+0.04)-0.01))*0.5*(sin(cs+t*2.+fc.y*pi+fc.x*pi)*0.5+0.2+cg.y*cg.w);
    col += (smoothstep(0.01, 0.0, abs(b+0.075)-0.005))*0.5*(sin(cs+t*2.+(abs(gb)*r2d(deg*45.)).y)*0.5+0.2+cg.z*cg.x);
    col += (smoothstep(0.01, 0.0, abs(b+0.1)-0.005))*0.5*(sin(cs+t*2.+(abs(gb)*r2d(deg*-45.)).y)*0.5+0.2+cg.x*cg.y*cg.z);
    col += (smoothstep(0.01,0.,b))/2.*(cos(cs+t+fc.x*pi)*0.5+0.2+-cg.y*cg.x);
    col += (smoothstep(0.01, 0.0, abs(b+0.)-0.005))*sin(atan(uv.x,uv.y)+cs+time*10.+fc.x*pi*2.)*0.3;
    col += (smoothstep(0.01, 0.0, abs(b+0.1)-0.05))*sin(atan(uv.x,uv.y)*2.+cs-time*10.-fc.x*pi*2.)*0.1;
    col = col * lit + (1.-fc.x*0.1)*0.2*(sin(t)*0.5+0.5);
    col = clamp(col,0.,1.);
    return col;
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
    vec2 uv = fragCoord.xy / iResolution.xy;
    vec2 tv = uv;
    uv -= 0.5;
    uv.x *= ar;
    vec3 col = vec3(0.);
    //uv *= 1.09;
    for (int i=0;i<8;i++) {
        float ii = float(i);
        float fi = fract(ii/3.+time/pi/2.);
        float f2 = fract(ii/3.+time/pi/2.+0.5);
        float afi = abs(fi-0.5)*2.;
        float af2 = abs(fi-0.5)*2.;
        float nfi = 1.-fi;
        float nf2 = 1.-f2;
        float naf2 = 1.-af2;
        float nafi = 1.-afi;
        nf2 = pow(nf2,1.9);
        vec2 av = uv;
        //av = av/dot(av,av);
        //uv *= r2d(deg*45.);
        float d = max(abs(av.x),abs(av.y))*40.;
        //av += sin(uv*14.+ii/pi/3.)*nf2*0.1;
        //av += vec2(sin(time*6.+d),cos(time*6.+d))*pow(nf2,6.)*0.3;
        //av.x += sin(uv.x*3.+ii)*nf2*sin(ii*pi/2.+afi*2.)*0.05;
        //av.y += sin(uv.y*3.+ii)*nf2*-sin(ii*pi/2.+afi*2.)*0.05;
        av += sin((av*r2d(time*1.)).x*1.)*pow(nf2,4.)*afi*1.2;
        //av += cos((av*r2d(time*1.+ii)).y*1.)*pow(nf2,4.);
        //av += sin(av.y+ii)*pow(nf2,3.);
        av *= r2d(deg*45.);
        
        //av += sin(av.yx*80.+ii/pi/3.)*pow(nf2,4.)*0.1;
        //av = av/dot(av,av);
        //av *= 1.+sin(sdBox(av,vec2(10.))*40.+time*4.)*nf2*0.012;
        //av += sin(av.yx*14.+ii/pi/3.)*pow(nf2,4.)*0.5;
        
        av *= r2d(deg*-45.);
        //av += vec2(sin(time*6.+d),cos(time*6.+d))*-pow(nf2,6.)*0.3;
        vec3 c = c1(av,time*1.+ii*pi/16.)*afi*0.3;
        col += c;
    }

    //col = c1(uv, time);
    fragColor = vec4(col, 1.0);
}

Image

Not used

More shaders by scry

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

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

Account

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