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.

65 lines
1.5 KiB

  1. // STATIC: "VERTEXCOLOR" "0..1"
  2. // STATIC: "SRGB" "0..1"
  3. // DYNAMIC: "DOWATERFOG" "0..1"
  4. #include "common_vs_fxc.h"
  5. static const int g_FogType = DOWATERFOG;
  6. static const bool g_bVertexColor = VERTEXCOLOR ? true : false;
  7. struct VS_INPUT
  8. {
  9. // This is all of the stuff that we ever use.
  10. float4 vPos : POSITION;
  11. float4 vColor : COLOR0;
  12. // make these float2's and stick the [n n 0 1] in the dot math.
  13. float4 vTexCoord0 : TEXCOORD0;
  14. };
  15. struct VS_OUTPUT
  16. {
  17. float4 projPos : POSITION; // Projection-space position
  18. #if !defined( _X360 )
  19. float fog : FOG;
  20. #endif
  21. HALF2 baseTexCoord : TEXCOORD0; // Base texture coordinate
  22. float4 color : TEXCOORD2; // Vertex color (from lighting or unlit)
  23. float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog
  24. };
  25. VS_OUTPUT main( const VS_INPUT v )
  26. {
  27. VS_OUTPUT o = ( VS_OUTPUT )0;
  28. float3 worldPos;
  29. worldPos = mul4x3( v.vPos, cModel[0] );
  30. // Transform into projection space
  31. float4 projPos = mul( float4( worldPos, 1 ), cViewProj );
  32. o.projPos = projPos;
  33. projPos.z = dot( float4( worldPos, 1 ), cViewProjZ );
  34. o.worldPos_projPosZ = float4( worldPos.xyz, projPos.z );
  35. #if !defined( _X360 )
  36. o.fog = CalcFog( worldPos, projPos, g_FogType );
  37. #endif
  38. if ( g_bVertexColor )
  39. {
  40. // Assume that this is unlitgeneric if you are using vertex color.
  41. #if SRGB
  42. o.color.rgba = GammaToLinear( v.vColor.rgba );
  43. #else
  44. o.color.rgba = v.vColor.rgba;
  45. #endif
  46. }
  47. // Base texture coordinates
  48. o.baseTexCoord.xy = v.vTexCoord0.xy;
  49. return o;
  50. }