layers.shader 4.5 KB

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