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.

64 lines
2.1 KiB

  1. //========== Copyright (c) Valve Corporation, All rights reserved. ==========//
  2. // STATIC: "SHADER_SRGB_READ" "0..1" [XBOX]
  3. // STATIC: "SHADER_SRGB_READ" "0..0" [PC]
  4. // STATIC: "SHADER_SRGB_READ" "0..0" [SONYPS3]
  5. // STATIC: "SHADOWDEPTH" "0..1"
  6. // STATIC: "ALPHATESTREF" "0..1"
  7. // DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps20b] [PC]
  8. // DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20b] [CONSOLE]
  9. // DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20]
  10. // SKIP: ( $ALPHATESTREF == 1 ) && ( $SHADOWDEPTH == 1 )
  11. #include "common_fog_ps_fxc.h"
  12. #include "common_ps_fxc.h"
  13. float4 g_FogParams : register( c0 );
  14. float4 g_EyePos : register( c1 );
  15. #if ( ALPHATESTREF )
  16. #define g_AlphaTestRef g_EyePos.w
  17. #endif
  18. // VS_OUTPUT in a common file.
  19. #define PIXELSHADER
  20. #include "common_splinerope_fxc.h"
  21. sampler BaseTextureSampler : register( s0 );
  22. sampler NormalSampler : register( s1 );
  23. float4_color_return_type main( PS_INPUT i ) : COLOR
  24. {
  25. #if ( SHADOWDEPTH == 0 )
  26. {
  27. float3 vNormalMapDir = tex2D( NormalSampler, i.texCoord.xy ).xyz; // Get the 3-vector from the normal map
  28. float4 textureColor = tex2Dsrgb( BaseTextureSampler, i.texCoord.xy );
  29. //Expand compacted vectors
  30. vNormalMapDir = ( vNormalMapDir - 0.5 ) * 2.0;
  31. float3 vLightDir = float3( 0.0f, 0.0f, 1.0f );
  32. float lightDirDotNormalMap = dot( vNormalMapDir, vLightDir ); //normalMap dot dirLightDir
  33. // do half-lambert on the dot
  34. lightDirDotNormalMap = lightDirDotNormalMap * 0.5 + 0.5;
  35. lightDirDotNormalMap = lightDirDotNormalMap * lightDirDotNormalMap;
  36. float4 resultColor;
  37. resultColor.xyz = lightDirDotNormalMap * ( textureColor.rgb * i.argbcolor.rgb );
  38. resultColor.a = textureColor.a * i.argbcolor.a;
  39. #if ( ALPHATESTREF )
  40. clip( resultColor.a - g_AlphaTestRef );
  41. #endif
  42. float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w );
  43. return FinalOutput( resultColor, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, (WRITE_DEPTH_TO_DESTALPHA != 0), i.worldPos_projPosZ.w );
  44. }
  45. #else
  46. {
  47. return float4_color_return_type( 0.0f, 0.0f, 0.0f, 1.0f );
  48. }
  49. #endif
  50. }