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.

73 lines
2.1 KiB

  1. // DYNAMIC: "COMPRESSED_VERTS" "0..1"
  2. // DYNAMIC: "DOWATERFOG" "0..1"
  3. // DYNAMIC: "SKINNING" "0..1"
  4. #include "common_vs_fxc.h"
  5. static const bool g_bSkinning = SKINNING ? true : false;
  6. static const int g_FogType = DOWATERFOG;
  7. const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 );
  8. const float4 cBaseTexCoordTransform2[2] : register( SHADER_SPECIFIC_CONST_2 );
  9. struct VS_INPUT
  10. {
  11. float4 vPos : POSITION;
  12. float4 vBoneWeights : BLENDWEIGHT;
  13. float4 vBoneIndices : BLENDINDICES;
  14. // make these float2's and stick the [n n 0 1] in the dot math.
  15. float4 vTexCoord0 : TEXCOORD0;
  16. };
  17. struct VS_OUTPUT
  18. {
  19. float4 projPos : POSITION; // Projection-space position
  20. #if !defined( _X360 )
  21. float fog : FOG;
  22. #endif
  23. HALF2 baseTexCoord : TEXCOORD0; // Base texture coordinate
  24. HALF2 baseTexCoord2 : TEXCOORD1; // Base texture coordinate
  25. float4 worldPos_projPosZ : TEXCOORD7; // Necessary for water fog dest alpha
  26. float4 vColor : COLOR0;
  27. float4 fogFactorW : COLOR1;
  28. };
  29. VS_OUTPUT main( const VS_INPUT v )
  30. {
  31. VS_OUTPUT o = ( VS_OUTPUT )0;
  32. float4 vPosition = v.vPos;
  33. // Perform skinning
  34. float3 worldNormal, worldPos;
  35. SkinPosition(
  36. g_bSkinning,
  37. vPosition,
  38. v.vBoneWeights, v.vBoneIndices,
  39. worldPos );
  40. // Transform into projection space
  41. float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj );
  42. o.projPos = vProjPos;
  43. vProjPos.z = dot( float4( worldPos, 1 ), cViewProjZ );
  44. o.fogFactorW.w = CalcFog( worldPos, vProjPos, g_FogType );
  45. #if !defined( _X360 )
  46. o.fog = o.fogFactorW.w;
  47. #endif
  48. // Needed for water fog alpha;
  49. // FIXME: we shouldn't have to compute this all thie time.
  50. o.worldPos_projPosZ = float4( worldPos.xyz, vProjPos.z );
  51. // Base texture coordinates
  52. o.baseTexCoord.x = dot( v.vTexCoord0, cBaseTexCoordTransform[0] );
  53. o.baseTexCoord.y = dot( v.vTexCoord0, cBaseTexCoordTransform[1] );
  54. // Base texture coordinates
  55. o.baseTexCoord2.x = dot( v.vTexCoord0, cBaseTexCoordTransform2[0] );
  56. o.baseTexCoord2.y = dot( v.vTexCoord0, cBaseTexCoordTransform2[1] );
  57. o.vColor = cModulationColor;
  58. return o;
  59. }