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
2.0 KiB

  1. //========== Copyright (c) Valve Corporation, All rights reserved. ==========//
  2. #include "common_fog_ps_fxc.h"
  3. #include "common_ps_fxc.h"
  4. #include "shader_constant_register_map.h"
  5. sampler BaseTextureSampler : register( s0 );
  6. sampler LightMap0Sampler : register( s1 );
  7. sampler LightMap1Sampler : register( s2 );
  8. sampler LightMap2Sampler : register( s3 );
  9. const float4 g_LightMap0Color : register( c0 );
  10. const float4 g_LightMap1Color : register( c1 );
  11. const float4 g_LightMap2Color : register( c2 );
  12. const float4 g_ModulationColor : register( c3 );
  13. const float4 g_FogParams : register( PSREG_FOG_PARAMS );
  14. const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT );
  15. struct PS_INPUT
  16. {
  17. float4 vProjPos : POSITION;
  18. float2 vTexCoord0 : TEXCOORD0;
  19. float2 vTexCoord1 : TEXCOORD1;
  20. float2 vTexCoord2 : TEXCOORD2;
  21. float2 vTexCoord3 : TEXCOORD3;
  22. float4 worldPos_projPosZ : TEXCOORD4; // Necessary for pixel fog
  23. float4 vColor : COLOR0;
  24. };
  25. float4_color_return_type main( PS_INPUT i ) : COLOR
  26. {
  27. float4 resultColor;
  28. // output = lightmapColor[0] * ( ( N dot basis[0] )^2 ) +
  29. // lightmapColor[1] * ( ( N dot basis[1] )^2 ) +
  30. // lightmapColor[2] * ( ( N dot basis[2] )^2 ) +
  31. resultColor = tex2D( LightMap0Sampler, i.vTexCoord1 ) * g_LightMap0Color;
  32. resultColor = (tex2D( LightMap1Sampler, i.vTexCoord2 ) * g_LightMap1Color) + resultColor;
  33. resultColor = (tex2D( LightMap2Sampler, i.vTexCoord3 ) * g_LightMap2Color) + resultColor;
  34. // Modulate by decal texture
  35. float4 decalColor = tex2D( BaseTextureSampler, i.vTexCoord0 );
  36. resultColor.rgb = resultColor.rgb * decalColor.rgb;
  37. resultColor.a = decalColor.a;
  38. // Modulate by constant color
  39. resultColor = resultColor * g_ModulationColor;
  40. // Modulate by per-vertex factor
  41. resultColor = resultColor * i.vColor;
  42. float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w );
  43. return FinalOutput( resultColor, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR );
  44. }