GLSL screen space checkerboard


/ Published in: C
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.