layers_shadow.shader 5.0 KB

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