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.

43 lines
1.3 KiB

  1. // STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
  2. // STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX]
  3. // STATIC: "PASS" "0..1"
  4. #define HDRTYPE HDR_TYPE_NONE
  5. #include "common_ps_fxc.h"
  6. // CENTROID: TEXCOORD1
  7. sampler BaseSampler : register( s0 );
  8. sampler LightmapSampler: register( s1 );
  9. sampler LightmapAlphaSampler: register( s2 );
  10. struct PS_INPUT
  11. {
  12. float2 baseCoord : TEXCOORD0;
  13. float2 lightmapCoord : TEXCOORD1;
  14. };
  15. float4 main( PS_INPUT i ) : COLOR
  16. {
  17. bool bAlphaPass = PASS ? true : false;
  18. float4 base = tex2D( BaseSampler, i.baseCoord );
  19. float4 lightmap = tex2D( LightmapSampler, i.lightmapCoord );
  20. float4 alpha = tex2D( LightmapAlphaSampler, i.lightmapCoord );
  21. float4 color;
  22. base.a = dot( base, HALF3( HALF_CONSTANT(0.33333f), HALF_CONSTANT(0.33333f), HALF_CONSTANT(0.33333f) ) );
  23. color = 2.0f * base * lightmap; // The 2x is for an assumed overbright 2 (it's always 2 on dx9)
  24. if( bAlphaPass )
  25. {
  26. // Don't care about color, just return pre-multiplied alpha
  27. return FinalOutput( float4( 0.0f, 0.0f, 1.0f, (1.0f - alpha.a) * color.a ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
  28. }
  29. else
  30. {
  31. return FinalOutput( float4( color.rgb, (1.0f - alpha.a) ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
  32. }
  33. }