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.

58 lines
1.9 KiB

  1. //========== Copyright (c) Valve Corporation, All rights reserved. ==========//
  2. // STATIC: "DEPTHBLEND" "0..1" [ps20b]
  3. #include "common_fog_ps_fxc.h"
  4. #include "shader_constant_register_map.h"
  5. const float4 g_FogParams : register( PSREG_FOG_PARAMS );
  6. const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT );
  7. const float4 g_DepthFeatheringConstants : register( c0 );
  8. sampler BumpmapSampler : register( s0 );
  9. sampler DepthSampler : register( s1 );
  10. struct PS_INPUT
  11. {
  12. float2 vBumpTexCoord : TEXCOORD0;
  13. float3 vTangentSpaceLightDir : TEXCOORD1;
  14. float3 vAmbientColor : TEXCOORD2;
  15. float4 vIteratedProjPos : TEXCOORD3;
  16. float4 vDirLightScale : COLOR0;
  17. float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog
  18. };
  19. float4_color_return_type main( PS_INPUT i ) : COLOR
  20. {
  21. float4 baseColor = tex2D( BumpmapSampler, i.vBumpTexCoord );
  22. // Dot the bump normal and the light vector.
  23. float4 vBumpMapNormal = (baseColor - 0.5); // The format of the sphere map is 0 to 1,
  24. // so this is now -0.5 to 0.5.
  25. float3 vTangentSpaceLightDir = (i.vTangentSpaceLightDir - 0.5) * 2; // This is -1 to 1
  26. float4 vOutput = dot( vBumpMapNormal.xyz, vTangentSpaceLightDir.xyz ) + 0.5;
  27. // Scale by the light color outputted by the vertex shader (ie: based on distance).
  28. vOutput *= i.vDirLightScale;
  29. // Add ambient.
  30. vOutput += float4( i.vAmbientColor.x, i.vAmbientColor.y, i.vAmbientColor.z, 0 );
  31. // Alpha = normal map alpha * vertex alpha
  32. vOutput.a = baseColor.a * i.vDirLightScale.a;
  33. //Soft Particles FTW
  34. # if (DEPTHBLEND == 1)
  35. vOutput.a *= DepthFeathering( DepthSampler, i.vIteratedProjPos, g_DepthFeatheringConstants );
  36. # endif
  37. float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w );
  38. return FinalOutput( vOutput, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR );
  39. }