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.

146 lines
3.4 KiB

  1. // STATIC: "DEFERRED_SHADOWS" "0..1"
  2. #include "common_fog_vs_fxc.h"
  3. #include "common_vs_fxc.h"
  4. static const int g_FogType = DOWATERFOG;
  5. const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 );
  6. const float4 cTextureJitter[2] : register( SHADER_SPECIFIC_CONST_2 );
  7. #if DEFERRED_SHADOWS == 0
  8. struct VS_INPUT
  9. {
  10. // This is all of the stuff that we ever use.
  11. float4 vPos : POSITION;
  12. float4 vColor : COLOR0;
  13. float4 vTexCoord0 : TEXCOORD0;
  14. float3 vFalloffParams : TEXCOORD1;
  15. };
  16. struct VS_OUTPUT
  17. {
  18. float4 projPos : POSITION;
  19. #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
  20. float fog : FOG;
  21. #endif
  22. float4 worldPos_projPosZ : TEXCOORD0;
  23. float4 vFalloffParams : TEXCOORD1;
  24. float3 texCoord0_shadowAlpha : TEXCOORD2;
  25. #if !defined( _X360 )
  26. float4 texCoord1_2 : TEXCOORD3;
  27. float4 texCoord3_4 : TEXCOORD4;
  28. #endif
  29. };
  30. VS_OUTPUT main( const VS_INPUT v )
  31. {
  32. VS_OUTPUT o = ( VS_OUTPUT )0;
  33. float3 worldPos;
  34. float2 texCoord;
  35. worldPos = mul4x3( v.vPos, cModel[0] );
  36. float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj );
  37. o.projPos = vProjPos;
  38. #ifdef _PS3
  39. // Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1]
  40. o.projPos.y = -o.projPos.y;
  41. o.projPos.z = 2.0f * o.projPos.z - o.projPos.w;
  42. #endif // _PS3
  43. #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
  44. o.fog = CalcFixedFunctionFog( worldPos, g_FogType );
  45. #endif
  46. o.worldPos_projPosZ = float4( worldPos, vProjPos.z );
  47. o.vFalloffParams.xyz = v.vFalloffParams;
  48. o.vFalloffParams.w = v.vTexCoord0.z;
  49. texCoord.x = dot( v.vTexCoord0, cBaseTexCoordTransform[0] );
  50. texCoord.y = dot( v.vTexCoord0, cBaseTexCoordTransform[1] );
  51. o.texCoord0_shadowAlpha.xy = texCoord;
  52. #if !defined( _X360 )
  53. {
  54. o.texCoord1_2.xy = texCoord + cTextureJitter[0].xy;
  55. o.texCoord1_2.wz = texCoord - cTextureJitter[0].xy;
  56. o.texCoord3_4.xy = texCoord + cTextureJitter[1].xy;
  57. o.texCoord3_4.wz = texCoord - cTextureJitter[1].xy;
  58. }
  59. #endif
  60. o.texCoord0_shadowAlpha.z = v.vColor.a;
  61. return o;
  62. }
  63. #else // DEFERRED_SHADOWS == 1
  64. struct VS_INPUT
  65. {
  66. float4 vPos : POSITION;
  67. float3 vNormal : NORMAL;
  68. float3 vShadowDir : TEXCOORD0;
  69. float4 vTexCoordBiasScale : TEXCOORD1;
  70. float4 vProjToTex0 : TEXCOORD2;
  71. float4 vProjToTex1 : TEXCOORD3;
  72. float4 vProjToTex2 : TEXCOORD4;
  73. float4 vProjToTex3 : TEXCOORD5;
  74. float3 vFalloffParams : TEXCOORD6;
  75. };
  76. struct VS_OUTPUT
  77. {
  78. #ifdef _PS3
  79. float4 projPos : POSITION;
  80. #else
  81. float4 projPos : POSITION;
  82. #endif
  83. float4 vTexCoordBiasScale : TEXCOORD0;
  84. float4 vProjToTex0 : TEXCOORD1;
  85. float4 vProjToTex1 : TEXCOORD2;
  86. float4 vProjToTex2 : TEXCOORD3;
  87. float4 vProjToTex3 : TEXCOORD4;
  88. float3 vFalloffParams : TEXCOORD5;
  89. };
  90. VS_OUTPUT main( const VS_INPUT v )
  91. {
  92. VS_OUTPUT o = ( VS_OUTPUT )0;
  93. float3 worldNormal, worldPos;
  94. float2 texCoord;
  95. // obj->world xform currently handled on CPU for batching
  96. /*
  97. worldPos = mul4x3( v.vPos, cModel[0] );
  98. worldNormal = mul3x3( v.vNormal, ( float3x3 )cModel[0] );
  99. */
  100. worldPos = v.vPos.xyz;
  101. worldNormal = v.vNormal.xyz;
  102. // bounding volume extrusion
  103. if ( dot( worldNormal, v.vShadowDir ) > 0.0 )
  104. {
  105. worldPos += v.vShadowDir;
  106. }
  107. o.vTexCoordBiasScale = v.vTexCoordBiasScale;
  108. o.vProjToTex0 = v.vProjToTex0;
  109. o.vProjToTex1 = v.vProjToTex1;
  110. o.vProjToTex2 = v.vProjToTex2;
  111. o.vProjToTex3 = v.vProjToTex3;
  112. o.vFalloffParams.xyz = v.vFalloffParams;
  113. float4 projPos = mul( float4( worldPos, 1 ), cViewProj );
  114. o.projPos = projPos;
  115. return o;
  116. }
  117. #endif