SelectionBase.bslinc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. mixin
  2. #ifdef USE_BLEND_SHAPES
  3. #ifdef USE_SKELETON
  4. SelectionSkinnedMorph
  5. #else
  6. SelectionMorph
  7. #endif
  8. #else
  9. #ifdef USE_SKELETON
  10. SelectionSkinned
  11. #else
  12. Selection
  13. #endif
  14. #endif
  15. {
  16. raster
  17. {
  18. fill = wire;
  19. bias = 0.00001f;
  20. };
  21. blend
  22. {
  23. target
  24. {
  25. enabled = true;
  26. color = { srcA, srcIA, add };
  27. };
  28. };
  29. code
  30. {
  31. struct VertexInput
  32. {
  33. float3 position : POSITION;
  34. #ifdef USE_SKELETON
  35. uint4 blendIndices : BLENDINDICES;
  36. float4 blendWeights : BLENDWEIGHT;
  37. #endif
  38. #ifdef USE_BLEND_SHAPES
  39. float3 deltaPosition : POSITION1;
  40. float4 deltaNormal : NORMAL1;
  41. #endif
  42. };
  43. cbuffer VertParams
  44. {
  45. float4x4 matWorldViewProj;
  46. };
  47. #ifdef USE_SKELETON
  48. StructuredBuffer<float4> boneMatrices;
  49. float3x4 getBoneMatrix(uint idx)
  50. {
  51. float4 row0 = boneMatrices[idx * 3 + 0];
  52. float4 row1 = boneMatrices[idx * 3 + 1];
  53. float4 row2 = boneMatrices[idx * 3 + 2];
  54. return float3x4(row0, row1, row2);
  55. }
  56. float3x4 getBlendMatrix(VertexInput input)
  57. {
  58. float3x4 result = input.blendWeights.x * getBoneMatrix(input.blendIndices.x);
  59. result += input.blendWeights.y * getBoneMatrix(input.blendIndices.y);
  60. result += input.blendWeights.z * getBoneMatrix(input.blendIndices.z);
  61. result += input.blendWeights.w * getBoneMatrix(input.blendIndices.w);
  62. return result;
  63. }
  64. #endif
  65. void vsmain(VertexInput input, out float4 oPosition : SV_Position)
  66. {
  67. #ifdef USE_BLEND_SHAPES
  68. float4 position = float4(input.position + input.deltaPosition, 1.0f);
  69. #else
  70. float4 position = float4(input.position, 1.0f);
  71. #endif
  72. #ifdef USE_SKELETON
  73. float3x4 blendMatrix = getBlendMatrix(input);
  74. position = float4(mul(blendMatrix, position), 1.0f);
  75. #endif
  76. oPosition = mul(matWorldViewProj, position);
  77. }
  78. cbuffer FragParams
  79. {
  80. float4 selColor;
  81. };
  82. float4 fsmain(in float4 inPos : SV_Position) : SV_Target
  83. {
  84. return selColor;
  85. }
  86. };
  87. };