layers.shader 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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 and 9 are travel moves
  22. if ((a_line_type != 8.0) && (a_line_type != 9.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. if ((u_show_travel_moves == 0) && (v_line_type >= 7.5) && (v_line_type <= 9.5)) { // actually, 8 and 9
  44. // discard movements
  45. discard;
  46. }
  47. // support: 4, 5, 7, 10, 11 (prime tower)
  48. if ((u_show_helpers == 0) && (
  49. ((v_line_type >= 3.5) && (v_line_type <= 4.5)) ||
  50. ((v_line_type >= 4.5) && (v_line_type <= 5.5)) ||
  51. ((v_line_type >= 6.5) && (v_line_type <= 7.5)) ||
  52. ((v_line_type >= 9.5) && (v_line_type <= 10.5)) ||
  53. ((v_line_type >= 10.5) && (v_line_type <= 11.5))
  54. )) {
  55. discard;
  56. }
  57. // skin: 1, 2, 3
  58. if ((u_show_skin == 0) && (
  59. (v_line_type >= 0.5) && (v_line_type <= 3.5)
  60. )) {
  61. discard;
  62. }
  63. // infill:
  64. if ((u_show_infill == 0) && (v_line_type >= 5.5) && (v_line_type <= 6.5)) {
  65. // discard movements
  66. discard;
  67. }
  68. gl_FragColor = v_color;
  69. }
  70. vertex41core =
  71. #version 410
  72. uniform highp mat4 u_modelMatrix;
  73. uniform highp mat4 u_viewMatrix;
  74. uniform highp mat4 u_projectionMatrix;
  75. uniform lowp float u_active_extruder;
  76. uniform lowp float u_shade_factor;
  77. uniform highp int u_layer_view_type;
  78. in highp float a_extruder;
  79. in highp float a_line_type;
  80. in highp vec4 a_vertex;
  81. in lowp vec4 a_color;
  82. in lowp vec4 a_material_color;
  83. out lowp vec4 v_color;
  84. out float v_line_type;
  85. void main()
  86. {
  87. gl_Position = u_projectionMatrix * u_viewMatrix * u_modelMatrix * a_vertex;
  88. v_color = a_color;
  89. if ((a_line_type != 8) && (a_line_type != 9)) {
  90. v_color = (a_extruder == u_active_extruder) ? v_color : vec4(u_shade_factor * v_color.rgb, v_color.a);
  91. }
  92. v_line_type = a_line_type;
  93. }
  94. fragment41core =
  95. #version 410
  96. in lowp vec4 v_color;
  97. in float v_line_type;
  98. out vec4 frag_color;
  99. uniform int u_show_travel_moves;
  100. uniform int u_show_helpers;
  101. uniform int u_show_skin;
  102. uniform int u_show_infill;
  103. void main()
  104. {
  105. if ((u_show_travel_moves == 0) && (v_line_type >= 7.5) && (v_line_type <= 9.5)) { // actually, 8 and 9
  106. // discard movements
  107. discard;
  108. }
  109. // helpers: 4, 5, 7, 10
  110. if ((u_show_helpers == 0) && (
  111. ((v_line_type >= 3.5) && (v_line_type <= 4.5)) ||
  112. ((v_line_type >= 6.5) && (v_line_type <= 7.5)) ||
  113. ((v_line_type >= 9.5) && (v_line_type <= 10.5)) ||
  114. ((v_line_type >= 4.5) && (v_line_type <= 5.5))
  115. )) {
  116. discard;
  117. }
  118. // skin: 1, 2, 3
  119. if ((u_show_skin == 0) && (
  120. (v_line_type >= 0.5) && (v_line_type <= 3.5)
  121. )) {
  122. discard;
  123. }
  124. // infill:
  125. if ((u_show_infill == 0) && (v_line_type >= 5.5) && (v_line_type <= 6.5)) {
  126. // discard movements
  127. discard;
  128. }
  129. frag_color = v_color;
  130. }
  131. [defaults]
  132. u_active_extruder = 0.0
  133. u_shade_factor = 0.60
  134. u_layer_view_type = 0
  135. u_extruder_opacity = [1.0, 1.0, 1.0, 1.0]
  136. u_show_travel_moves = 0
  137. u_show_helpers = 1
  138. u_show_skin = 1
  139. u_show_infill = 1
  140. [bindings]
  141. u_modelMatrix = model_matrix
  142. u_viewMatrix = view_matrix
  143. u_projectionMatrix = projection_matrix
  144. [attributes]
  145. a_vertex = vertex
  146. a_color = color
  147. a_extruder = extruder
  148. a_line_type = line_type
  149. a_material_color = material_color