1.0.1 • Published 9 years ago

glsl-checker v1.0.1

Weekly downloads
27
License
MIT
Repository
github
Last release
9 years ago

glsl-checker

stable

img

(glslb.in demo)

GLSL utility for checkered patterns.

uniform vec2 iResolution;

#pragma glslify: checker = require('glsl-checker')

void main() {
  vec2 uv = vec2(gl_FragCoord.xy / iResolution.xy);

  //optionally fix aspect ratio
  uv.x *= iResolution.x / iResolution.y;

  //18x18 checkered background
  float gray = mix(0.8, 1.0, checker(uv, 18.0));
  
  gl_FragColor.rgb = vec3(gray);
  gl_FragColor.a = 1.0;
}

Usage

NPM

float c = checker(vec2 uv, float n)

Creates a checkered n x n pattern with the given UV coordinates, returning a float 0.0 or 1.0.

License

MIT, see LICENSE.md for details.