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.

60 lines
1.7 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. const HALF4 settings : register( c0 );
  9. // x=sharpness,y=woodcut,z=bloom_amt,w=alpha sharpen factor
  10. const HALF4 settings2 : register( c1 ); // x=bloom exp,y=vignette min scale z=vignette_power
  11. struct PS_INPUT
  12. {
  13. float2 texCoord : TEXCOORD0;
  14. float2 ZeroTexCoord : TEXCOORD1;
  15. float2 bloomTexCoord : TEXCOORD2;
  16. };
  17. float4 main( PS_INPUT i ) : COLOR
  18. {
  19. float4 fbSample = tex2D( FBSampler, i.texCoord );
  20. float4 bloom=tex2D(BloomSampler,i.bloomTexCoord);
  21. float2 xofs=2*(i.texCoord-float2(0.5,0.5));
  22. float dist=(1.0/2.0)*(xofs.x*xofs.x+xofs.y*xofs.y);
  23. float vig=pow(1-dist,settings2.z);
  24. fbSample=lerp(fbSample,bloom,(1-vig)*settings2.w);
  25. fbSample=lerp(bloom,fbSample,settings.x+settings.w*fbSample.a*settings2.w);
  26. float3 woodcut;
  27. if (bloom.x<fbSample.x)
  28. woodcut.x=1.0;
  29. else
  30. woodcut.x=0.0;
  31. if (bloom.y<fbSample.y)
  32. woodcut.y=1.0;
  33. else
  34. woodcut.y=0.0;
  35. if (bloom.z<fbSample.z)
  36. woodcut.z=1.0;
  37. else
  38. woodcut.z=0.0;
  39. fbSample.xyz=lerp(fbSample.xyz,woodcut.xyz,settings.y);
  40. bloom.xyz*=sqrt(LINEAR_LIGHT_SCALE);
  41. bloom.xyz=min(bloom.xyz,1.0);
  42. float lum=.3*bloom.x+.59*bloom.y+.11*bloom.z;
  43. lum=min(1.0,lum);
  44. float4 c_out=float4(cLightScale.xyz, 1) * fbSample + settings.z * pow(lum, settings2.x) * bloom;
  45. // calculate vignette (lens brightness falloff near edges)
  46. c_out.xyz*=max(settings2.y,vig);
  47. return FinalOutput( c_out, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
  48. }