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.

87 lines
2.3 KiB

  1. // STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
  2. // STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX]
  3. // STATIC: "HASALPHAMASK" "0..1"
  4. // STATIC: "HASSTATICTEXTURE" "0..1"
  5. // DYNAMIC: "ADDSTATIC" "0..1"
  6. // DYNAMIC: "HDRENABLED" "0..1"
  7. // DYNAMIC: "PIXELFOGTYPE" "0..1"
  8. #define USESTATICTEXTURE (((ADDSTATIC == 1) && (HASSTATICTEXTURE == 1))?(1):(0))
  9. #include "common_ps_fxc.h"
  10. #include "shader_constant_register_map.h"
  11. const float4 g_StaticAmount : register( c0 ); //x is static, y is 1.0 - static
  12. const float4 g_FogParams : register( PSREG_FOG_PARAMS );
  13. const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT );
  14. sampler PortalSampler : register( s0 );
  15. #if( (HASALPHAMASK == 1) || (USESTATICTEXTURE == 1) )
  16. sampler SecondarySampler : register( s1 );
  17. # if( (HASALPHAMASK == 1) && (USESTATICTEXTURE == 1) )
  18. sampler TertiarySampler : register( s2 );
  19. # endif
  20. #endif
  21. struct PS_INPUT
  22. {
  23. float3 vPortalTexCoord : TEXCOORD0;
  24. # if( (HASALPHAMASK == 1) || (USESTATICTEXTURE == 1) )
  25. float2 vSecondaryTexCoord : TEXCOORD1;
  26. # if( (HASALPHAMASK == 1) && (USESTATICTEXTURE == 1) )
  27. float2 vTertiaryTexCoord : TEXCOORD2;
  28. # endif
  29. # endif
  30. float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog
  31. };
  32. float4 main( PS_INPUT i ) : COLOR
  33. {
  34. HALF4 result;
  35. result.rgb = tex2D(PortalSampler, i.vPortalTexCoord.xy / i.vPortalTexCoord.z ).rgb;
  36. //mix in static
  37. # if( ADDSTATIC == 1 )
  38. {
  39. result.rgb *= g_StaticAmount.y; //inverse static on original colors
  40. # if( HASSTATICTEXTURE == 1 )
  41. {
  42. # if( HASALPHAMASK == 1 )
  43. result.rgb += tex2D(TertiarySampler, i.vTertiaryTexCoord ).rgb * g_StaticAmount.x; //static
  44. # else
  45. result.rgb += tex2D(SecondarySampler, i.vSecondaryTexCoord ).rgb * g_StaticAmount.x; //static
  46. # endif
  47. }
  48. # else
  49. {
  50. result.rgb += g_StaticAmount.x * 0.25; //mix in gray
  51. }
  52. # endif
  53. }
  54. # endif
  55. # if( HASALPHAMASK == 1 )
  56. {
  57. //alpha mask
  58. result.a = tex2D(SecondarySampler, i.vSecondaryTexCoord ).a;
  59. }
  60. # else
  61. {
  62. result.a = 1;
  63. }
  64. # endif
  65. float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.z, i.worldPos_projPosZ.z, i.worldPos_projPosZ.w );
  66. return FinalOutput( result, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR );
  67. }