Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.4 KiB

  1. //======= Copyright � 1996-2006, Valve Corporation, All rights reserved. ======
  2. // STATIC: "CONSTANTBASEDMORPH" "0..1"
  3. #include "common_vs_fxc.h"
  4. struct VS_INPUT
  5. {
  6. float4 vSrcCoord : TEXCOORD0;
  7. float vMorphWeightId : TEXCOORD1;
  8. };
  9. struct VS_OUTPUT
  10. {
  11. float4 vDestCoord : POSITION;
  12. float2 vSrcCoord : TEXCOORD0;
  13. float2 vSideSpeedCoord : TEXCOORD1;
  14. #if CONSTANTBASEDMORPH
  15. float4 vMorphWeights : TEXCOORD2;
  16. #else
  17. float2 vMorphWeightCoord : TEXCOORD2;
  18. #endif
  19. };
  20. #if !CONSTANTBASEDMORPH
  21. const float4 vMorphWeightSubrect : register( SHADER_SPECIFIC_CONST_0 );
  22. const float4 vMorphWeightDimensions : register( SHADER_SPECIFIC_CONST_1 );
  23. #endif
  24. VS_OUTPUT main( const VS_INPUT v )
  25. {
  26. VS_OUTPUT o = ( VS_OUTPUT )0;
  27. // FIXME: Want these to be in pixel centers!
  28. float2 projSpace = v.vSrcCoord.zw;
  29. projSpace *= 2.0f;
  30. projSpace -= 1.0f;
  31. projSpace.y *= -1.0f;
  32. o.vDestCoord = float4( projSpace.x, projSpace.y, 0.0f, 1.0f );
  33. o.vSrcCoord = v.vSrcCoord.xy;
  34. o.vSideSpeedCoord = v.vSrcCoord.xy;
  35. #if CONSTANTBASEDMORPH
  36. o.vMorphWeights = cFlexWeights[ v.vMorphWeightId ];
  37. #else
  38. float flColumn = floor( v.vMorphWeightId / vMorphWeightSubrect.w );
  39. o.vMorphWeightCoord.x = vMorphWeightSubrect.x + flColumn + 0.5f;
  40. o.vMorphWeightCoord.y = vMorphWeightSubrect.y + v.vMorphWeightId - flColumn * vMorphWeightSubrect.w + 0.5f;
  41. o.vMorphWeightCoord.xy /= vMorphWeightDimensions.xy;
  42. #endif
  43. return o;
  44. }