Team Fortress 2 Source Code as on 22/4/2020
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.

45 lines
1.0 KiB

  1. // STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
  2. // STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX]
  3. #define HDRTYPE HDR_TYPE_NONE
  4. #include "common_ps_fxc.h"
  5. sampler LowSampler : register( s0 );
  6. sampler HiSampler : register( s1 );
  7. struct PS_INPUT
  8. {
  9. float2 texCoord : TEXCOORD0;
  10. };
  11. struct MYHDR_PS_OUTPUT
  12. {
  13. float4 color[2] : COLOR0;
  14. };
  15. MYHDR_PS_OUTPUT main( PS_INPUT i ) : COLOR
  16. {
  17. float3 lowColor = GammaToLinear( tex2D( LowSampler, i.texCoord ) );
  18. float3 hiColor = GammaToLinear( tex2D( HiSampler, i.texCoord ) );
  19. float4 lowOut;
  20. lowOut.a = 1.0f;
  21. float4 hiOut;
  22. hiOut.a = 1.0f;
  23. float3 hdrColor = max( lowColor, hiColor * MAX_HDR_OVERBRIGHT );
  24. float fMax = max( hdrColor.b, max( hdrColor.r, hdrColor.g ) );
  25. float blendFactor = saturate( ( fMax - 0.9f ) * 10.0f );
  26. blendFactor = 1.0f;
  27. lowOut.rgb = LinearToGamma( lowColor * ( 1.0f - blendFactor ) );
  28. hiOut.rgb = LinearToGamma( hiColor * ( blendFactor ) );
  29. MYHDR_PS_OUTPUT output;
  30. output.color[0] = lowOut;
  31. output.color[1] = hiOut;
  32. return output;
  33. }