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.

48 lines
1.6 KiB

  1. //====== Copyright � 1996-2004, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. // STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
  7. // STATIC: "CONVERT_TO_SRGB" "0..1" [ps30][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
  8. // STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX]
  9. // DYNAMIC: "PIXELFOGTYPE" "0..1"
  10. // DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps20b] [PC]
  11. // DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20b] [XBOX]
  12. // DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps30]
  13. #if defined( SHADER_MODEL_PS_2_0 )
  14. # define WRITE_DEPTH_TO_DESTALPHA 0
  15. #endif
  16. #include "common_ps_fxc.h"
  17. #include "shader_constant_register_map.h"
  18. sampler BaseTextureSampler : register( s0 );
  19. const float4 g_FogParams : register( PSREG_FOG_PARAMS );
  20. const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT );
  21. struct PS_INPUT
  22. {
  23. float2 baseTexCoord : TEXCOORD0;
  24. float3 vertAtten : TEXCOORD1;
  25. float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog
  26. };
  27. float4 main( PS_INPUT i ) : COLOR
  28. {
  29. float4 baseSample = tex2D( BaseTextureSampler, i.baseTexCoord );
  30. float4 result;
  31. result.xyz = baseSample.xyz * i.vertAtten;
  32. result.a = baseSample.a;
  33. float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.z, i.worldPos_projPosZ.z, i.worldPos_projPosZ.w );
  34. return FinalOutput( result, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, (WRITE_DEPTH_TO_DESTALPHA != 0), i.worldPos_projPosZ.w );
  35. }