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.

72 lines
2.0 KiB

  1. // STATIC: "HALFLAMBERT" "0..1"
  2. // STATIC: "USE_STATIC_CONTROL_FLOW" "0..1" [vs20]
  3. // DYNAMIC: "DYNAMIC_LIGHT" "0..1"
  4. // DYNAMIC: "STATIC_LIGHT" "0..1"
  5. // DYNAMIC: "NUM_LIGHTS" "0..2" [vs20]
  6. // If using static control flow on Direct3D, we should use the NUM_LIGHTS=0 combo
  7. // SKIP: $USE_STATIC_CONTROL_FLOW && ( $NUM_LIGHTS > 0 ) [vs20]
  8. #include "common_vs_fxc.h"
  9. static const bool g_bHalfLambert = HALFLAMBERT ? true : false;
  10. const float3 cLeafCenter : register(SHADER_SPECIFIC_CONST_0);
  11. struct VS_INPUT
  12. {
  13. // This is all of the stuff that we ever use.
  14. float4 vPos : POSITION;
  15. float4 vNormal : NORMAL;
  16. float2 vTexCoord : TEXCOORD0;
  17. };
  18. struct VS_OUTPUT
  19. {
  20. float4 projPos : POSITION;
  21. float2 texCoord : TEXCOORD0;
  22. float3 color : COLOR;
  23. };
  24. VS_OUTPUT main( const VS_INPUT v )
  25. {
  26. VS_OUTPUT o = ( VS_OUTPUT )0;
  27. bool bDynamicLight = DYNAMIC_LIGHT ? true : false;
  28. bool bStaticLight = STATIC_LIGHT ? true : false;
  29. float3 worldPos;
  30. worldPos = mul( v.vPos, cModel[0] );
  31. float3 normal = v.vPos.xyz - cLeafCenter.xyz;
  32. normal = normalize( normal );
  33. float3 worldNormal = mul( float4( normal, 0.0f ), cModel[0] );
  34. #if ( USE_STATIC_CONTROL_FLOW ) || defined ( SHADER_MODEL_VS_3_0 )
  35. float3 lighting = DoLighting( worldPos, worldNormal, float3(0,0,0), bStaticLight, bDynamicLight, g_bHalfLambert );
  36. #else
  37. float3 lighting = DoLightingUnrolled( worldPos, worldNormal, float3(0,0,0), bStaticLight, bDynamicLight, g_bHalfLambert, NUM_LIGHTS );
  38. #endif
  39. float3 xAxis = float3( cViewModel[0].x, cViewModel[1].x, cViewModel[2].x );
  40. float3 yAxis = float3( cViewModel[0].y, cViewModel[1].y, cViewModel[2].y );
  41. worldPos += xAxis * v.vTexCoord.x;
  42. worldPos += yAxis * (1.0f-v.vTexCoord.y);
  43. float4 projPos = mul( float4(worldPos, 1.0f), cViewProj );
  44. float3 light_vec = float3( 1.0f, 0.0, 1.0 );
  45. light_vec = normalize( light_vec );
  46. o.projPos = projPos;
  47. // FIXME: if this shader gets put back into use, be sure this usage of normals jives with compressed verts
  48. o.texCoord = v.vNormal.xy;
  49. o.color = lighting;
  50. return o;
  51. }