blend_shape.glsl 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /* clang-format off */
  2. [vertex]
  3. /*
  4. from VisualServer:
  5. ARRAY_VERTEX=0,
  6. ARRAY_NORMAL=1,
  7. ARRAY_TANGENT=2,
  8. ARRAY_COLOR=3,
  9. ARRAY_TEX_UV=4,
  10. ARRAY_TEX_UV2=5,
  11. ARRAY_BONES=6,
  12. ARRAY_WEIGHTS=7,
  13. ARRAY_INDEX=8,
  14. */
  15. #ifdef USE_2D_VERTEX
  16. #define VFORMAT vec2
  17. #else
  18. #define VFORMAT vec3
  19. #endif
  20. /* INPUT ATTRIBS */
  21. layout(location = 0) in highp VFORMAT vertex_attrib;
  22. /* clang-format on */
  23. layout(location = 1) in vec3 normal_attrib;
  24. #ifdef ENABLE_TANGENT
  25. layout(location = 2) in vec4 tangent_attrib;
  26. #endif
  27. #ifdef ENABLE_COLOR
  28. layout(location = 3) in vec4 color_attrib;
  29. #endif
  30. #ifdef ENABLE_UV
  31. layout(location = 4) in vec2 uv_attrib;
  32. #endif
  33. #ifdef ENABLE_UV2
  34. layout(location = 5) in vec2 uv2_attrib;
  35. #endif
  36. #ifdef ENABLE_SKELETON
  37. layout(location = 6) in ivec4 bone_attrib;
  38. layout(location = 7) in vec4 weight_attrib;
  39. #endif
  40. /* BLEND ATTRIBS */
  41. #ifdef ENABLE_BLEND
  42. layout(location = 8) in highp VFORMAT vertex_attrib_blend;
  43. layout(location = 9) in vec3 normal_attrib_blend;
  44. #ifdef ENABLE_TANGENT
  45. layout(location = 10) in vec4 tangent_attrib_blend;
  46. #endif
  47. #ifdef ENABLE_COLOR
  48. layout(location = 11) in vec4 color_attrib_blend;
  49. #endif
  50. #ifdef ENABLE_UV
  51. layout(location = 12) in vec2 uv_attrib_blend;
  52. #endif
  53. #ifdef ENABLE_UV2
  54. layout(location = 13) in vec2 uv2_attrib_blend;
  55. #endif
  56. #ifdef ENABLE_SKELETON
  57. layout(location = 14) in ivec4 bone_attrib_blend;
  58. layout(location = 15) in vec4 weight_attrib_blend;
  59. #endif
  60. #endif
  61. /* OUTPUTS */
  62. out VFORMAT vertex_out; //tfb:
  63. #ifdef ENABLE_NORMAL
  64. out vec3 normal_out; //tfb:ENABLE_NORMAL
  65. #endif
  66. #ifdef ENABLE_TANGENT
  67. out vec4 tangent_out; //tfb:ENABLE_TANGENT
  68. #endif
  69. #ifdef ENABLE_COLOR
  70. out vec4 color_out; //tfb:ENABLE_COLOR
  71. #endif
  72. #ifdef ENABLE_UV
  73. out vec2 uv_out; //tfb:ENABLE_UV
  74. #endif
  75. #ifdef ENABLE_UV2
  76. out vec2 uv2_out; //tfb:ENABLE_UV2
  77. #endif
  78. #ifdef ENABLE_SKELETON
  79. out ivec4 bone_out; //tfb:ENABLE_SKELETON
  80. out vec4 weight_out; //tfb:ENABLE_SKELETON
  81. #endif
  82. uniform float blend_amount;
  83. void main() {
  84. #ifdef ENABLE_BLEND
  85. vertex_out = vertex_attrib_blend + vertex_attrib * blend_amount;
  86. #ifdef ENABLE_NORMAL
  87. normal_out = normal_attrib_blend + normal_attrib * blend_amount;
  88. #endif
  89. #ifdef ENABLE_TANGENT
  90. tangent_out.xyz = tangent_attrib_blend.xyz + tangent_attrib.xyz * blend_amount;
  91. tangent_out.w = tangent_attrib_blend.w; //just copy, no point in blending his
  92. #endif
  93. #ifdef ENABLE_COLOR
  94. color_out = color_attrib_blend + color_attrib * blend_amount;
  95. #endif
  96. #ifdef ENABLE_UV
  97. uv_out = uv_attrib_blend + uv_attrib * blend_amount;
  98. #endif
  99. #ifdef ENABLE_UV2
  100. uv2_out = uv2_attrib_blend + uv2_attrib * blend_amount;
  101. #endif
  102. #ifdef ENABLE_SKELETON
  103. bone_out = bone_attrib_blend;
  104. weight_out = weight_attrib_blend + weight_attrib * blend_amount;
  105. #endif
  106. #else //ENABLE_BLEND
  107. vertex_out = vertex_attrib * blend_amount;
  108. #ifdef ENABLE_NORMAL
  109. normal_out = normal_attrib * blend_amount;
  110. #endif
  111. #ifdef ENABLE_TANGENT
  112. tangent_out.xyz = tangent_attrib.xyz * blend_amount;
  113. tangent_out.w = tangent_attrib.w; //just copy, no point in blending his
  114. #endif
  115. #ifdef ENABLE_COLOR
  116. color_out = color_attrib * blend_amount;
  117. #endif
  118. #ifdef ENABLE_UV
  119. uv_out = uv_attrib * blend_amount;
  120. #endif
  121. #ifdef ENABLE_UV2
  122. uv2_out = uv2_attrib * blend_amount;
  123. #endif
  124. #ifdef ENABLE_SKELETON
  125. bone_out = bone_attrib;
  126. weight_out = weight_attrib * blend_amount;
  127. #endif
  128. #endif
  129. gl_Position = vec4(0.0);
  130. }
  131. /* clang-format off */
  132. [fragment]
  133. void main() {
  134. }
  135. /* clang-format on */