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.

80 lines
2.8 KiB

  1. //========== Copyright (c) Valve Corporation, All rights reserved. ==========//
  2. // DYNAMIC: "SKINNING" "0..1"
  3. // DYNAMIC: "COMPRESSED_VERTS" "0..1"
  4. #include "common_vs_fxc.h"
  5. const float4 g_baseTextureTransform[2] : register( SHADER_SPECIFIC_CONST_0 ); // 0 & 1
  6. static const bool g_bSkinning = SKINNING ? true : false;
  7. struct VS_INPUT
  8. {
  9. float4 vPos : POSITION;
  10. float2 vTexCoord : TEXCOORD0;
  11. float4 vNormal : NORMAL;
  12. float4 vTangent : TANGENT;
  13. float4 vBoneWeights : BLENDWEIGHT;
  14. float4 vBoneIndices : BLENDINDICES;
  15. };
  16. struct VS_OUTPUT
  17. {
  18. float4 vProjPos_POSITION : POSITION;
  19. //float4 lightAtten : TEXCOORD2;
  20. float3 worldPos : TEXCOORD3;
  21. float3x3 tangentSpaceTranspose : TEXCOORD4;
  22. // second row : TEXCOORD5;
  23. // third row : TEXCOORD6;
  24. float4 vProjPos : TEXCOORD7;
  25. };
  26. // Main
  27. VS_OUTPUT main( const VS_INPUT i )
  28. {
  29. VS_OUTPUT o;
  30. float4 vPosition, vTangent;
  31. float3 vNormal, worldPos, worldNormal, worldTangentS, worldTangentT;
  32. vPosition = i.vPos;
  33. // Perform skinning
  34. DecompressVertex_NormalTangent( i.vNormal, i.vTangent, vNormal, vTangent );
  35. SkinPositionNormalAndTangentSpace( g_bSkinning, vPosition, vNormal, vTangent,
  36. i.vBoneWeights, i.vBoneIndices, worldPos,
  37. worldNormal, worldTangentS, worldTangentT );
  38. worldTangentS = normalize( worldTangentS );
  39. worldTangentT = normalize( worldTangentT );
  40. worldNormal = normalize( worldNormal );
  41. // Tangent space transform
  42. o.tangentSpaceTranspose[0].xyz = float3( worldTangentS.x, worldTangentT.x, worldNormal.x );
  43. o.tangentSpaceTranspose[1].xyz = float3( worldTangentS.y, worldTangentT.y, worldNormal.y );
  44. o.tangentSpaceTranspose[2].xyz = float3( worldTangentS.z, worldTangentT.z, worldNormal.z );
  45. o.worldPos = worldPos;
  46. o.vProjPos = o.vProjPos_POSITION = mul( float4( worldPos, 1.0f ), cViewProj );
  47. //o.lightAtten.x = GetVertexAttenForLight( worldPos, 0, false );
  48. //o.lightAtten.y = GetVertexAttenForLight( worldPos, 1, false );
  49. //o.lightAtten.z = GetVertexAttenForLight( worldPos, 2, false );
  50. //o.lightAtten.w = GetVertexAttenForLight( worldPos, 3, false );
  51. //o.vBaseUV_PatternUV.xy = i.vTexCoord;
  52. //
  53. //o.vBaseUV_PatternUV.z = dot ( i.vTexCoord, g_baseTextureTransform[0].xy ) + g_baseTextureTransform[0].w;
  54. //o.vBaseUV_PatternUV.w = dot ( i.vTexCoord, g_baseTextureTransform[1].xy ) + g_baseTextureTransform[1].w;
  55. //
  56. //o.vWearUV_GrungeUV.x = dot ( i.vTexCoord, g_wearTexCoordTransform[0].xy ) + g_wearTexCoordTransform[0].w;
  57. //o.vWearUV_GrungeUV.y = dot ( i.vTexCoord, g_wearTexCoordTransform[1].xy ) + g_wearTexCoordTransform[1].w;
  58. //
  59. //o.vWearUV_GrungeUV.z = dot ( i.vTexCoord, g_grungeTexCoordTransform[0].xy ) + g_grungeTexCoordTransform[0].w;
  60. //o.vWearUV_GrungeUV.w = dot ( i.vTexCoord, g_grungeTexCoordTransform[1].xy ) + g_grungeTexCoordTransform[1].w;
  61. return o;
  62. }