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.

76 lines
2.7 KiB

  1. // DYNAMIC: "PIXELFOGTYPE" "0..1"
  2. // DYNAMIC: "LIGHTING_PREVIEW" "0..2" [PC]
  3. // DYNAMIC: "LIGHTING_PREVIEW" "0..0" [XBOX]
  4. // DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps20b] [PC]
  5. // DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20b] [XBOX]
  6. // STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
  7. // STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX]
  8. #if defined( SHADER_MODEL_PS_2_0 )
  9. # define WRITE_DEPTH_TO_DESTALPHA 0
  10. #endif
  11. #include "common_ps_fxc.h"
  12. #include "shader_constant_register_map.h"
  13. const HALF4 g_DiffuseModulation : register( c1 );
  14. #if !FLASHLIGHT
  15. // we don't use these with HDR.
  16. const HALF3 g_EnvmapContrast : register( c2 );
  17. const HALF3 g_EnvmapSaturation : register( c3 );
  18. #endif
  19. const float4 g_FogParams : register( PSREG_FOG_PARAMS );
  20. const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT );
  21. const float4 g_FlashlightAttenuationFactors : register( c22 );
  22. const HALF3 g_FlashlightPos : register( c23 );
  23. const float4x4 g_FlashlightWorldToTexture : register( c24 ); // through c27
  24. sampler BaseTextureSampler : register( s0 );
  25. sampler BaseTextureSampler2 : register( s1 );
  26. struct PS_INPUT
  27. {
  28. float4 projPos : POSITION; // Projection-space position
  29. HALF2 baseTexCoord : TEXCOORD0; // Base texture coordinate
  30. HALF2 baseTexCoord2 : TEXCOORD1; // Base texture coordinate
  31. float4 worldPos_projPosZ : TEXCOORD7; // Necessary for water fog dest alpha
  32. float4 fogFactorW : COLOR1;
  33. #if defined( _X360 ) //matching pixel shader inputs to vertex shader outputs to avoid shader patches
  34. float4 vColor : COLOR0;
  35. #endif
  36. };
  37. #if LIGHTING_PREVIEW == 2
  38. LPREVIEW_PS_OUT main( PS_INPUT i ) : COLOR
  39. #else
  40. float4 main( PS_INPUT i ) : COLOR
  41. #endif
  42. {
  43. #if LIGHTING_PREVIEW
  44. # if LIGHTING_PREVIEW == 1
  45. return FinalOutput( float4( 0.0f, 0.0f, 0.0f, 1.0f ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_LINEAR );
  46. # else
  47. LPREVIEW_PS_OUT ret;
  48. float alpha = 1.0f;
  49. ret.flags=float4(1,1,1,1);
  50. ret.color=float4( 0.0f, 0.0f, 0.0f, alpha );
  51. ret.normal=float4( 0.0f, 0.0f, 1.0f, 1.0f );
  52. ret.position=float4( i.worldPos_projPosZ.xyz, alpha );
  53. return FinalOutput( ret, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
  54. # endif
  55. #else
  56. HALF4 baseColor = tex2D( BaseTextureSampler, i.baseTexCoord.xy );
  57. HALF4 baseColor2 = tex2D( BaseTextureSampler2, i.baseTexCoord2.xy );
  58. HALF4 result = baseColor * baseColor2 * g_DiffuseModulation;
  59. float alpha = 1.0f;
  60. float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.z, i.worldPos_projPosZ.z, i.worldPos_projPosZ.w );
  61. return FinalOutput( float4( result.rgb, alpha ), fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, (WRITE_DEPTH_TO_DESTALPHA != 0), i.worldPos_projPosZ.w );
  62. #endif
  63. }