Skip to content

raymarch steps

BLOKS Shader Bulletin Board

raymarch steps

By RJ Shelton June 9, 2026

Shader Preview Unavailable

This realtime shader may be too intensive for your current device or browser.

Shader Code
float map(vec3 p)
{
    return length(p) - 1.0;
}

void mainImage(out vec4 fragColor, in vec2 fragCoord)
{
    vec2 uv = fragCoord.xy / iResolution.xy;

    vec2 p = uv * 2.0 - 1.0;

    p.x *= iResolution.x / iResolution.y;

    vec3 ro = vec3(0.0, 0.0, -4.0);
    vec3 rd = normalize(vec3(p, 1.5));

    float d = 0.0;

    vec3 color = vec3(0.02, 0.04, 0.08);

    for(int i = 0; i < 24; i++)
    {
        vec3 pos = ro + rd * d;

        float ds = map(pos);

        float marker =
            0.015 / abs(length(pos.xy) - 1.0);

        color += vec3(1.0, 0.2, 0.8) * marker;

        d += ds;

        if(ds < 0.001) break;
    }

    fragColor = vec4(color, 1.0);
}

← Back to Shader Bulletin Board