Project_2024-10-27_23-54-24

GLSL shader by scry · created 2024-10-28 · 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)

Buffer A (iChannel0)

#define pi acos(-1.)
#define deg pi/180.
#define time iTime*pi/10.
#define R iResolution.xy
#define ar R.x/R.y
vec3 cs = vec3(1.,2.,3.);
mat2 r2d(float a) {
    return mat2(cos(a),sin(a),-sin(a),cos(a));
}
float sdBox(vec3 p, vec3 b) {
    vec3 q = abs(p) - b;
    return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0);
}
vec4 map(vec3 p) {
    p.z -= 4.;
    p.yz *= r2d(deg*-45.);
    p.xz *= r2d(deg*45.);
    float d = sdBox(p,vec3(0.5));
    d = min(d,p.y+0.5+sin(d*10.-time*40.)*0.1);
    return vec4(p,d);
}
vec2 RM(vec3 ro, vec3 rd) {
    float dO = 0.;
    float ii = 0.;
    for (int i=0;i<40;i++) {
        vec3 p = ro+rd*dO;
        float dS = map(p).w;
        dO += dS;
        ii += 0.01;
        if ( dO > 100. || dS < 0.001) {break;}
    }
    return vec2(dO,ii);
}
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.);
    vec3 ro = vec3(0.);
    vec3 rd = normalize(vec3(uv,1.));
    vec2 d = RM(ro,rd);
    col += d.x*0.1;
    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