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.

67 lines
1.7 KiB

  1. //========== Copyright (c) Valve Corporation, All rights reserved. ==========//
  2. #include "common_ps_fxc.h"
  3. sampler Tex1Sampler : register( s0 );
  4. sampler Tex2Sampler : register( s1 );
  5. const float4 g_Const0 : register( c0 );
  6. #define g_offsetX g_Const0.x
  7. #define g_offsetY g_Const0.y
  8. #define g_time g_Const0.z
  9. #define g_fadein g_Const0.w
  10. struct PS_INPUT
  11. {
  12. float2 vBaseUV : TEXCOORD0;
  13. };
  14. float4 main( PS_INPUT i ) : COLOR
  15. {
  16. float2 vUV = i.vBaseUV;
  17. float flDistortX = (vUV.x - 0.5) * 2.8;
  18. float flDistortY = (vUV.y - 0.5) * 2.5;
  19. float flToCenter = length( float2( flDistortX, flDistortY ) );
  20. float flAbbrScale = pow( flToCenter, 2 );
  21. // gather noise
  22. float2 vUVnoise0 = vUV * 1.5;
  23. vUVnoise0.x += g_time * 8;
  24. vUVnoise0.y += sin( g_time ) * 0.1;
  25. float flNoise0 = tex2D( Tex2Sampler, vUVnoise0 ).g;
  26. float2 vUVnoise1 = vUV * 1.2;
  27. vUVnoise1.x += g_time * 5;
  28. vUVnoise1.y += sin( g_time ) * 0.2;
  29. float flNoise1 = tex2D( Tex2Sampler, vUVnoise1 ).g;
  30. float flNoise = max( flNoise0, flNoise1 );
  31. // distort
  32. vUV.x += flNoise * 0.002 * flAbbrScale;
  33. // chromatic abberation
  34. float flR = tex2D( Tex1Sampler, vUV + flAbbrScale * float2(g_offsetX, 0) ).r;
  35. float flG = tex2D( Tex1Sampler, vUV + flAbbrScale * float2(g_offsetX, g_offsetY) ).g;
  36. float flB = tex2D( Tex1Sampler, vUV + flAbbrScale * float2(0, g_offsetY) ).b;
  37. float3 cOut = float3( flR, flG, flB );
  38. // desaturate edge
  39. const float3 coef = float3( 0.3, 0.59, 0.11 );
  40. cOut.rgb = lerp(cOut.rgb, dot(coef.rgb, cOut.rgb), saturate(flNoise * 4) );
  41. // lateral vignette
  42. float flBezel = saturate( abs( vUV.x - 0.5 ) - 0.48 ) * 50;
  43. cOut.rgb -= flBezel * flBezel * 0.1;
  44. // blue tint
  45. cOut.rg *= 0.9;
  46. // fade to black
  47. cOut.rgb = (cOut-g_fadein) * (1-g_fadein);
  48. return float4( cOut, 1 );
  49. }