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.

73 lines
2.1 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: "HDRENABLED" "0..1"
  6. // DYNAMIC: "PIXELFOGTYPE" "0..1"
  7. #include "common_ps_fxc.h"
  8. #include "shader_constant_register_map.h"
  9. const HALF3 g_StaticAmount : register( c0 ); //x is static, y is 1.0 - static
  10. const float4 g_FogParams : register( PSREG_FOG_PARAMS );
  11. const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT );
  12. #if( HASSTATICTEXTURE )
  13. sampler StaticTextureSampler : register( s0 );
  14. # if( HASALPHAMASK )
  15. sampler AlphaMaskSampler : register( s1 );
  16. # endif
  17. #else
  18. # if( HASALPHAMASK )
  19. sampler AlphaMaskSampler : register( s0 );
  20. # endif
  21. #endif
  22. struct PS_INPUT
  23. {
  24. float4 vProjPos : POSITION;
  25. //vStaticTexCoord and vAlphaMaskTexCoord are the same numbers, but we need to map TEXCOORD0 to sampler 0, and TEXCOORD1 to sampler1. ps11 compatibility issue
  26. #if( HASSTATICTEXTURE )
  27. float2 vStaticTexCoord : TEXCOORD0;
  28. # if( HASALPHAMASK )
  29. float2 vAlphaMaskTexCoord : TEXCOORD1;
  30. # endif
  31. #else
  32. # if( HASALPHAMASK )
  33. float2 vAlphaMaskTexCoord : TEXCOORD0;
  34. # else
  35. float2 vUnusedTexCoord1 : TEXCOORD0;
  36. # endif
  37. float2 vUnusedTexCoord2 : TEXCOORD1;
  38. #endif
  39. float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog
  40. };
  41. float4 main( PS_INPUT i ) : COLOR
  42. {
  43. HALF4 result;
  44. # if( HASSTATICTEXTURE )
  45. result.rgb = tex2D( StaticTextureSampler, i.vStaticTexCoord ).rgb;
  46. # else
  47. result.rgb = 0.25; //without a static texture, just be gray
  48. # endif
  49. # if( HASALPHAMASK )
  50. 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
  51. # else
  52. result.a = g_StaticAmount.x; //when static reaches 0, fades away completely
  53. # endif
  54. float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.z, i.worldPos_projPosZ.z, i.worldPos_projPosZ.w );
  55. return FinalOutput( result, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR );
  56. }