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.

82 lines
2.0 KiB

  1. // STATIC: "SRGB_ADAPTER" "0..1" [ps20b] [PC]
  2. // STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b] [= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
  3. // STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX]
  4. // STATIC: "CSTRIKE" "0..1"
  5. #define HDRTYPE HDR_TYPE_NONE
  6. #include "common_ps_fxc.h"
  7. sampler TexSampler : register( s0 );
  8. float4 params : register( c0 );
  9. struct PS_INPUT
  10. {
  11. float2 coordTap0 : TEXCOORD0;
  12. float2 coordTap1 : TEXCOORD1;
  13. float2 coordTap2 : TEXCOORD2;
  14. float2 coordTap3 : TEXCOORD3;
  15. };
  16. #if ( CSTRIKE == 0 )
  17. //---------------------------------------//
  18. // Everything but Counter-Strike: Source //
  19. //---------------------------------------//
  20. float4 Shape( float2 uv )
  21. {
  22. float4 pixel = tex2D( TexSampler, uv );
  23. #if ( SRGB_ADAPTER == 1 )
  24. {
  25. pixel.rgb = LinearToGamma( pixel.rgb );
  26. }
  27. #endif
  28. float lum = dot( pixel.xyz, params.xyz );
  29. pixel.xyz = pow( pixel.xyz, params.w ) * lum;
  30. #if ( SRGB_ADAPTER == 1 )
  31. {
  32. pixel.rgb = GammaToLinear( pixel.rgb );
  33. }
  34. #endif
  35. return pixel;
  36. }
  37. float4 main( PS_INPUT i ) : COLOR
  38. {
  39. float4 s0, s1, s2, s3;
  40. // Sample 4 taps
  41. s0 = Shape( i.coordTap0 );
  42. s1 = Shape( i.coordTap1 );
  43. s2 = Shape( i.coordTap2 );
  44. s3 = Shape( i.coordTap3 );
  45. float4 avgColor = ( s0 + s1 + s2 + s3 ) * 0.25f;
  46. return FinalOutput( avgColor, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
  47. }
  48. #else
  49. //------------------------//
  50. // Counter-Strike: Source //
  51. //------------------------//
  52. float3 Shape( float3 s )
  53. {
  54. float lum = ( 0.3f * s.x ) + ( 0.59f * s.y ) + ( 0.11f * s.z );
  55. return lum * s;
  56. }
  57. float4 main( PS_INPUT i ) : COLOR
  58. {
  59. float3 s0, s1, s2, s3;
  60. // Sample 4 taps
  61. s0 = Shape( GammaToLinear( tex2D( TexSampler, i.coordTap0 ) ) );
  62. s1 = Shape( GammaToLinear( tex2D( TexSampler, i.coordTap1 ) ) );
  63. s2 = Shape( GammaToLinear( tex2D( TexSampler, i.coordTap2 ) ) );
  64. s3 = Shape( GammaToLinear( tex2D( TexSampler, i.coordTap3 ) ) );
  65. float3 avgColor = ( s0 + s1 + s2 + s3 ) * 0.25f;
  66. return float4( avgColor, 1.0f );
  67. }
  68. #endif