title: GLSL Checkerboard Pattern
body: <p>i want to shade the quad with checkers:</p>
  
  <blockquote>
    <p>f(P)=[floor(Px)+floor(Py)]mod2.</p>
  </blockquote>
  
  <p>My quad is:</p>
  
  <pre><code>glBegin(GL_QUADS);    
    glVertex3f(0,0,0.0);    
    glVertex3f(4,0,0.0);    
    glVertex3f(4,4,0.0);   
    glVertex3f(0,4, 0.0); 
  glEnd();
  </code></pre>
  
  <p>The vertex shader file:</p>
  
  <pre><code>varying float factor;
  float x,y;
  void main(){
    x=floor(gl_Position.x);
    y=floor(gl_Position.y);
    factor = mod((x+y),2.0);
  }
  </code></pre>
  
  <p>And the fragment shader file is:</p>
  
  <pre><code>varying float factor;
  void main(){
    gl_FragColor = vec4(factor,factor,factor,1.0);
  }
  </code></pre>
  
  <p>But im getting this:</p>
  
  <p><img src="https://i.stack.imgur.com/SjAW8.jpg" alt="alt text"></p>
  
  <p>It seems that the mod function doeasn't work or maybe somthing else...
  Any help?</p>