grid.shader 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. vertex41core =
  24. #version 410
  25. uniform highp mat4 u_modelViewProjectionMatrix;
  26. in highp vec4 a_vertex;
  27. in lowp vec2 a_uvs;
  28. out lowp vec2 v_uvs;
  29. void main()
  30. {
  31. gl_Position = u_modelViewProjectionMatrix * a_vertex;
  32. v_uvs = a_uvs;
  33. }
  34. fragment41core =
  35. #version 410
  36. uniform lowp vec4 u_gridColor0;
  37. uniform lowp vec4 u_gridColor1;
  38. in lowp vec2 v_uvs;
  39. out vec4 frag_color;
  40. void main()
  41. {
  42. if (mod(floor(v_uvs.x / 10.0) - floor(v_uvs.y / 10.0), 2.0) < 1.0)
  43. frag_color = u_gridColor0;
  44. else
  45. frag_color = u_gridColor1;
  46. }
  47. [defaults]
  48. u_gridColor0 = [0.96, 0.96, 0.96, 1.0]
  49. u_gridColor1 = [0.8, 0.8, 0.8, 1.0]
  50. [bindings]
  51. u_modelViewProjectionMatrix = model_view_projection_matrix
  52. [attributes]
  53. a_vertex = vertex
  54. a_uvs = uv0