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.

73 lines
2.0 KiB

  1. // STATIC: "HALFLAMBERT" "0..1"
  2. // STATIC: "USE_STATIC_CONTROL_FLOW" "0..1" [vs20]
  3. // DYNAMIC: "DOWATERFOG" "0..1"
  4. // DYNAMIC: "SKINNING" "0..1"
  5. // DYNAMIC: "DYNAMIC_LIGHT" "0..1"
  6. // DYNAMIC: "STATIC_LIGHT" "0..1"
  7. // DYNAMIC: "NUM_LIGHTS" "0..2" [vs20]
  8. // If using static control flow on Direct3D, we should use the NUM_LIGHTS=0 combo
  9. // SKIP: $USE_STATIC_CONTROL_FLOW && ( $NUM_LIGHTS > 0 ) [vs20]
  10. #include "common_vs_fxc.h"
  11. static const int g_FogType = DOWATERFOG;
  12. static const bool g_bHalfLambert = HALFLAMBERT ? true : false;
  13. static const int g_nSkinning = SKINNING;
  14. static const bool g_bDynamicLight = DYNAMIC_LIGHT ? true : false;
  15. static const bool g_bStaticLight = STATIC_LIGHT ? true : false;
  16. struct VS_INPUT
  17. {
  18. float4 vPos : POSITION;
  19. float4 vBoneWeights : BLENDWEIGHT;
  20. float4 vBoneIndices : BLENDINDICES;
  21. float4 vNormal : NORMAL;
  22. float3 vSpecular : COLOR1;
  23. float2 vTexCoord0 : TEXCOORD0;
  24. float2 vTexCoord1 : TEXCOORD1;
  25. float2 vTexCoord2 : TEXCOORD2;
  26. };
  27. struct VS_OUTPUT
  28. {
  29. float4 vProjPos : POSITION;
  30. float3 vColor0 : COLOR0;
  31. float4 fogFactorW : COLOR1;
  32. #if !defined( _X360 )
  33. float fog : FOG;
  34. #endif
  35. };
  36. VS_OUTPUT main( const VS_INPUT v )
  37. {
  38. VS_OUTPUT o = ( VS_OUTPUT )0;
  39. float3 vObjNormal;
  40. DecompressVertex_Normal( v.vNormal, vObjNormal );
  41. float3 worldPos, worldNormal;
  42. SkinPositionAndNormal( g_bSkinning, v.vPos, vObjNormal, v.vBoneWeights, v.vBoneIndices, worldPos, worldNormal );
  43. o.vProjPos = mul( float4( worldPos, 1 ), cViewProj );
  44. o.fogFactorW = CalcFog( worldPos, o.vProjPos, g_FogType );
  45. #if !defined( _X360 )
  46. o.fog = o.fogFactorW;
  47. #endif
  48. // Compute vertex lighting
  49. #if ( USE_STATIC_CONTROL_FLOW ) || defined ( SHADER_MODEL_VS_3_0 )
  50. o.vColor0 = DoLighting( worldPos, worldNormal, float3(0.0f, 0.0f, 0.0f), g_bStaticLight, g_bDynamicLight, g_bHalfLambert );
  51. #else
  52. o.vColor0 = DoLightingUnrolled( worldPos, worldNormal, float3(0.0f, 0.0f, 0.0f), g_bStaticLight, g_bDynamicLight, g_bHalfLambert, NUM_LIGHTS );
  53. #endif
  54. return o;
  55. }