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.

74 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. const float4 cShaderConst0 : register( SHADER_SPECIFIC_CONST_0 );
  5. const float4 cShaderConst1 : register( SHADER_SPECIFIC_CONST_1 );
  6. struct VS_INPUT
  7. {
  8. float4 vPos : POSITION;
  9. float4 vTexCoord0 : TEXCOORD0;
  10. float4 vTexCoord1 : TEXCOORD1;
  11. float2 vTexCoord2 : TEXCOORD2;
  12. float4 vColor : COLOR0;
  13. };
  14. struct VS_OUTPUT
  15. {
  16. float4 vProjPos : POSITION;
  17. float2 vTexCoord0 : TEXCOORD0;
  18. float2 vTexCoord1 : TEXCOORD1;
  19. float2 vTexCoord2 : TEXCOORD2;
  20. float2 vTexCoord3 : TEXCOORD3;
  21. float4 worldPos_projPosZ : TEXCOORD4; // Necessary for pixel fog
  22. float4 vColor : COLOR0;
  23. #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
  24. float fog : FOG;
  25. #endif
  26. };
  27. VS_OUTPUT main( const VS_INPUT v )
  28. {
  29. VS_OUTPUT o = ( VS_OUTPUT )0;
  30. float3 worldPos;
  31. worldPos = mul4x3( v.vPos, cModel[0] );
  32. o.vProjPos = mul( float4( worldPos, 1 ), cViewProj );
  33. #ifdef _PS3
  34. // Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1]
  35. o.vProjPos.y = -o.vProjPos.y;
  36. o.vProjPos.z = 2.0f * o.vProjPos.z - o.vProjPos.w;
  37. #endif // _PS3
  38. o.worldPos_projPosZ = float4( worldPos.xyz, o.vProjPos.z );
  39. #if !defined( _X360 ) && !defined( _PS3 ) && !defined( SHADER_MODEL_VS_3_0 )
  40. o.fog = CalcFixedFunctionFog( worldPos, g_FogType );
  41. #endif
  42. // Compute the texture coordinates given the offset between
  43. // each bumped lightmap
  44. float2 offset;
  45. offset.x = v.vTexCoord2.x;
  46. offset.y = 0.0f;
  47. o.vTexCoord0.x = dot( v.vTexCoord0, cShaderConst0 );
  48. o.vTexCoord0.y = dot( v.vTexCoord0, cShaderConst1 );
  49. o.vTexCoord1 = offset + v.vTexCoord1.xy;
  50. o.vTexCoord2 = (offset * 2.0) + v.vTexCoord1.xy;
  51. o.vTexCoord3 = (offset * 3.0) + v.vTexCoord1.xy;
  52. o.vColor = v.vColor;
  53. return o;
  54. }