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.

72 lines
2.1 KiB

  1. //========== Copyright (c) Valve Corporation, All rights reserved. ==========//
  2. // STATIC: "VERTEXCOLOR" "0..1"
  3. // STATIC: "CONSTANTCOLOR" "0..1"
  4. // STATIC: "HDRTYPE" "0..2"
  5. // STATIC: "SRGB" "0..1"
  6. // STATIC: "SRGB_OUTPUT_ADAPTER" "0..1" [ps20b]
  7. // DYNAMIC: "HDRENABLED" "0..1"
  8. #include "common_fog_ps_fxc.h"
  9. #include "common_ps_fxc.h"
  10. #include "shader_constant_register_map.h"
  11. const float4 g_Color : register( c0 );
  12. const float g_HDRColorScale : register( c1 );
  13. const float4 g_FogParams : register( PSREG_FOG_PARAMS );
  14. const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT );
  15. sampler TexSampler : register( s0 );
  16. struct PS_INPUT
  17. {
  18. float2 baseTexCoord : TEXCOORD0; // Base texture coordinate
  19. float4 color : TEXCOORD2; // Vertex color (from lighting or unlit)
  20. float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog
  21. };
  22. float4_color_return_type main( PS_INPUT i ) : COLOR
  23. {
  24. #if defined(_X360) && defined( CSTRIKE15 )
  25. // [mariod] - gamma appropriate sprites without adding an extra SHADER_SRGB_READ combo (SRGB provides same info implicitly)
  26. #if SRGB
  27. // fix up properly when SHADER_SRGB_READ is added to this shader
  28. float4 result, sample = tex2D( TexSampler, i.baseTexCoord );
  29. sample.rgb = GammaToLinear( sample.rgb );
  30. #else
  31. float4 result, sample = tex2D( TexSampler, i.baseTexCoord );
  32. #endif
  33. #else
  34. float4 result, sample = tex2D( TexSampler, i.baseTexCoord );
  35. #endif
  36. #if VERTEXCOLOR
  37. sample *= i.color;
  38. #endif
  39. #if CONSTANTCOLOR
  40. sample *= g_Color;
  41. #endif
  42. #if HDRTYPE && HDRENABLED
  43. sample.xyz *= g_HDRColorScale;
  44. #endif
  45. float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w );
  46. #if SRGB
  47. result = FinalOutput( sample, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR );
  48. #else
  49. result = FinalOutput( sample, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_GAMMA );
  50. #endif
  51. // On Posix, we're being forced through a linear-to-gamma curve but don't want it, so we do the opposite here first
  52. #if SRGB_OUTPUT_ADAPTER
  53. result = GammaToLinear( result );
  54. #endif
  55. return result;
  56. }