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.

55 lines
1.6 KiB

  1. //========== Copyright (c) Valve Corporation, All rights reserved. ==========//
  2. // STATIC: "CASCADED_SHADOW_MAPPING" "0..1" [ps30]
  3. // STATIC: "CSM_MODE" "0..3" [ps30]
  4. // DYNAMIC: "DYN_CSM_ENABLED" "0..1" [ps30]
  5. // SKIP: ( $CASCADED_SHADOW_MAPPING == 0 ) && ( $DYN_CSM_ENABLED == 1 )
  6. #include "common_fog_ps_fxc.h"
  7. #include "common_ps_fxc.h"
  8. #include "shader_constant_register_map.h"
  9. const float4 g_Color : register( c0 );
  10. const float g_HDRColorScale : register( c1 );
  11. const float4 g_FogParams : register( PSREG_FOG_PARAMS );
  12. const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT );
  13. sampler TexSampler : register( s0 );
  14. #if ( CASCADED_SHADOW_MAPPING == 1 )
  15. sampler CSMDepthAtlasSampler : register( s15 );
  16. #define CASCADE_SIZE 3
  17. #define CSM_ENABLED 1
  18. #include "csm_common_fxc.h"
  19. #endif
  20. struct PS_INPUT
  21. {
  22. float2 baseTexCoord : TEXCOORD0; // Base texture coordinate
  23. float4 color : TEXCOORD2; // Vertex color (from lighting or unlit)
  24. float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog
  25. };
  26. float4_color_return_type main( PS_INPUT i ) : COLOR
  27. {
  28. float4 sample = tex2D( TexSampler, i.baseTexCoord );
  29. sample.rgb *= i.color.rgb;
  30. float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w );
  31. #if ( (CASCADED_SHADOW_MAPPING == 1) && (DYN_CSM_ENABLED == 1) )
  32. float flCSMShadow = CSMComputeShadowing( i.worldPos_projPosZ.xyz );
  33. flCSMShadow = (flCSMShadow * 0.7f) + 0.3f;
  34. sample.rgb *= flCSMShadow;
  35. #endif
  36. sample = FinalOutput( sample, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR );
  37. return sample;
  38. }