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.

82 lines
2.6 KiB

  1. //========== Copyright (c) Valve Corporation, All rights reserved. ==========//
  2. // DYNAMIC: "COMPRESSED_VERTS" "0..1"
  3. #include "common_fog_vs_fxc.h"
  4. // DYNAMIC: "SKINNING" "0..1"
  5. // DYNAMIC: "WORLD_NORMAL" "0..1" [PC]
  6. // DYNAMIC: "WORLD_NORMAL" "0..0" [CONSOLE]
  7. #include "common_vs_fxc.h"
  8. static const bool g_bSkinning = SKINNING ? true : false;
  9. static const int g_FogType = DOWATERFOG;
  10. const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 ); // 0 & 1
  11. const float4 cBaseTexCoordTransform2[2] : register( SHADER_SPECIFIC_CONST_2 ); // 2 & 3
  12. const float4 g_vEyeVector : register( SHADER_SPECIFIC_CONST_4 );
  13. struct VS_INPUT
  14. {
  15. float4 vPos : POSITION;
  16. float4 vBoneWeights : BLENDWEIGHT;
  17. float4 vBoneIndices : BLENDINDICES;
  18. // make these float2's and stick the [n n 0 1] in the dot math.
  19. float4 vTexCoord0 : TEXCOORD0;
  20. };
  21. struct VS_OUTPUT
  22. {
  23. float4 projPos : POSITION; // Projection-space position
  24. #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
  25. float fog : FOG;
  26. #endif
  27. float2 baseTexCoord : TEXCOORD0; // Base texture coordinate
  28. float2 baseTexCoord2 : TEXCOORD1; // Base texture coordinate
  29. float4 worldPos_projPosZ : TEXCOORD7; // Necessary for water fog dest alpha
  30. float4 vColor : COLOR0;
  31. };
  32. VS_OUTPUT main( const VS_INPUT v )
  33. {
  34. VS_OUTPUT o = ( VS_OUTPUT )0;
  35. float4 vPosition = v.vPos;
  36. // Perform skinning
  37. float3 worldNormal, worldPos;
  38. SkinPosition( g_bSkinning, vPosition, v.vBoneWeights, v.vBoneIndices, worldPos );
  39. // Transform into projection space
  40. float4 projPos = mul( float4( worldPos, 1 ), cViewProj );
  41. o.projPos = projPos;
  42. #ifdef _PS3
  43. // Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1]
  44. o.projPos.y = -o.projPos.y;
  45. o.projPos.z = 2.0f * o.projPos.z - o.projPos.w;
  46. #endif // _PS3
  47. #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
  48. o.fog = CalcFixedFunctionFog( worldPos, g_FogType );
  49. #endif
  50. // Needed for water fog alpha;
  51. o.worldPos_projPosZ = float4( worldPos.xyz, o.projPos.z ); // FIXME: we shouldn't have to compute this all thie time.
  52. #if WORLD_NORMAL
  53. {
  54. o.worldPos_projPosZ.w = dot( g_vEyeVector, worldPos.xyz - cEyePos.xyz ); // Linear depth
  55. }
  56. #endif
  57. o.baseTexCoord.x = dot( v.vTexCoord0, cBaseTexCoordTransform[0] ); // Base texture coordinates
  58. o.baseTexCoord.y = dot( v.vTexCoord0, cBaseTexCoordTransform[1] );
  59. o.baseTexCoord2.x = dot( v.vTexCoord0, cBaseTexCoordTransform2[0] ); // Secondary texture coordinates
  60. o.baseTexCoord2.y = dot( v.vTexCoord0, cBaseTexCoordTransform2[1] );
  61. o.vColor = cModulationColor;
  62. return o;
  63. }