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.

35 lines
1.0 KiB

  1. //========== Copyright (c) Valve Corporation, All rights reserved. ==========//
  2. #include "common_ps_fxc.h"
  3. #define NUM_TAPS 18
  4. struct PS_INPUT
  5. {
  6. float2 vPos : VPOS; // Normalized Screenpos, call ComputeScreenPos() to get useful 2D coordinates
  7. };
  8. sampler TexSampler : register( s0 );
  9. float2 vDir : register( c0 ); // This will be [1,0] or [0,1]
  10. float vCoeff[NUM_TAPS] : register( c33 );
  11. float4 main( PS_INPUT i ) : COLOR
  12. {
  13. // Center tap at vPos
  14. float4 sampleCenter = tex2D( TexSampler, saturate( ComputeScreenPos( i.vPos ) ) );
  15. float4 accum = vCoeff[0] * sampleCenter;
  16. // Positive and negative offsets per "loop" (we unroll because we can't actually index the constant store)
  17. [unroll]
  18. for ( int j=1; j < NUM_TAPS; j++ )
  19. {
  20. float4 sample0 = tex2D( TexSampler, saturate( ComputeScreenPos( i.vPos + ( vDir * j ) ) ) );
  21. accum += vCoeff[j] * sample0;
  22. float4 sample1 = tex2D( TexSampler, saturate( ComputeScreenPos( i.vPos - ( vDir * j ) ) ) );
  23. accum += vCoeff[j] * sample1;
  24. }
  25. return max( 0, accum );
  26. }