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.

118 lines
3.5 KiB

  1. //========== Copyright (c) Valve Corporation, All rights reserved. ==========//
  2. //
  3. // Purpose:
  4. //
  5. //===========================================================================//
  6. // STATIC: "MODEL" "0..1"
  7. #include "common_fog_vs_fxc.h"
  8. // DYNAMIC: "SKINNING" "0..1"
  9. // DYNAMIC: "MORPHING" "0..0" [ = false ]
  10. // STATIC: "SPECULAR" "0..1"
  11. #include "common_vs_fxc.h"
  12. static const bool g_bSkinning = SKINNING ? true : false;
  13. static const int g_FogType = DOWATERFOG;
  14. const float4 cBaseTexCoordTransform[ 2 ] : register( SHADER_SPECIFIC_CONST_6 );
  15. const float4 g_vFoWWorldSize : register( c26 );
  16. const float4 g_vRotations : register( c27 );
  17. const float4 g_vScales : register( c28 );
  18. const float4 g_vLightDir : register( c29 ); // xyz = light dir, w = spec power
  19. struct VS_INPUT
  20. {
  21. float3 vPos : POSITION;
  22. float4 vNormal : NORMAL;
  23. float2 vBaseTexCoord : TEXCOORD0;
  24. float2 vLightmapTexCoord : TEXCOORD1;
  25. // float2 vLightmapTexCoordOffset : TEXCOORD2;
  26. float4 vAlphaBlend : TEXCOORD3;
  27. float4 vColorBlend1 : TEXCOORD4;
  28. float4 vColorBlend2 : TEXCOORD5;
  29. float4 vColorBlend3 : TEXCOORD6;
  30. float4 vColorBlend4 : TEXCOORD7;
  31. };
  32. struct VS_OUTPUT
  33. {
  34. float4 vProjPos : POSITION;
  35. float4 vBaseTexCoord : TEXCOORD0; // xy = blend 1 coord, zw = lightmap cord
  36. float4 worldPos_projPosZ : TEXCOORD1;
  37. // float3 vWorldNormal : TEXCOORD2;
  38. float flSpecPower : TEXCOORD2;
  39. float4 vFowCoord : TEXCOORD3; // xy = fow, zw = blend4 coord
  40. float4 vAlphaBlend : TEXCOORD4;
  41. // float3 worldVertToEyeVector : TEXCOORD5;
  42. float4 vBlendCoords23 : TEXCOORD5;
  43. float4 vColorBlend1 : COLOR0;
  44. float4 vColorBlend2 : COLOR1;
  45. float4 vColorBlend3 : TEXCOORD6;
  46. float4 vColorBlend4 : TEXCOORD7;
  47. };
  48. float2 ComputeTexCoord( const float2 vBaseCoord, const float flRotation, const float flScale )
  49. {
  50. float2 vAdjust = vBaseCoord - float2( 0.5, 0.5 );
  51. float2 vResult;
  52. float c = cos( flRotation );
  53. float s = sin( flRotation );
  54. vResult.x = ( vAdjust.x * c ) + ( vAdjust.y * -s );
  55. vResult.y = ( vAdjust.x * s ) + ( vAdjust.y * c );
  56. return ( vResult / flScale ) + float2( 0.5, 0.5 );
  57. }
  58. VS_OUTPUT main( const VS_INPUT v )
  59. {
  60. VS_OUTPUT o;
  61. float3 vObjNormal;
  62. DecompressVertex_Normal( v.vNormal, vObjNormal );
  63. float4 vProjPos;
  64. float3 vWorldPos;
  65. vWorldPos = mul( float4( v.vPos, 1 ), cModel[0] );
  66. vProjPos = mul( float4( vWorldPos, 1 ), cViewProj );
  67. o.vProjPos = vProjPos;
  68. o.worldPos_projPosZ.w = vProjPos.z;
  69. o.worldPos_projPosZ.xyz = vWorldPos;
  70. o.vFowCoord.xy = float2( 0.0, 0.0 );
  71. float3 vWorldNormal = mul( vObjNormal, ( float3x3 )cModel[0] );
  72. o.vBaseTexCoord.xy = ComputeTexCoord( v.vBaseTexCoord, g_vRotations.x, g_vScales.x );
  73. o.vBlendCoords23.xy = ComputeTexCoord( v.vBaseTexCoord, g_vRotations.y, g_vScales.y );
  74. o.vBlendCoords23.zw = ComputeTexCoord( v.vBaseTexCoord, g_vRotations.z, g_vScales.z );
  75. o.vFowCoord.zw = ComputeTexCoord( v.vBaseTexCoord, g_vRotations.w, g_vScales.w );
  76. o.vBaseTexCoord.zw = v.vLightmapTexCoord; // + v.vLightmapTexCoordOffset;
  77. o.vColorBlend1 = v.vColorBlend1;
  78. o.vColorBlend2 = v.vColorBlend2;
  79. o.vColorBlend3 = v.vColorBlend3;
  80. o.vColorBlend4 = v.vColorBlend4;
  81. o.vAlphaBlend = v.vAlphaBlend;
  82. #if ( SPECULAR == 1 )
  83. float3 vWorldVertToEyeVector = cEyePos - vWorldPos;
  84. float3 vView = normalize( vWorldVertToEyeVector );
  85. float3 vReflect = reflect( g_vLightDir, vWorldNormal );
  86. float fDot = dot( vView, vReflect );
  87. o.flSpecPower = saturate( pow( saturate( fDot ), g_vLightDir.w ) );
  88. #else
  89. o.flSpecPower = 0;
  90. #endif
  91. return o;
  92. }