title: Procedural Texturing Checkerboard OpenGL
body: <p>I encounter some difficulties to implement a procedural texture of checkerboard. Here is what I need to get:</p>
  
  <p><a href="https://i.stack.imgur.com/Uceef.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Uceef.png" alt="enter image description here"></a></p>
  
  <p>Here is what i get:</p>
  
  <p><a href="https://i.stack.imgur.com/U7F9Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/U7F9Q.png" alt="enter image description here"></a></p>
  
  <p>It's close but my texture is kind of rotated in respect of what I need to get.</p>
  
  <p>Here is the code of my shader:</p>
  
  <pre><code>#version 330
  
  in vec2 uv;
  
  out vec3 color;
  
  uniform sampler1D colormap;
  
  void main() {
      float sx = sin(10*3.14*uv.x)/2 + 0.5;
  
      float sy = sin(10*3.14*uv.y)/2 + 0.5;
  
      float s = (sx + sy)/2;
  
  
      if(true){
              color = texture(colormap,s).rgb;
       }
  </code></pre>
  
  <p>colormap is a mapping from 0 to 1, where 0 correspond to red, 1 to green.</p>
  
  <p>I think the problem is coming from the formula i use, (sx+sy)/2 . I need to get the square not rotated but aligned with the border of the big square.
  If someone has an idea to get the good formula.</p>
  
  <p>Thanks.</p>