I am attempting to create a X by Y checkerboard (by this, I simply mean that I could set any size for X and Y) using OpenGL ES 2.0, but I’m wondering how I go about creating the pattern.
I have already got the MVP matrix working well (presently I’m just using a solid colored rectangle), it correctly renders appropriate to the screen, centered and in full view (and each box [-created a couple test boxes] is square, regardless of the over-all size). The world coordinates are simple 1×1 spaces for each grid space, and the view and projection matrices bring it into perfect view.
What I can’t work out is applying that checkerboard pattern. I considered first using a single rectangle as I am now, and applying a fragment shader, but I couldn’t work out how to make that work given that the grid could be any number of spaces in either direction (and no longer in world coordinates by that point). I also considered creating a background and then adding a colored square every other space, but that seemed resource intensive for what should be a pretty simple job.
What would be the best way to go about this?
I would use mod function and remainder to select the white or black
and poke this into the color.
Look for some examples at the famous GLSL Sandbox site.
See also figure 1.2
http://webstaff.itn.liu.se/~stegu/TNM084-2012/proceduraltextures.pdf