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.

72 lines
2.4 KiB

  1. //========== Copyright (c) Valve Corporation, All rights reserved. ==========//
  2. #include "common_ps_fxc.h"
  3. #include "shader_constant_register_map.h"
  4. // SAMPLERS
  5. sampler BaseSampler : register( s0 );
  6. // REGISTERS
  7. //for normalized screen-space coords
  8. const float4 g_fvConstRegister17 : register( c17 );
  9. const float4 g_fvConstRegister18 : register( c18 );
  10. #define g_vEyePos g_fvConstRegister18.xyz
  11. #define g_flElementDistance g_fvConstRegister18.w
  12. const float4 g_fvConstRegister0 : register( c0 );
  13. #define g_flOnePixelX g_fvConstRegister0.x
  14. #define g_flOnePixelY g_fvConstRegister0.y
  15. #define g_vOnePixel g_fvConstRegister0.xy
  16. const float4 g_DiffuseModulation : register( c1 );
  17. struct PS_INPUT
  18. {
  19. //float4 lightAtten : TEXCOORD2;
  20. float3 worldPos : TEXCOORD3;
  21. float3x3 tangentSpaceTranspose : TEXCOORD4;
  22. // second row : TEXCOORD5;
  23. // third row : TEXCOORD6;
  24. float4 vProjPos : TEXCOORD7;
  25. };
  26. float4_color_return_type main( PS_INPUT i ) : COLOR
  27. {
  28. float2 vScreenPos = (i.vProjPos.xy / i.vProjPos.w) * g_fvConstRegister17.xy + g_fvConstRegister17.zw;
  29. vScreenPos += (g_vOnePixel * 0.5f);
  30. float flEdgeThickness = 5.0f;
  31. float flDist = smoothstep( 300.0f, 800.f, length( g_vEyePos.xyz - i.worldPos.xyz ) );
  32. flEdgeThickness -= ( 3.5f * flDist );
  33. float flCenter = -1.0f;
  34. float2 offsets[16] = {
  35. float2( 0.5301946, 0.5073427 ),
  36. float2( 0.0684771, 0.4128032 ),
  37. float2( 0.5126259, 0.0365609 ),
  38. float2( 0.0101744, 0.8379333 ),
  39. float2( 0.1560884, -0.1649500 ),
  40. float2( 0.9068975, -0.0846123 ),
  41. float2( 0.6797046, -0.5736184 ),
  42. float2( -0.4168866, 0.8836493 ),
  43. float2( -0.5666743, 0.3535654 ),
  44. float2( -0.0424080, -0.6649325 ),
  45. float2( 0.3658477, -0.8909833 ),
  46. float2( -0.4150895, -0.2524949 ),
  47. float2( -0.9276293, 0.0097100 ),
  48. float2( 0.4289346, 0.9020033 ),
  49. float2( -0.6507930, -0.6037632 ),
  50. float2( -0.2034065, 0.1169684 )
  51. };
  52. for ( int k = 0; k < 16; k++ )
  53. {
  54. flCenter += tex2D( BaseSampler, vScreenPos + g_vOnePixel * offsets[k] * flEdgeThickness ).g * 0.125f;
  55. }
  56. flCenter = saturate( 1.0f - abs( flCenter ) );
  57. float4 cOut = float4( g_DiffuseModulation.rgb * flCenter, 1 );
  58. return FinalOutput( cOut, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_LINEAR );
  59. }