layers_shadow.shader 4.4 KB

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