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.

135 lines
3.7 KiB

  1. // STATIC: "VERTEXCOLOR" "0..1"
  2. // DYNAMIC: "COMPRESSED_VERTS" "0..1"
  3. // DYNAMIC: "SKINNING" "0..1"
  4. // DYNAMIC: "TESSELLATION" "0..0" [vs30] [PC]
  5. // DYNAMIC: "TESSELLATION" "0..0" [CONSOLE]
  6. // DYNAMIC: "TESSELLATION" "0..0" [vs20] [PC]
  7. // SKIP: $TESSELLATION && $VERTEXCOLOR
  8. #include "common_fog_vs_fxc.h"
  9. #include "common_vs_fxc.h"
  10. static const int g_FogType = DOWATERFOG;
  11. static const bool g_bSkinning = SKINNING ? true : false;
  12. const float4 cBaseTextureTransform[2] : register( SHADER_SPECIFIC_CONST_0 );
  13. const float4 cMaskTextureTransform[2] : register( SHADER_SPECIFIC_CONST_2 );
  14. const float4 cDetailTextureTransform[2] : register( SHADER_SPECIFIC_CONST_4 );
  15. #if TESSELLATION
  16. #include "tessellation_vs_fxc.h"
  17. const float4 g_SubDControls : register( SHADER_SPECIFIC_CONST_9 );
  18. sampler2D BezierSampler : register( s1 );
  19. sampler2D DispSampler : register( s2 );
  20. // VS_INPUT defined in header
  21. #else // no TESSELLATION
  22. struct VS_INPUT
  23. {
  24. float4 vPos : POSITION;
  25. float4 vBoneWeights : BLENDWEIGHT;
  26. float4 vBoneIndices : BLENDINDICES;
  27. float4 vNormal : NORMAL;
  28. #if VERTEXCOLOR
  29. float4 vColor : COLOR0;
  30. #endif
  31. float4 vTexCoord0 : TEXCOORD0;
  32. };
  33. #endif
  34. struct VS_OUTPUT
  35. {
  36. float4 vProjPos : POSITION;
  37. float2 vTexCoord0 : TEXCOORD0;
  38. float2 vTexCoord1 : TEXCOORD1;
  39. float2 vTexCoord2 : TEXCOORD2;
  40. float2 vTexCoord3 : TEXCOORD3;
  41. float4 vColor : COLOR0;
  42. #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
  43. float fog : FOG;
  44. #endif
  45. float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog
  46. };
  47. VS_OUTPUT main( const VS_INPUT v )
  48. {
  49. VS_OUTPUT o = ( VS_OUTPUT )0;
  50. float3 worldPos;
  51. float3 worldNormal;
  52. float2 vTexCoord0;
  53. float4 vColor;
  54. #if TESSELLATION
  55. {
  56. float flBiTangentSign;
  57. float3 worldTangentS, worldTangentT;
  58. float2 vDetailCoord;
  59. float flWrinkleWeight;
  60. vColor = float4(1,1,1,1);
  61. EvaluateSubdivisionSurface( v, g_SubDControls.x, g_SubDControls.y, g_SubDControls.z, BezierSampler, DispSampler,
  62. worldNormal, worldPos, worldTangentS, worldTangentT, flBiTangentSign,
  63. flWrinkleWeight, vTexCoord0, vDetailCoord );
  64. }
  65. #else // no TESSELLATION
  66. {
  67. //------------------------------------------------------------------------------
  68. // Vertex blending
  69. //------------------------------------------------------------------------------
  70. SkinPosition( g_bSkinning, v.vPos, v.vBoneWeights, v.vBoneIndices, worldPos );
  71. vTexCoord0 = v.vTexCoord0.xy;
  72. #if VERTEXCOLOR
  73. vColor = v.vColor;
  74. #endif
  75. }
  76. #endif
  77. o.vProjPos = mul( float4( worldPos, 1 ), cViewProj );
  78. #ifdef _PS3
  79. // Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1]
  80. o.vProjPos.y = -o.vProjPos.y;
  81. o.vProjPos.z = 2.0f * o.vProjPos.z - o.vProjPos.w;
  82. #endif // _PS3
  83. o.worldPos_projPosZ = float4( worldPos.xyz, o.vProjPos.z );
  84. //------------------------------------------------------------------------------
  85. // Fog
  86. //------------------------------------------------------------------------------
  87. #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
  88. o.fog = CalcFixedFunctionFog( worldPos, g_FogType );
  89. #endif
  90. //------------------------------------------------------------------------------
  91. // Texture coord transforms
  92. //------------------------------------------------------------------------------
  93. #ifdef _PS3
  94. o.vTexCoord0 = ( cBaseTextureTransform[0].xy * vTexCoord0.xx ) + ( cBaseTextureTransform[1].xy * vTexCoord0.yy );
  95. o.vTexCoord3 = ( cDetailTextureTransform[0].xy * vTexCoord0.xx ) + ( cDetailTextureTransform[1].xy * vTexCoord0.yy );
  96. #else
  97. o.vTexCoord0 = mul( vTexCoord0, (float2x4)cBaseTextureTransform );
  98. o.vTexCoord3 = mul( vTexCoord0, (float2x4)cDetailTextureTransform );
  99. #endif
  100. o.vColor = cModulationColor;
  101. #if VERTEXCOLOR
  102. o.vColor *= v.vColor;
  103. #endif
  104. return o;
  105. }