Posted By

vorp on 04/21/10


Tagged

opengl GLSL


Versions (?)

GLSL screen space checkerboard


 / Published in: C
 

This, in the .frag shader will produce a screen-space checkboard.

  1. vec2 pos = mod(gl_FragCoord.xy,vec2(100));
  2. if ((pos.x > 50.0)&&(pos.y > 50.0)){
  3. gl_FragColor=vec4(1.0, 1.0, 1.0, 1.0);
  4. }
  5. if ((pos.x < 50.0)&&(pos.y < 50.0)){
  6. gl_FragColor=vec4(1.0, 1.0, 1.0, 1.0);
  7. }
  8. if ((pos.x < 50.0)&&(pos.y > 50.0)){
  9. gl_FragColor=vec4(0.0, 0.0, 0.0, 1.0);
  10. }
  11. if ((pos.x > 50.0)&&(pos.y < 50.0)){
  12. gl_FragColor=vec4(0.0, 0.0, 0.0, 1.0);
  13. }

Report this snippet  

You need to login to post a comment.