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.

44 lines
1.4 KiB

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