Skip to content

mattdesl/glsl-checker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

repeating checker GLSL pattern

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages