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.

35 lines
1.0 KiB

  1. //======= Copyright � 1996-2006, Valve Corporation, All rights reserved. ======
  2. #include "common_ps_fxc.h"
  3. sampler TexSampler : register( s0 );
  4. sampler TexRed : register( s1 );
  5. sampler TexGreen : register( s2 );
  6. sampler TexBlue : register( s3 );
  7. float g_flDimValue : register( c0 );
  8. struct PS_INPUT
  9. {
  10. HALF2 baseTexCoord : TEXCOORD0; // Base texture coordinate
  11. };
  12. float4 main( PS_INPUT i ) : COLOR
  13. {
  14. float4 result = tex2D( TexSampler, i.baseTexCoord );
  15. // Scale by dim value before computing luminance below
  16. result.rgb *= saturate( g_flDimValue );
  17. // Fetch into 1D textures based on the intensity of each color channel and sum
  18. float4 vRed = tex2D( TexRed, pow( result.r, 0.45 ) );
  19. float4 vGreen = tex2D( TexGreen, pow( result.g, 0.45 ) );
  20. float4 vBlue = tex2D( TexBlue, pow( result.b, 0.45 ) );
  21. result.rgb = vRed.rgb + vGreen.rgb + vBlue.rgb;
  22. // Store max color component in alpha for alpha blend of one/invSrcAlpha
  23. float flLuminance = max( result.r, max( result.g, result.b ) );
  24. result.a = flLuminance;
  25. return result.rgba;
  26. }