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.

77 lines
2.6 KiB

  1. //========== Copyright (c) Valve Corporation, All rights reserved. ==========//
  2. // STATIC: "PREVIEW" "0..1"
  3. // DYNAMIC: "SKINNING" "0..1"
  4. // DYNAMIC: "COMPRESSED_VERTS" "0..1"
  5. // DYNAMIC: "NUM_LIGHTS" "0..4"
  6. // SKIP: ( ( $PREVIEW == 0 ) && ( $SKINNING == 1 ) )
  7. // SKIP: ( ( $NUM_LIGHTS != 0 ) && ( $PREVIEW == 0 ) )
  8. #include "common_vs_fxc.h"
  9. const float4 g_patternTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 ); // 0 & 1
  10. const float4 g_wearTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_2 ); // 2 & 3
  11. const float4 g_grungeTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_4 ); // 4 & 5
  12. static const bool g_bSkinning = SKINNING ? true : false;
  13. // Structs
  14. struct VS_INPUT
  15. {
  16. float4 vPos : POSITION;
  17. float2 vTexCoord : TEXCOORD0;
  18. #if ( PREVIEW == 1 )
  19. float4 vNormal : NORMAL;
  20. float4 vBoneWeights : BLENDWEIGHT;
  21. float4 vBoneIndices : BLENDINDICES;
  22. #endif
  23. };
  24. struct VS_OUTPUT
  25. {
  26. float4 vProjPos : POSITION;
  27. float4 vBaseUV_PatternUV : TEXCOORD0;
  28. float4 vWearUV_GrungeUV : TEXCOORD1;
  29. #if ( PREVIEW == 1 )
  30. float4 lightAtten : TEXCOORD2;
  31. float3 worldPos : TEXCOORD3;
  32. float3 vWorldNormal : TEXCOORD4;
  33. #endif
  34. };
  35. // Main
  36. VS_OUTPUT main( const VS_INPUT i )
  37. {
  38. VS_OUTPUT o;
  39. #if ( PREVIEW == 1 )
  40. float4 vPosition, vTangent;
  41. float3 vNormal, worldPos, worldNormal, worldTangentS, worldTangentT;
  42. vPosition = i.vPos;
  43. DecompressVertex_Normal( i.vNormal, vNormal );
  44. SkinPositionAndNormal( g_bSkinning, vPosition, vNormal, i.vBoneWeights, i.vBoneIndices, worldPos, worldNormal );
  45. o.worldPos = worldPos;
  46. o.vProjPos = mul( float4( worldPos, 1.0f ), cViewProj );
  47. o.vWorldNormal = worldNormal;
  48. o.lightAtten.x = GetVertexAttenForLight( worldPos, 0 );
  49. o.lightAtten.y = GetVertexAttenForLight( worldPos, 1 );
  50. o.lightAtten.z = GetVertexAttenForLight( worldPos, 2 );
  51. o.lightAtten.w = GetVertexAttenForLight( worldPos, 3 );
  52. #else
  53. o.vProjPos = i.vPos;
  54. #endif
  55. o.vBaseUV_PatternUV.xy = i.vTexCoord;
  56. o.vBaseUV_PatternUV.z = dot ( i.vTexCoord, g_patternTexCoordTransform[0].xy ) + g_patternTexCoordTransform[0].w;
  57. o.vBaseUV_PatternUV.w = dot ( i.vTexCoord, g_patternTexCoordTransform[1].xy ) + g_patternTexCoordTransform[1].w;
  58. o.vWearUV_GrungeUV.x = dot ( i.vTexCoord, g_wearTexCoordTransform[0].xy ) + g_wearTexCoordTransform[0].w;
  59. o.vWearUV_GrungeUV.y = dot ( i.vTexCoord, g_wearTexCoordTransform[1].xy ) + g_wearTexCoordTransform[1].w;
  60. o.vWearUV_GrungeUV.z = dot ( i.vTexCoord, g_grungeTexCoordTransform[0].xy ) + g_grungeTexCoordTransform[0].w;
  61. o.vWearUV_GrungeUV.w = dot ( i.vTexCoord, g_grungeTexCoordTransform[1].xy ) + g_grungeTexCoordTransform[1].w;
  62. return o;
  63. }