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.

53 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: "TEXTURE2" "0..1"
  4. // DYNAMIC: "PIXELFOGTYPE" "0..1"
  5. // DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps20b] [PC]
  6. // DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20b] [XBOX]
  7. #if defined( SHADER_MODEL_PS_2_0 )
  8. # define WRITE_DEPTH_TO_DESTALPHA 0
  9. #endif
  10. #include "shader_constant_register_map.h"
  11. #include "common_ps_fxc.h"
  12. sampler BaseTextureSampler : register( s0 );
  13. sampler SecondaryTextureSampler : register( s1 );
  14. const float4 g_Contrast : register( c1 );
  15. const float4 g_Saturation : register( c2 );
  16. const float4 g_Tint : register( c3 );
  17. const float4 g_FogParams : register( PSREG_FOG_PARAMS );
  18. const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT );
  19. #define g_Grey float4( 0.33333f, 0.33333f, 0.33333f, 0.33333f )
  20. struct PS_INPUT
  21. {
  22. float2 vTexCoord0 : TEXCOORD0;
  23. float2 vTexCoord1 : TEXCOORD1;
  24. float4 vColor : COLOR0;
  25. float4 worldPos_projPosZ : TEXCOORD7;
  26. };
  27. float4 main( PS_INPUT i ) : COLOR
  28. {
  29. float4 resultColor = tex2D( BaseTextureSampler, i.vTexCoord0 ) * i.vColor; // base texture modulated with vertex color
  30. #if (TEXTURE2 == 1)
  31. resultColor = tex2D( SecondaryTextureSampler, i.vTexCoord1 ) * resultColor; // modulate base color by another texture
  32. #endif
  33. float3 tempColor = resultColor.rgb * resultColor.rgb; //base * base
  34. resultColor.rgb = lerp( resultColor.rgb, tempColor.rgb, g_Contrast.rgb ); // blend between color and color * color
  35. tempColor = dot( resultColor.rgb, g_Grey ); // color greyscaled
  36. resultColor.rgb = lerp( tempColor.rgb, resultColor.rgb, g_Saturation.rgb ); // blend between color and greyscale
  37. resultColor.rgb = resultColor.rgb * g_Tint.rgb; // tint
  38. float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.z, i.worldPos_projPosZ.z, i.worldPos_projPosZ.w );
  39. return FinalOutput( resultColor, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_NONE, (WRITE_DEPTH_TO_DESTALPHA != 0), i.worldPos_projPosZ.w );
  40. }