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.

71 lines
1.7 KiB

  1. // STATIC: "VERTEXCOLOR" "0..1"
  2. // STATIC: "SRGB" "0..1"
  3. #include "common_fog_vs_fxc.h"
  4. #include "common_vs_fxc.h"
  5. static const int g_FogType = DOWATERFOG;
  6. static const bool g_bVertexColor = VERTEXCOLOR ? true : false;
  7. struct VS_INPUT
  8. {
  9. // This is all of the stuff that we ever use.
  10. float4 vPos : POSITION;
  11. float4 vColor : COLOR0;
  12. // make these float2's and stick the [n n 0 1] in the dot math.
  13. float4 vTexCoord0 : TEXCOORD0;
  14. };
  15. struct VS_OUTPUT
  16. {
  17. float4 projPos : POSITION; // Projection-space position
  18. #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
  19. float fog : FOG;
  20. #endif
  21. float2 baseTexCoord : TEXCOORD0; // Base texture coordinate
  22. float4 color : TEXCOORD2; // Vertex color (from lighting or unlit)
  23. float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog
  24. };
  25. VS_OUTPUT main( const VS_INPUT v )
  26. {
  27. VS_OUTPUT o = ( VS_OUTPUT )0;
  28. float3 worldPos;
  29. worldPos = mul4x3( v.vPos, cModel[0] );
  30. // Transform into projection space
  31. float4 projPos = mul( float4( worldPos, 1 ), cViewProj );
  32. o.projPos = projPos;
  33. #ifdef _PS3
  34. // Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1]
  35. o.projPos.y = -o.projPos.y;
  36. o.projPos.z = 2.0f * o.projPos.z - o.projPos.w;
  37. #endif // _PS3
  38. o.worldPos_projPosZ = float4( worldPos.xyz, projPos.z );
  39. #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
  40. o.fog = CalcFixedFunctionFog( worldPos, g_FogType );
  41. #endif
  42. if ( g_bVertexColor )
  43. {
  44. // Assume that this is unlitgeneric if you are using vertex color.
  45. #if SRGB
  46. o.color.rgba = GammaToLinear( v.vColor.rgba );
  47. #else
  48. o.color.rgba = v.vColor.rgba;
  49. #endif
  50. }
  51. // Base texture coordinates
  52. o.baseTexCoord.xy = v.vTexCoord0.xy;
  53. return o;
  54. }