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.

57 lines
1.3 KiB

  1. // DYNAMIC: "COMPRESSED_VERTS" "0..1"
  2. #include "common_fog_vs_fxc.h"
  3. // DYNAMIC: "SKINNING" "0..1"
  4. #include "common_vs_fxc.h"
  5. static const int g_FogType = DOWATERFOG;
  6. static const bool g_bSkinning = SKINNING ? true : false;
  7. struct VS_INPUT
  8. {
  9. float4 vPos : POSITION;
  10. float4 vBoneWeights : BLENDWEIGHT;
  11. float4 vBoneIndices : BLENDINDICES;
  12. float4 vNormal : NORMAL;
  13. };
  14. struct VS_OUTPUT
  15. {
  16. float4 vProjPos : POSITION;
  17. float4 vDiffuse : COLOR0;
  18. #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
  19. float fog : FOG;
  20. #endif
  21. };
  22. VS_OUTPUT main( const VS_INPUT v )
  23. {
  24. VS_OUTPUT o = ( VS_OUTPUT )0;
  25. float3 vObjNormal;
  26. DecompressVertex_Normal( v.vNormal, vObjNormal );
  27. float3 worldPos, worldNormal;
  28. SkinPositionAndNormal( g_bSkinning, v.vPos, vObjNormal, v.vBoneWeights, v.vBoneIndices, worldPos, worldNormal );
  29. o.vProjPos = mul( float4( worldPos, 1 ), cViewProj );
  30. #ifdef _PS3
  31. // Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1]
  32. o.vProjPos.y = -o.vProjPos.y;
  33. o.vProjPos.z = 2.0f * o.vProjPos.z - o.vProjPos.w;
  34. #endif // _PS3
  35. #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
  36. o.fog = CalcFixedFunctionFog( worldPos, g_FogType );
  37. #endif
  38. // stick the normal in the color channel
  39. o.vDiffuse.rgb = worldNormal;
  40. o.vDiffuse.a = 1.0f;
  41. return o;
  42. }