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 and professional software engineer. Lets make something awesome together!