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.

91 lines
2.9 KiB

  1. // STATIC: "BLEND" "0..1"
  2. #include "common_vs_fxc.h"
  3. struct VS_INPUT
  4. {
  5. float4 vPos : POSITION;
  6. float4 vNormal : NORMAL;
  7. float2 vNormalMapCoord : TEXCOORD0;
  8. float3 vTangentS : TANGENT;
  9. float3 vTangentT : BINORMAL;
  10. };
  11. struct VS_OUTPUT
  12. {
  13. float4 projPos : POSITION;
  14. #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
  15. float fog : FOG;
  16. #endif
  17. float4 worldVertToEyeVector_normalMapX : TEXCOORD1;
  18. float3x3 tangentSpaceTranspose : TEXCOORD2;
  19. float4 vRefract_W_ProjZ : TEXCOORD5;
  20. float4 vExtraBumpTexCoord : TEXCOORD6;
  21. float4 worldPos_normalMapY : TEXCOORD7;
  22. };
  23. const float4 cNormalMapTransform[2] : register( SHADER_SPECIFIC_CONST_0 );
  24. const float4 TexOffsets : register( SHADER_SPECIFIC_CONST_3 );
  25. VS_OUTPUT main( const VS_INPUT v )
  26. {
  27. VS_OUTPUT o = ( VS_OUTPUT )0;
  28. float3 vObjNormal;
  29. DecompressVertex_Normal( v.vNormal, vObjNormal );
  30. float4 projPos;
  31. float3 worldPos;
  32. worldPos = mul4x3( v.vPos, cModel[0] );
  33. projPos = mul( float4( worldPos, 1 ), cViewProj );
  34. o.projPos = projPos;
  35. #ifdef _PS3
  36. // Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1]
  37. o.projPos.y = -o.projPos.y;
  38. o.projPos.z = 2.0f * o.projPos.z - o.projPos.w;
  39. #endif // _PS3
  40. #if BLEND
  41. // Map projected position to the reflection texture
  42. o.vRefract_W_ProjZ.x = projPos.x;
  43. o.vRefract_W_ProjZ.y = -projPos.y; // invert Y
  44. o.vRefract_W_ProjZ.xy = ( o.vRefract_W_ProjZ.xy + projPos.ww ) * float2( 0.5f, 0.5f );
  45. o.vRefract_W_ProjZ.z = projPos.w;
  46. #endif
  47. o.vRefract_W_ProjZ.w = projPos.z;
  48. float3 worldTangentS = mul3x3( v.vTangentS, ( const float3x3 )cModel[0] );
  49. float3 worldTangentT = mul3x3( v.vTangentT, ( const float3x3 )cModel[0] );
  50. float3 worldNormal = mul3x3( vObjNormal, ( float3x3 )cModel[0] );
  51. o.tangentSpaceTranspose[0] = worldTangentS;
  52. o.tangentSpaceTranspose[1] = worldTangentT;
  53. o.tangentSpaceTranspose[2] = worldNormal;
  54. float3 worldVertToEyeVector = VSHADER_VECT_SCALE * (cEyePos - worldPos);
  55. o.worldVertToEyeVector_normalMapX.xyz = worldVertToEyeVector;
  56. // FIXME: need to add a normalMapTransform to all of the water shaders.
  57. //o.worldVertToEyeVector_normalMapX.w = dot( v.vNormalMapCoord, cNormalMapTransform[0] ) + cNormalMapTransform[0].w;
  58. //o.worldPos_normalMapY.w = dot( v.vNormalMapCoord, cNormalMapTransform[1] ) + cNormalMapTransform[1].w;
  59. o.worldVertToEyeVector_normalMapX.w = v.vNormalMapCoord.x;
  60. o.worldPos_normalMapY.w = v.vNormalMapCoord.y;
  61. float f45x=v.vNormalMapCoord.x+v.vNormalMapCoord.y;
  62. float f45y=v.vNormalMapCoord.y-v.vNormalMapCoord.x;
  63. o.vExtraBumpTexCoord.x=f45x*0.1+TexOffsets.x;
  64. o.vExtraBumpTexCoord.y=f45y*0.1+TexOffsets.y;
  65. o.vExtraBumpTexCoord.z=v.vNormalMapCoord.y*0.45+TexOffsets.z;
  66. o.vExtraBumpTexCoord.w=v.vNormalMapCoord.x*0.45+TexOffsets.w;
  67. o.worldPos_normalMapY.xyz = worldPos;
  68. #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
  69. o.fog = CalcFixedFunctionFog( worldPos, FOGTYPE_RANGE );
  70. #endif
  71. return o;
  72. }