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.

67 lines
1.6 KiB

  1. // STATIC: "HASALPHAMASK" "0..1"
  2. // STATIC: "HASSTATICTEXTURE" "0..1"
  3. // DYNAMIC: "HDRENABLED" "0..1"
  4. // DYNAMIC: "PIXELFOGTYPE" "0..1"
  5. #include "common_ps_fxc.h"
  6. const HALF3 g_StaticAmount : register( c0 ); //x is static, y is 1.0 - static
  7. #if( HASSTATICTEXTURE )
  8. sampler StaticTextureSampler : register( s0 );
  9. # if( HASALPHAMASK )
  10. sampler AlphaMaskSampler : register( s1 );
  11. # endif
  12. #else
  13. # if( HASALPHAMASK )
  14. sampler AlphaMaskSampler : register( s0 );
  15. # endif
  16. #endif
  17. struct PS_INPUT
  18. {
  19. float4 vProjPos : POSITION;
  20. //vStaticTexCoord and vAlphaMaskTexCoord are the same numbers, but we need to map TEXCOORD0 to sampler 0, and TEXCOORD1 to sampler1. ps11 compatibility issue
  21. #if( HASSTATICTEXTURE )
  22. float2 vStaticTexCoord : TEXCOORD0;
  23. # if( HASALPHAMASK )
  24. float2 vAlphaMaskTexCoord : TEXCOORD1;
  25. # endif
  26. #else
  27. # if( HASALPHAMASK )
  28. float2 vAlphaMaskTexCoord : TEXCOORD0;
  29. # else
  30. float2 vUnusedTexCoord1 : TEXCOORD0;
  31. # endif
  32. float2 vUnusedTexCoord2 : TEXCOORD1;
  33. #endif
  34. };
  35. HALF4 main( PS_INPUT i ) : COLOR
  36. {
  37. HALF4 result;
  38. # if( HASSTATICTEXTURE )
  39. result.rgb = tex2D( StaticTextureSampler, i.vStaticTexCoord ).rgb;
  40. # else
  41. result.rgb = 0.25; //without a static texture, just be gray
  42. # endif
  43. # if( HASALPHAMASK )
  44. result.a = min( g_StaticAmount.x, tex2D( AlphaMaskSampler, i.vAlphaMaskTexCoord ).a ); //when static reaches 0, fades away completely, also never exceeds the mask's alpha
  45. # else
  46. result.a = g_StaticAmount.x; //when static reaches 0, fades away completely
  47. # endif
  48. //result.r = 1.0;
  49. //result.gb = 0.0;
  50. //result.a = 0.5;
  51. return result;
  52. }