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.

72 lines
2.0 KiB

  1. // STATIC: "ADDBASETEXTURE2" "0..1"
  2. // STATIC: "ADDSELF" "0..1"
  3. // STATIC: "USEALPHAASRGB" "0..1"
  4. // SKIP: $USEALPHAASRGB && $ADDSELF
  5. // SKIP: $USEALPHAASRGB && $ADDBASETEXTURE2
  6. #define HDRTYPE HDR_TYPE_NONE
  7. #include "common_ps_fxc.h"
  8. struct PS_INPUT
  9. {
  10. float2 texCoord0 : TEXCOORD0;
  11. float2 texCoord1 : TEXCOORD1;
  12. float4 argbcolor : COLOR;
  13. float4 blendfactor0 : TEXCOORD2;
  14. #if ADDBASETEXTURE2
  15. float2 texCoord2 : TEXCOORD3;
  16. #endif
  17. float4 vScreenPos : TEXCOORD7;
  18. };
  19. sampler BaseTextureSampler : register( s0 );
  20. #if ADDBASETEXTURE2
  21. sampler BaseTextureSampler2 : register( s3 );
  22. #endif
  23. sampler BaseTextureSampler1 : register( s1 );
  24. const float4 g_Parameters : register( c0 );
  25. const float4 g_ColorPowers : register( c1 );
  26. #define fAdditiveBlendWeight g_Parameters.x
  27. #define fOverbrightFactor g_Parameters.y
  28. #define fAdditiveSelfBlendWeight g_Parameters.z
  29. #define fSoftParticleBlendScale g_Parameters.w
  30. #pragma warning( disable : 4707 4704 )
  31. float4 main( PS_INPUT i ) : COLOR
  32. {
  33. // Sample frames from texture 0
  34. #if ( ! ADDSELF ) && ( ! ADDBASETEXTURE2 )
  35. float4 baseTex0 = tex2D( BaseTextureSampler, i.texCoord0 );
  36. float4 baseTex1 = tex2D( BaseTextureSampler1, i.texCoord1 );
  37. float4 blended_rgb = lerp( baseTex0, baseTex1, i.blendfactor0.x );
  38. #else
  39. float4 blended_rgb = tex2D( BaseTextureSampler, i.texCoord0 );
  40. #endif
  41. #if USEALPHAASRGB
  42. blended_rgb.rgb = blended_rgb.a;
  43. #endif
  44. #if ADDBASETEXTURE2
  45. blended_rgb.a *= i.argbcolor.a;
  46. // In this case, we don't really want to pre-multiply by alpha
  47. float4 color2 = tex2D( BaseTextureSampler2, i.texCoord2 );
  48. blended_rgb.rgb *= blended_rgb.a;
  49. blended_rgb.rgb += fOverbrightFactor * fAdditiveBlendWeight * i.argbcolor.a * color2;
  50. blended_rgb.rgb *= 2 * i.argbcolor.rgb;
  51. #else
  52. #if ADDSELF
  53. blended_rgb.a *= i.argbcolor.a;
  54. blended_rgb.rgb *= blended_rgb.a;
  55. blended_rgb.rgb += fOverbrightFactor * 8 * fAdditiveSelfBlendWeight * blended_rgb;
  56. blended_rgb.rgb *= 2 * i.argbcolor.rgb;
  57. #else
  58. blended_rgb *= i.argbcolor;
  59. #endif
  60. #endif
  61. return blended_rgb;
  62. }