layers.shader 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. [shaders]
  2. vertex =
  3. uniform highp mat4 u_modelViewProjectionMatrix;
  4. uniform lowp float u_active_extruder;
  5. uniform lowp float u_shade_factor;
  6. uniform highp int u_layer_view_type;
  7. attribute highp float a_extruder;
  8. attribute highp float a_line_type;
  9. attribute highp vec4 a_vertex;
  10. attribute lowp vec4 a_color;
  11. attribute lowp vec4 a_material_color;
  12. varying lowp vec4 v_color;
  13. varying float v_line_type;
  14. void main()
  15. {
  16. gl_Position = u_modelViewProjectionMatrix * a_vertex;
  17. // shade the color depending on the extruder index
  18. v_color = a_color;
  19. // 8 and 9 are travel moves
  20. if ((a_line_type != 8.0) && (a_line_type != 9.0)) {
  21. v_color = (a_extruder == u_active_extruder) ? v_color : vec4(u_shade_factor * v_color.rgb, v_color.a);
  22. }
  23. v_line_type = a_line_type;
  24. }
  25. fragment =
  26. #ifdef GL_ES
  27. #ifdef GL_FRAGMENT_PRECISION_HIGH
  28. precision highp float;
  29. #else
  30. precision mediump float;
  31. #endif // GL_FRAGMENT_PRECISION_HIGH
  32. #endif // GL_ES
  33. varying lowp vec4 v_color;
  34. varying float v_line_type;
  35. uniform int u_show_travel_moves;
  36. uniform int u_show_helpers;
  37. uniform int u_show_skin;
  38. uniform int u_show_infill;
  39. void main()
  40. {
  41. if ((u_show_travel_moves == 0) && (v_line_type >= 7.5) && (v_line_type <= 9.5)) { // actually, 8 and 9
  42. // discard movements
  43. discard;
  44. }
  45. // support: 4, 5, 7, 10
  46. if ((u_show_helpers == 0) && (
  47. ((v_line_type >= 3.5) && (v_line_type <= 4.5)) ||
  48. ((v_line_type >= 6.5) && (v_line_type <= 7.5)) ||
  49. ((v_line_type >= 9.5) && (v_line_type <= 10.5)) ||
  50. ((v_line_type >= 4.5) && (v_line_type <= 5.5))
  51. )) {
  52. discard;
  53. }
  54. // skin: 1, 2, 3
  55. if ((u_show_skin == 0) && (
  56. (v_line_type >= 0.5) && (v_line_type <= 3.5)
  57. )) {
  58. discard;
  59. }
  60. // infill:
  61. if ((u_show_infill == 0) && (v_line_type >= 5.5) && (v_line_type <= 6.5)) {
  62. // discard movements
  63. discard;
  64. }
  65. gl_FragColor = v_color;
  66. }
  67. vertex41core =
  68. #version 410
  69. uniform highp mat4 u_modelViewProjectionMatrix;
  70. uniform lowp float u_active_extruder;
  71. uniform lowp float u_shade_factor;
  72. uniform highp int u_layer_view_type;
  73. in highp float a_extruder;
  74. in highp float a_line_type;
  75. in highp vec4 a_vertex;
  76. in lowp vec4 a_color;
  77. in lowp vec4 a_material_color;
  78. out lowp vec4 v_color;
  79. out float v_line_type;
  80. void main()
  81. {
  82. gl_Position = u_modelViewProjectionMatrix * a_vertex;
  83. v_color = a_color;
  84. if ((a_line_type != 8) && (a_line_type != 9)) {
  85. v_color = (a_extruder == u_active_extruder) ? v_color : vec4(u_shade_factor * v_color.rgb, v_color.a);
  86. }
  87. v_line_type = a_line_type;
  88. }
  89. fragment41core =
  90. #version 410
  91. in lowp vec4 v_color;
  92. in float v_line_type;
  93. out vec4 frag_color;
  94. uniform int u_show_travel_moves;
  95. uniform int u_show_helpers;
  96. uniform int u_show_skin;
  97. uniform int u_show_infill;
  98. void main()
  99. {
  100. if ((u_show_travel_moves == 0) && (v_line_type >= 7.5) && (v_line_type <= 9.5)) { // actually, 8 and 9
  101. // discard movements
  102. discard;
  103. }
  104. // helpers: 4, 5, 7, 10
  105. if ((u_show_helpers == 0) && (
  106. ((v_line_type >= 3.5) && (v_line_type <= 4.5)) ||
  107. ((v_line_type >= 6.5) && (v_line_type <= 7.5)) ||
  108. ((v_line_type >= 9.5) && (v_line_type <= 10.5)) ||
  109. ((v_line_type >= 4.5) && (v_line_type <= 5.5))
  110. )) {
  111. discard;
  112. }
  113. // skin: 1, 2, 3
  114. if ((u_show_skin == 0) && (
  115. (v_line_type >= 0.5) && (v_line_type <= 3.5)
  116. )) {
  117. discard;
  118. }
  119. // infill:
  120. if ((u_show_infill == 0) && (v_line_type >= 5.5) && (v_line_type <= 6.5)) {
  121. // discard movements
  122. discard;
  123. }
  124. frag_color = v_color;
  125. }
  126. [defaults]
  127. u_active_extruder = 0.0
  128. u_shade_factor = 0.60
  129. u_layer_view_type = 0
  130. u_extruder_opacity = [1.0, 1.0, 1.0, 1.0]
  131. u_show_travel_moves = 0
  132. u_show_helpers = 1
  133. u_show_skin = 1
  134. u_show_infill = 1
  135. [bindings]
  136. u_modelViewProjectionMatrix = model_view_projection_matrix
  137. [attributes]
  138. a_vertex = vertex
  139. a_color = color
  140. a_extruder = extruder
  141. a_line_type = line_type
  142. a_material_color = material_color