This page looks best with JavaScript enabled

Shadertoy: Grid Shader

 ·   ·  ☕ 1 min read

A Shadertoy shader creating a grid. This makes it possible to create an infintely scalable grid pattern that is fairly light-weight.

void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
    // Normalized pixel coordinates (from 0 to 1)
    vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;

    // Time varying pixel color
    float scale = 15.0 + 5.0*cos(iTime);
    
    float gridPointX = step(float(mod(uv.x * scale, 1.0)), 0.1);
    float gridPointY = step(float(mod(uv.y * scale, 1.0)), 0.1);
    float gridPoint = min(1.0, gridPointX + gridPointY);

    // Output to screen
    fragColor = vec4(gridPoint, gridPoint, gridPoint, 1.0);
}

Sam Wronski
WRITTEN BY
Sam Wronski
Maker of things, currently helping build cloud things @ Google. World of Zero is a personal project disconnected from my professional work. Lets make something awesome together!