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.

79 lines
1.9 KiB

  1. // DYNAMIC: "DOWATERFOG" "0..1"
  2. #include "common_vs_fxc.h"
  3. static const int g_FogType = DOWATERFOG;
  4. struct VS_INPUT
  5. {
  6. float4 vPos : POSITION;
  7. float2 vTexCoord0 : TEXCOORD0;
  8. float2 vTexCoord1 : TEXCOORD1;
  9. float4 directionalLightColor : COLOR0;
  10. float3 vTangentS : TANGENT;
  11. float3 vTangentT : BINORMAL;
  12. };
  13. struct VS_OUTPUT
  14. {
  15. float4 vProjPos : POSITION;
  16. float2 vTexCoord0 : TEXCOORD0;
  17. float2 vTexCoord1 : TEXCOORD1;
  18. float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog
  19. float4 directionalLightColor : COLOR0;
  20. float4 fogFactorW : COLOR1;
  21. #if !defined( _X360 )
  22. float fog : FOG;
  23. #endif
  24. };
  25. VS_OUTPUT main( const VS_INPUT v )
  26. {
  27. VS_OUTPUT o = ( VS_OUTPUT )0;
  28. float3 worldPos;
  29. worldPos = mul( v.vPos, cModel[0] );
  30. float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj );
  31. o.vProjPos = vProjPos;
  32. vProjPos.z = dot( float4( worldPos, 1 ), cViewProjZ );
  33. o.worldPos_projPosZ = float4( worldPos.xyz, vProjPos.z );
  34. o.fogFactorW = CalcFog( worldPos, vProjPos, g_FogType );
  35. #if !defined( _X360 )
  36. o.fog = o.fogFactorW;
  37. #endif
  38. //------------------------------------------------------------------------------
  39. // Setup the tangent space
  40. //------------------------------------------------------------------------------
  41. // Get S crossed with T (call it R)
  42. float3 r = cross( v.vTangentS, v.vTangentT );
  43. // Normalize S (into s)
  44. float3 s = normalize( v.vTangentS );
  45. // Normalize R (into r)
  46. r = normalize( r );
  47. // Regenerate T (into t)
  48. float3 t = cross( r, v.vTangentS );
  49. //------------------------------------------------------------------------------
  50. // Copy texcoords for the normal map and base texture
  51. //------------------------------------------------------------------------------
  52. o.vTexCoord0 = v.vTexCoord0;
  53. o.vTexCoord1 = v.vTexCoord1;
  54. // Pass the dirlight color through
  55. o.directionalLightColor = v.directionalLightColor;
  56. return o;
  57. }