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.

58 lines
1.3 KiB

  1. #include "common_fog_vs_forcevertexfog_fxc.h"
  2. #include "common_vs_fxc.h"
  3. // DYNAMIC: "SKINNING" "0..1"
  4. const float3 g_FogColorPostTonemapLinearSpace : register( SHADER_SPECIFIC_CONST_0 );
  5. struct VS_INPUT
  6. {
  7. float4 vPos : POSITION;
  8. float4 vBoneWeights : BLENDWEIGHT;
  9. float4 vBoneIndices : BLENDINDICES;
  10. };
  11. struct VS_OUTPUT
  12. {
  13. float4 projPos : POSITION; // Projection-space position
  14. #if ( HARDWAREFOGBLEND )
  15. float fog : FOG;
  16. #else
  17. float4 color : TEXCOORD0;
  18. #endif
  19. };
  20. VS_OUTPUT main( const VS_INPUT v )
  21. {
  22. VS_OUTPUT o;
  23. float3 worldPos;
  24. SkinPosition( SKINNING, v.vPos, v.vBoneWeights, v.vBoneIndices, worldPos );
  25. // Transform into projection space
  26. o.projPos = mul( float4( worldPos, 1 ), cViewProj );
  27. #ifdef _PS3
  28. // Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1]
  29. o.projPos.y = -o.projPos.y;
  30. o.projPos.z = 2.0f * o.projPos.z - o.projPos.w;
  31. #endif // _PS3
  32. #if ( HARDWAREFOGBLEND )
  33. {
  34. o.fog = CalcFixedFunctionFog( worldPos, DOWATERFOG );
  35. }
  36. #else
  37. {
  38. float flFogFactor = CalcNonFixedFunctionFog( worldPos, false );
  39. // squaring the factor will get the middle range mixing closer to hardware fog
  40. o.color.xyz = g_FogColorPostTonemapLinearSpace * flFogFactor * flFogFactor;
  41. o.color.a = 1.0f;
  42. }
  43. #endif
  44. return o;
  45. }