layers.shader 5.0 KB

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