layers_shadow.shader 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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 = vec4(0.4, 0.4, 0.4, 0.9); // default color for not current layer;
  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))
  42. { // actually, 8 and 9
  43. // discard movements
  44. discard;
  45. }
  46. // support: 4, 5, 7, 10, 11
  47. if ((u_show_helpers == 0) && (
  48. ((v_line_type >= 3.5) && (v_line_type <= 4.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 >= 4.5) && (v_line_type <= 5.5)) ||
  52. ((v_line_type >= 10.5) && (v_line_type <= 11.5))
  53. ))
  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. {
  66. // discard movements
  67. discard;
  68. }
  69. gl_FragColor = v_color;
  70. }
  71. vertex41core =
  72. #version 410
  73. uniform highp mat4 u_modelViewProjectionMatrix;
  74. uniform lowp float u_active_extruder;
  75. uniform lowp float u_shade_factor;
  76. uniform highp int u_layer_view_type;
  77. in highp float a_extruder;
  78. in highp float a_line_type;
  79. in highp vec4 a_vertex;
  80. in lowp vec4 a_color;
  81. in lowp vec4 a_material_color;
  82. out lowp vec4 v_color;
  83. out float v_line_type;
  84. void main()
  85. {
  86. gl_Position = u_modelViewProjectionMatrix * a_vertex;
  87. v_color = vec4(0.4, 0.4, 0.4, 0.9); // default color for not current layer
  88. // if ((a_line_type != 8) && (a_line_type != 9)) {
  89. // v_color = (a_extruder == u_active_extruder) ? v_color : vec4(u_shade_factor * v_color.rgb, v_color.a);
  90. // }
  91. v_line_type = a_line_type;
  92. }
  93. fragment41core =
  94. #version 410
  95. in lowp vec4 v_color;
  96. in float v_line_type;
  97. out vec4 frag_color;
  98. uniform int u_show_travel_moves;
  99. uniform int u_show_helpers;
  100. uniform int u_show_skin;
  101. uniform int u_show_infill;
  102. void main()
  103. {
  104. if ((u_show_travel_moves == 0) && (v_line_type >= 7.5) && (v_line_type <= 9.5)) { // actually, 8 and 9
  105. // discard movements
  106. discard;
  107. }
  108. // helpers: 4, 5, 7, 10, 11
  109. if ((u_show_helpers == 0) && (
  110. ((v_line_type >= 3.5) && (v_line_type <= 4.5)) ||
  111. ((v_line_type >= 6.5) && (v_line_type <= 7.5)) ||
  112. ((v_line_type >= 9.5) && (v_line_type <= 10.5)) ||
  113. ((v_line_type >= 4.5) && (v_line_type <= 5.5)) ||
  114. ((v_line_type >= 10.5) && (v_line_type <= 11.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_modelViewProjectionMatrix = model_view_projection_matrix
  142. [attributes]
  143. a_vertex = vertex
  144. a_color = color
  145. a_extruder = extruder
  146. a_line_type = line_type
  147. a_material_color = material_color