layers_shadow.shader 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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 = vec4(0.4, 0.4, 0.4, 0.9); // default color for not current layer;
  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. // 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. // discard movements
  48. discard;
  49. }
  50. // support: 4, 5, 7, 10, 11
  51. if ((u_show_helpers == 0) && (
  52. ((v_line_type >= 3.5) && (v_line_type <= 4.5)) ||
  53. ((v_line_type >= 6.5) && (v_line_type <= 7.5)) ||
  54. ((v_line_type >= 9.5) && (v_line_type <= 10.5)) ||
  55. ((v_line_type >= 4.5) && (v_line_type <= 5.5)) ||
  56. ((v_line_type >= 10.5) && (v_line_type <= 11.5))
  57. ))
  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. {
  70. // discard movements
  71. discard;
  72. }
  73. gl_FragColor = v_color;
  74. }
  75. vertex41core =
  76. #version 410
  77. uniform highp mat4 u_modelMatrix;
  78. uniform highp mat4 u_viewMatrix;
  79. uniform highp mat4 u_projectionMatrix;
  80. uniform lowp float u_active_extruder;
  81. uniform lowp float u_shade_factor;
  82. uniform highp int u_layer_view_type;
  83. in highp float a_extruder;
  84. in highp float a_line_type;
  85. in highp vec4 a_vertex;
  86. in lowp vec4 a_color;
  87. in lowp vec4 a_material_color;
  88. out lowp vec4 v_color;
  89. out float v_line_type;
  90. void main()
  91. {
  92. gl_Position = u_projectionMatrix * u_viewMatrix * u_modelMatrix * a_vertex;
  93. v_color = vec4(0.4, 0.4, 0.4, 0.9); // default color for not current layer
  94. // if ((a_line_type != 8) && (a_line_type != 9)) {
  95. // v_color = (a_extruder == u_active_extruder) ? v_color : vec4(u_shade_factor * v_color.rgb, v_color.a);
  96. // }
  97. v_line_type = a_line_type;
  98. }
  99. fragment41core =
  100. #version 410
  101. in lowp vec4 v_color;
  102. in float v_line_type;
  103. out vec4 frag_color;
  104. uniform int u_show_travel_moves;
  105. uniform int u_show_helpers;
  106. uniform int u_show_skin;
  107. uniform int u_show_infill;
  108. void main()
  109. {
  110. // travel moves: 8, 9 or 12
  111. if ((u_show_travel_moves == 0) &&
  112. (((v_line_type >= 7.5) && (v_line_type <= 9.5)) ||
  113. ((v_line_type >= 11.5) && (v_line_type <= 12.5))))
  114. // discard movements
  115. discard;
  116. }
  117. // helpers: 4, 5, 7, 10, 11
  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. ((v_line_type >= 10.5) && (v_line_type <= 11.5))
  124. )) {
  125. discard;
  126. }
  127. // skin: 1, 2, 3
  128. if ((u_show_skin == 0) && (
  129. (v_line_type >= 0.5) && (v_line_type <= 3.5)
  130. )) {
  131. discard;
  132. }
  133. // infill:
  134. if ((u_show_infill == 0) && (v_line_type >= 5.5) && (v_line_type <= 6.5)) {
  135. // discard movements
  136. discard;
  137. }
  138. frag_color = v_color;
  139. }
  140. [defaults]
  141. u_active_extruder = 0.0
  142. u_shade_factor = 0.60
  143. u_layer_view_type = 0
  144. 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]]
  145. u_show_travel_moves = 0
  146. u_show_helpers = 1
  147. u_show_skin = 1
  148. u_show_infill = 1
  149. [bindings]
  150. u_modelMatrix = model_matrix
  151. u_viewMatrix = view_matrix
  152. u_projectionMatrix = projection_matrix
  153. [attributes]
  154. a_vertex = vertex
  155. a_color = color
  156. a_extruder = extruder
  157. a_line_type = line_type
  158. a_material_color = material_color