grid.shader 797 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. [shaders]
  2. vertex =
  3. uniform highp mat4 u_modelViewProjectionMatrix;
  4. attribute highp vec4 a_vertex;
  5. attribute lowp vec2 a_uvs;
  6. varying lowp vec2 v_uvs;
  7. void main()
  8. {
  9. gl_Position = u_modelViewProjectionMatrix * a_vertex;
  10. v_uvs = a_uvs;
  11. }
  12. fragment =
  13. uniform lowp vec4 u_gridColor0;
  14. uniform lowp vec4 u_gridColor1;
  15. varying lowp vec2 v_uvs;
  16. void main()
  17. {
  18. if (mod(floor(v_uvs.x / 10.0) - floor(v_uvs.y / 10.0), 2.0) < 1.0)
  19. gl_FragColor = u_gridColor0;
  20. else
  21. gl_FragColor = u_gridColor1;
  22. }
  23. [defaults]
  24. u_gridColor0 = [0.96, 0.96, 0.96, 1.0]
  25. u_gridColor1 = [0.8, 0.8, 0.8, 1.0]
  26. [bindings]
  27. u_modelViewProjectionMatrix = model_view_projection_matrix
  28. [attributes]
  29. a_vertex = vertex
  30. a_uvs = uv0