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.

91 lines
2.5 KiB

  1. // STATIC: "VERTEXCOLOR" "0..1"
  2. // DYNAMIC: "COMPRESSED_VERTS" "0..1"
  3. // DYNAMIC: "DOWATERFOG" "0..1"
  4. // DYNAMIC: "SKINNING" "0..1"
  5. #include "common_vs_fxc.h"
  6. static const int g_FogType = DOWATERFOG;
  7. static const bool g_bSkinning = SKINNING ? true : false;
  8. const float4 cBaseTextureTransform[2] : register( SHADER_SPECIFIC_CONST_0 );
  9. const float4 cMaskTextureTransform[2] : register( SHADER_SPECIFIC_CONST_2 );
  10. const float4 cDetailTextureTransform[2] : register( SHADER_SPECIFIC_CONST_4 );
  11. const float4 g_vVertexColor : register( SHADER_SPECIFIC_CONST_6 );
  12. struct VS_INPUT
  13. {
  14. float4 vPos : POSITION;
  15. float4 vBoneWeights : BLENDWEIGHT;
  16. float4 vBoneIndices : BLENDINDICES;
  17. float4 vNormal : NORMAL;
  18. #if VERTEXCOLOR
  19. float4 vColor : COLOR0;
  20. #endif
  21. float4 vTexCoord0 : TEXCOORD0;
  22. };
  23. struct VS_OUTPUT
  24. {
  25. float4 vProjPos : POSITION;
  26. float2 vTexCoord0 : TEXCOORD0;
  27. float2 vTexCoord1 : TEXCOORD1;
  28. float2 vTexCoord2 : TEXCOORD2;
  29. float2 vTexCoord3 : TEXCOORD3;
  30. float4 vColor : COLOR0;
  31. float4 fogFactorW : COLOR1;
  32. #if !defined( _X360 )
  33. float fog : FOG;
  34. #endif
  35. float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog
  36. };
  37. VS_OUTPUT main( const VS_INPUT v )
  38. {
  39. VS_OUTPUT o = ( VS_OUTPUT )0;
  40. float3 worldPos;
  41. float3 worldNormal;
  42. //------------------------------------------------------------------------------
  43. // Vertex blending
  44. //------------------------------------------------------------------------------
  45. SkinPosition( g_bSkinning, v.vPos, v.vBoneWeights, v.vBoneIndices, worldPos );
  46. float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj );
  47. o.vProjPos = vProjPos;
  48. vProjPos = dot( float4( worldPos, 1 ), cViewProjZ );
  49. o.worldPos_projPosZ = float4( worldPos.xyz, vProjPos.z );
  50. //------------------------------------------------------------------------------
  51. // Fog
  52. //------------------------------------------------------------------------------
  53. o.fogFactorW = CalcFog( worldPos, vProjPos, g_FogType );
  54. #if !defined( _X360 )
  55. o.fog = o.fogFactorW;
  56. #endif
  57. //------------------------------------------------------------------------------
  58. // Texture coord transforms
  59. //------------------------------------------------------------------------------
  60. o.vTexCoord0 = mul( v.vTexCoord0, (float2x4)cBaseTextureTransform );
  61. o.vTexCoord3 = mul( v.vTexCoord0, (float2x4)cDetailTextureTransform );
  62. o.vColor = cModulationColor;
  63. #if VERTEXCOLOR
  64. // 0 or 1 for g_vVertexColor.x, eliminating a bool
  65. o.vColor = lerp( o.vColor, o.vColor * v.vColor, g_vVertexColor.x );
  66. #endif
  67. return o;
  68. }