VertexInput.bslinc 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #define LIGHTING_DATA 1
  2. #include "$ENGINE$\VertexCommon.bslinc"
  3. mixin VertexInput
  4. {
  5. mixin VertexCommon;
  6. #ifndef NO_ANIMATION
  7. variations
  8. {
  9. SKINNED = { false, true };
  10. MORPH = { false, true };
  11. };
  12. #endif
  13. code
  14. {
  15. float4 getVertexWorldPosition(VertexInput input, VertexIntermediate intermediate)
  16. {
  17. #if MORPH
  18. float4 position = float4(input.position + input.deltaPosition, 1.0f);
  19. #else
  20. float4 position = float4(input.position, 1.0f);
  21. #endif
  22. #if SKINNED
  23. position = float4(mul(intermediate.blendMatrix, position), 1.0f);
  24. #endif
  25. return mul(gMatWorld, position);
  26. }
  27. float4 getVertexWorldPosition(VertexInput_PO input)
  28. {
  29. #if MORPH
  30. float4 position = float4(input.position + input.deltaPosition, 1.0f);
  31. #else
  32. float4 position = float4(input.position, 1.0f);
  33. #endif
  34. #if SKINNED
  35. float3x4 blendMatrix = getBlendMatrix(input.blendWeights, input.blendIndices);
  36. position = float4(mul(blendMatrix, position), 1.0f);
  37. #endif
  38. return mul(gMatWorld, position);
  39. }
  40. // Note: This can be made optional if velocity buffer isn't required
  41. float4 getPrevVertexWorldPosition(VertexInput input, VertexIntermediate intermediate)
  42. {
  43. #if MORPH
  44. float4 position = float4(input.position + input.deltaPosition, 1.0f);
  45. #else
  46. float4 position = float4(input.position, 1.0f);
  47. #endif
  48. #if SKINNED
  49. #if PREV_CLIP_POS
  50. position = float4(mul(intermediate.prevBlendMatrix, position), 1.0f);
  51. #endif
  52. #endif
  53. return mul(gMatPrevWorld, position);
  54. }
  55. };
  56. };