Skip to content

cosine wave

BLOKS Shader Bulletin Board

cosine wave

By John Doe June 8, 2026

Shader Preview Unavailable

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

Shader Code
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 bg = vec3(0.02, 0.03, 0.08);
    vec3 gridCol = vec3(0.10, 0.16, 0.32);
    vec3 blue = vec3(0.18, 0.32, 1.0);
    vec3 cyan = vec3(0.28, 0.65, 1.0);

    vec3 col = bg;

    float grid = 0.0;
    grid += smoothstep(0.012, 0.0, abs(fract(p.x * 4.0) - 0.5) / 4.0);
    grid += smoothstep(0.012, 0.0, abs(fract(p.y * 4.0) - 0.5) / 4.0);
    col += gridCol * grid * 0.18;

    float axisX = smoothstep(0.006, 0.0, abs(p.y));
    float axisY = smoothstep(0.006, 0.0, abs(p.x));
    col += vec3(0.20, 0.28, 0.45) * (axisX + axisY);

    float y = cos(p.x * 3.14159 + iTime) * 0.45;
    float d = abs(p.y - y);

    float line = smoothstep(0.018, 0.0, d);
    float glow = 0.025 / max(d, 0.025);

    col += blue * glow * 0.35;
    col += cyan * line;

    fragColor = vec4(col, 1.0);
}

← Back to Shader Bulletin Board