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.

70 lines
2.2 KiB

  1. // DYNAMIC: "DOWATERFOG" "0..1"
  2. // STATIC: "ENVMAP_MASK" "0..1"
  3. #include "common_vs_fxc.h"
  4. static const int g_FogType = DOWATERFOG;
  5. static const bool g_UseSeparateEnvmapMask = ENVMAP_MASK;
  6. const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 );
  7. const float4 cDetailTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_2 );
  8. struct VS_INPUT
  9. {
  10. float3 vPos : POSITION;
  11. float4 vNormal : NORMAL;
  12. float2 vBaseTexCoord : TEXCOORD0;
  13. float2 vLightmapTexCoord : TEXCOORD1;
  14. float2 vDetailTexCoord : TEXCOORD2;
  15. };
  16. struct VS_OUTPUT
  17. {
  18. float4 projPos : POSITION;
  19. #if !defined( _X360 )
  20. float fog : FOG;
  21. #endif
  22. float2 baseTexCoord : TEXCOORD0;
  23. float2 detailTexCoord : TEXCOORD1;
  24. float2 lightmapTexCoord : TEXCOORD2;
  25. float2 envmapMaskTexCoord : TEXCOORD3;
  26. float4 worldPos_projPosZ : TEXCOORD4;
  27. float3 worldNormal : TEXCOORD5;
  28. float4 vertexColor : COLOR;
  29. float4 fogFactorW : COLOR1;
  30. };
  31. VS_OUTPUT main( const VS_INPUT v )
  32. {
  33. VS_OUTPUT o = ( VS_OUTPUT )0;
  34. float3 vObjNormal;
  35. DecompressVertex_Normal( v.vNormal, vObjNormal );
  36. float4 projPos;
  37. projPos = mul( float4( v.vPos, 1 ), cModelViewProj );
  38. o.projPos = projPos;
  39. projPos.z = dot( float4( v.vPos, 1 ), cModelViewProjZ );
  40. o.worldPos_projPosZ.w = projPos.z;
  41. o.worldPos_projPosZ.xyz = mul( float4( v.vPos, 1 ), cModel[0] );
  42. o.worldNormal = mul( vObjNormal, ( float3x3 )cModel[0] );
  43. o.baseTexCoord.x = dot( v.vBaseTexCoord, cBaseTexCoordTransform[0] ) + cBaseTexCoordTransform[0].w;
  44. o.baseTexCoord.y = dot( v.vBaseTexCoord, cBaseTexCoordTransform[1] ) + cBaseTexCoordTransform[1].w;
  45. o.detailTexCoord.x = dot( v.vDetailTexCoord, cDetailTexCoordTransform[0] ) + cDetailTexCoordTransform[0].w;
  46. o.detailTexCoord.y = dot( v.vDetailTexCoord, cDetailTexCoordTransform[1] ) + cDetailTexCoordTransform[1].w;
  47. o.envmapMaskTexCoord.x = dot( v.vDetailTexCoord, cDetailTexCoordTransform[0] ) + cDetailTexCoordTransform[0].w;
  48. o.envmapMaskTexCoord.y = dot( v.vDetailTexCoord, cDetailTexCoordTransform[1] ) + cDetailTexCoordTransform[1].w;
  49. o.lightmapTexCoord = v.vLightmapTexCoord;
  50. o.fogFactorW = CalcFog( o.worldPos_projPosZ.xyz, projPos, g_FogType );
  51. #if !defined( _X360 )
  52. o.fog = o.fogFactorW;
  53. #endif
  54. o.vertexColor = cModulationColor;
  55. return o;
  56. }