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.

73 lines
1.8 KiB

  1. #include "common_fog_vs_fxc.h"
  2. #include "common_vs_fxc.h"
  3. static const int g_FogType = DOWATERFOG;
  4. struct VS_INPUT
  5. {
  6. float4 vPos : POSITION;
  7. float2 vTexCoord0 : TEXCOORD0;
  8. float2 vTexCoord1 : TEXCOORD1;
  9. float4 directionalLightColor : COLOR0;
  10. float3 vTangentS : TANGENT;
  11. float3 vTangentT : BINORMAL;
  12. };
  13. struct VS_OUTPUT
  14. {
  15. float4 vProjPos : POSITION;
  16. float2 vTexCoord0 : TEXCOORD0;
  17. float2 vTexCoord1 : TEXCOORD1;
  18. float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog
  19. float4 directionalLightColor : COLOR0;
  20. #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
  21. float fog : FOG;
  22. #endif
  23. };
  24. VS_OUTPUT main( const VS_INPUT v )
  25. {
  26. VS_OUTPUT o = ( VS_OUTPUT )0;
  27. float3 worldPos;
  28. worldPos = mul( v.vPos, cModel[0] );
  29. o.vProjPos = mul( float4( worldPos, 1 ), cViewProj );
  30. o.worldPos_projPosZ = float4( worldPos.xyz, o.vProjPos.z );
  31. #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
  32. o.fog = CalcFixedFunctionFog( worldPos, g_FogType );
  33. #endif
  34. //------------------------------------------------------------------------------
  35. // Setup the tangent space
  36. //------------------------------------------------------------------------------
  37. // Get S crossed with T (call it R)
  38. float3 r = cross( v.vTangentS, v.vTangentT );
  39. // Normalize S (into s)
  40. float3 s = normalize( v.vTangentS );
  41. // Normalize R (into r)
  42. r = normalize( r );
  43. // Regenerate T (into t)
  44. float3 t = cross( r, v.vTangentS );
  45. //------------------------------------------------------------------------------
  46. // Copy texcoords for the normal map and base texture
  47. //------------------------------------------------------------------------------
  48. o.vTexCoord0 = v.vTexCoord0;
  49. o.vTexCoord1 = v.vTexCoord1;
  50. // Pass the dirlight color through
  51. o.directionalLightColor = v.directionalLightColor;
  52. return o;
  53. }