Counter Strike : Global Offensive Source Code
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.

40 lines
1.1 KiB

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