Team Fortress 2 Source Code as on 22/4/2020
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.

49 lines
1.1 KiB

  1. // DYNAMIC: "CMBO_USERENDERTARGET" "0..1"
  2. #include "shader_constant_register_map.h"
  3. #include "common_ps_fxc.h"
  4. sampler BaseTextureSampler : register( s0 );
  5. sampler DistortMapTextureSampler : register( s1 );
  6. struct PS_INPUT
  7. {
  8. float2 vBaseTexCoord : TEXCOORD0;
  9. };
  10. float4 main( PS_INPUT i ) : COLOR
  11. {
  12. float2 vOriginal = i.vBaseTexCoord.xy;
  13. float4 vRead = tex2D( DistortMapTextureSampler, vOriginal );
  14. float2 vGreen;
  15. vGreen.r = ( vRead.x + vRead.z ) / 2.0;
  16. vGreen.g = ( vRead.y + vRead.w ) / 2.0;
  17. float4 vFinal;
  18. vFinal.r = tex2D( BaseTextureSampler, vRead.xy ).r;
  19. vFinal.ga = tex2D( BaseTextureSampler, vGreen ).ga;
  20. vFinal.b = tex2D( BaseTextureSampler, vRead.zw ).b;
  21. float fBoundsCheck;
  22. #if ( CMBO_USERENDERTARGET )
  23. {
  24. fBoundsCheck = saturate( dot( (vGreen.xy < float2(0.01,0.01)), float2(1,1)) + dot( (vGreen.xy > float2(0.99,0.99)), float2(1,1)) );
  25. }
  26. #else
  27. {
  28. fBoundsCheck = saturate( dot( (vGreen.xy < float2(0.005,0.005)), float2(1,1)) + dot( (vGreen.xy > float2(0.995,0.995)), float2(1,1))
  29. + (vGreen.x > 0.495 && vGreen.x < 0.505 ) );
  30. }
  31. #endif
  32. vFinal.xyz = lerp( vFinal.xyz, float3(0,0,0), fBoundsCheck );
  33. return vFinal;
  34. }