Counter Strike : Global Offensive Source Code
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.1 KiB

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