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.

48 lines
1.5 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_FLOAT
  4. #define HDRENABLED 1
  5. #include "common_ps_fxc.h"
  6. sampler FBSampler : register( s0 );
  7. sampler BloomSampler : register( s1 );
  8. sampler Exposure_Sampler : register( s2 );
  9. const HALF4 settings : register( c0 );
  10. // x=sharpness,y=woodcut,z=bloom_amt,w=alpha sharpen factor
  11. const HALF4 settings2 : register( c1 ); // x=bloom exp,y=vignette min scale z=vignette_power
  12. const HALF4 settings3 : register( c2 ); // x=autoexpose min y=autoexpose_max
  13. struct PS_INPUT
  14. {
  15. float2 texCoord : TEXCOORD0;
  16. float2 ZeroTexCoord : TEXCOORD1;
  17. };
  18. float4 main( PS_INPUT i ) : COLOR
  19. {
  20. float4 fbSample = tex2D( FBSampler, i.texCoord );
  21. float4 bloom=tex2D(BloomSampler,i.texCoord);
  22. float4 exposure_data=tex2D(Exposure_Sampler,i.ZeroTexCoord);
  23. float avg_lum=exposure_data.r;
  24. float tmscale=max(0.18/max(avg_lum,0.0001),settings3.x);
  25. tmscale=min(tmscale,settings3.y);
  26. float2 xofs=2*(i.texCoord-float2(0.5,0.5));
  27. float dist=(1.0/2.0)*(xofs.x*xofs.x+xofs.y*xofs.y);
  28. float vig=pow(1-dist,settings2.z);
  29. fbSample=lerp(fbSample,bloom,(1-vig)*settings2.w);
  30. fbSample=lerp(bloom,fbSample,settings.x+settings.w*fbSample.a*settings2.w);
  31. bloom.xyz=min(bloom.xyz,1.0);
  32. float lum=.3*bloom.x+.59*bloom.y+.11*bloom.z;
  33. lum=min(1.0,lum);
  34. float4 c_out=(fbSample)+settings.z*pow(lum,settings2.x)*bloom;
  35. c_out.xyz*=tmscale;
  36. return FinalOutput( c_out, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
  37. }