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.

32 lines
881 B

  1. //========== Copyright (c) Valve Corporation, All rights reserved. ==========//
  2. #include "common_ps_fxc.h"
  3. struct PS_INPUT
  4. {
  5. float2 vPos : VPOS; // Normalized Screenpos, call ComputeScreenPos() to get useful 2D coordinates
  6. };
  7. sampler TexSampler : register( s0 );
  8. float3 Shape( float3 cColor )
  9. {
  10. float flLum = saturate(dot( cColor.xyz, float3( 0.3f, 0.59f, 0.11f) ));
  11. cColor.xyz *= flLum * flLum * flLum * flLum; // TODO: parametrize this
  12. return cColor;
  13. }
  14. float4 main( PS_INPUT i ) : COLOR
  15. {
  16. // NOTE: Shape simulates what downsample_nohdr does to the pixel color
  17. float4 result = tex2D( TexSampler, saturate( ComputeScreenPos( i.vPos ) ) );
  18. // Local contrast needs gamma luminance in alpha
  19. float3 vGamma = SrgbLinearToGamma( result.rgb );
  20. result.a = dot( vGamma, float3( 0.299, 0.587, 0.114 ) );
  21. result.rgb = Shape( result.rgb );
  22. return max( 0, result );
  23. }