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.

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