I’m trying to write a checkerboard pattern inside a shader but not able to figure out the math for it. Right now I just draw black when tex.x and tex.y are less than 0.5 or greater than 0.5 and draw white if not. This results in half the image being white and half being black and not a real checkerboard.
Share
the boolean condition for a 2×2 checkerboard would be something like
(tex.x < 0.5) ^^ (tex.y < 0.5)Of course, if you want more checkers, you have to start doing some
modcomputation on each texture coordinate.Edit to add:
Say you want a checkerboard pattern of 2Nx2M squares (even to allow for simple math):
That is, bring the texture coordinates to the range you care about, and keep only the decimal part.