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.

66 lines
1.7 KiB

  1. // DYNAMIC: "DOWATERFOG" "0..1"
  2. #include "common_vs_fxc.h"
  3. static const int g_FogType = DOWATERFOG;
  4. const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 );
  5. const float4 cTextureJitter[2] : register( SHADER_SPECIFIC_CONST_2 );
  6. struct VS_INPUT
  7. {
  8. // This is all of the stuff that we ever use.
  9. float4 vPos : POSITION;
  10. float4 vColor : COLOR0;
  11. float4 vTexCoord0 : TEXCOORD0;
  12. };
  13. struct VS_OUTPUT
  14. {
  15. float4 projPos : POSITION;
  16. #if !defined( _X360 )
  17. float fog : FOG;
  18. #endif
  19. float2 texCoord0 : TEXCOORD0;
  20. float2 texCoord1 : TEXCOORD1;
  21. float2 texCoord2 : TEXCOORD2;
  22. float2 texCoord3 : TEXCOORD3;
  23. float2 texCoord4 : TEXCOORD4;
  24. HALF4 worldPos_projPosZ : TEXCOORD5;
  25. float4 shadowColor : COLOR0;
  26. float4 fogFactorW : COLOR1;
  27. };
  28. VS_OUTPUT main( const VS_INPUT v )
  29. {
  30. VS_OUTPUT o = ( VS_OUTPUT )0;
  31. float3 worldNormal, worldPos;
  32. float2 texCoord;
  33. worldPos = mul( v.vPos, cModel[0] );
  34. float4 projPos = mul( float4( worldPos, 1 ), cViewProj );
  35. o.projPos = projPos;
  36. projPos.z = dot( float4( worldPos, 1 ), cViewProjZ );
  37. // NOTE: CalcFog returns 1 for non-water fog, so it's ok to use fog
  38. // It returns the real fog for range fog, since we do vertex fog
  39. o.fogFactorW = CalcFog( worldPos, projPos, g_FogType );
  40. #if !defined( _X360 )
  41. o.fog = o.fogFactorW;
  42. #endif
  43. o.shadowColor = v.vColor;
  44. o.worldPos_projPosZ = float4( worldPos, projPos.z );
  45. texCoord.x = dot( v.vTexCoord0, cBaseTexCoordTransform[0] );
  46. texCoord.y = dot( v.vTexCoord0, cBaseTexCoordTransform[1] );
  47. o.texCoord0.xy = texCoord;
  48. o.texCoord1.xy = texCoord + cTextureJitter[0];
  49. o.texCoord2.xy = texCoord - cTextureJitter[0];
  50. o.texCoord3.xy = texCoord + cTextureJitter[1];
  51. o.texCoord4.xy = texCoord - cTextureJitter[1];
  52. return o;
  53. }