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.

83 lines
2.0 KiB

  1. // STATIC: "ONLY_PROJECT_POSITION" "0..1" [XBOX]
  2. // STATIC: "ONLY_PROJECT_POSITION" "0..0" [PC]
  3. // STATIC: "COLOR_DEPTH" "0..1"
  4. // DYNAMIC: "COMPRESSED_VERTS" "0..1"
  5. // DYNAMIC: "SKINNING" "0..1"
  6. // DYNAMIC: "MORPHING" "0..1" [vs30]
  7. #include "common_vs_fxc.h"
  8. static const bool g_bSkinning = SKINNING ? true : false;
  9. #ifdef SHADER_MODEL_VS_3_0
  10. // NOTE: cMorphTargetTextureDim.xy = target dimensions,
  11. // cMorphTargetTextureDim.z = 4tuples/morph
  12. const float3 cMorphTargetTextureDim : register( SHADER_SPECIFIC_CONST_6 );
  13. const float4 cMorphSubrect : register( SHADER_SPECIFIC_CONST_7 );
  14. sampler2D morphSampler : register( D3DVERTEXTEXTURESAMPLER0, s0 );
  15. #endif
  16. struct VS_INPUT
  17. {
  18. float4 vPos : POSITION;
  19. float2 vTexCoord : TEXCOORD0;
  20. float4 vBoneWeights : BLENDWEIGHT;
  21. float4 vBoneIndices : BLENDINDICES;
  22. // Position delta stream
  23. float3 vPosFlex : POSITION1;
  24. #ifdef SHADER_MODEL_VS_3_0
  25. float vVertexID : POSITION2;
  26. #endif
  27. };
  28. struct VS_OUTPUT
  29. {
  30. float4 vProjPos : POSITION;
  31. #if (ONLY_PROJECT_POSITION == 0) //360 sometimes runs without the pixel shader component, but has to patch this output if it does.
  32. float2 texCoord : TEXCOORD0;
  33. #endif
  34. #if COLOR_DEPTH
  35. float4 vWorldPos_projPosZ : TEXCOORD1;
  36. #endif
  37. };
  38. VS_OUTPUT main( const VS_INPUT v )
  39. {
  40. VS_OUTPUT o = ( VS_OUTPUT )0;
  41. float3 vWorldPos;
  42. float4 vPosition = v.vPos;
  43. #if !defined( SHADER_MODEL_VS_3_0 ) || !MORPHING
  44. ApplyMorph( v.vPosFlex, vPosition.xyz );
  45. #else
  46. ApplyMorph( morphSampler, cMorphTargetTextureDim, cMorphSubrect,
  47. v.vVertexID, float3(0, 0, 0), vPosition.xyz );
  48. #endif
  49. SkinPosition( g_bSkinning, vPosition, v.vBoneWeights, v.vBoneIndices, vWorldPos );
  50. float4 vProjPos = mul( float4( vWorldPos, 1.0f ), cViewProj );
  51. o.vProjPos = vProjPos;
  52. #if (ONLY_PROJECT_POSITION == 0)
  53. o.texCoord = v.vTexCoord;
  54. #endif
  55. #if ( COLOR_DEPTH && !ONLY_PROJECT_POSITION )
  56. o.vWorldPos_projPosZ.z = vProjPos.z;
  57. o.vWorldPos_projPosZ.w = vProjPos.w;
  58. #endif
  59. return o;
  60. }