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.

45 lines
1.7 KiB

  1. //======= Copyright � 1996-2006, Valve Corporation, All rights reserved. ======
  2. // STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
  3. // STATIC: "CONVERT_TO_SRGB" "0..1" [ps30][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
  4. // STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX]
  5. // DYNAMIC: "PIXELFOGTYPE" "0..1"
  6. #include "common_ps_fxc.h"
  7. #include "shader_constant_register_map.h"
  8. sampler TexSampler : register( s0 );
  9. const float4 g_FogParams : register( PSREG_FOG_PARAMS );
  10. const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT );
  11. struct PS_INPUT
  12. {
  13. HALF2 baseTexCoord : TEXCOORD0; // Base texture coordinate
  14. float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog
  15. float4 fogFactorW : COLOR1;
  16. #if defined( _X360 ) //matching pixel shader inputs to vertex shader outputs to avoid shader patches
  17. HALF2 detailTexCoord : TEXCOORD1;
  18. float4 color : TEXCOORD2;
  19. float3 worldVertToEyeVector : TEXCOORD3;
  20. float3 worldSpaceNormal : TEXCOORD4;
  21. float4 vProjPos : TEXCOORD6;
  22. #endif
  23. };
  24. float4 main( PS_INPUT i ) : COLOR
  25. {
  26. float4 result = tex2D( TexSampler, i.baseTexCoord );
  27. float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.z, i.worldPos_projPosZ.z, i.worldPos_projPosZ.w );
  28. // Since we're blending with a mod2x, we need to compensate with this hack
  29. // NOTE: If the fog color (not fog density) is extremely dark, this can makes some decals seem
  30. // a little transparent, but it's better than not doing this
  31. fogFactor = pow( saturate( fogFactor ), 0.4f );
  32. return FinalOutput( result, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_NONE );
  33. }