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
55 lines
1.6 KiB
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
|
|
|
// STATIC: "CASCADED_SHADOW_MAPPING" "0..1" [ps30]
|
|
// STATIC: "CSM_MODE" "0..3" [ps30]
|
|
|
|
// DYNAMIC: "DYN_CSM_ENABLED" "0..1" [ps30]
|
|
|
|
// SKIP: ( $CASCADED_SHADOW_MAPPING == 0 ) && ( $DYN_CSM_ENABLED == 1 )
|
|
|
|
#include "common_fog_ps_fxc.h"
|
|
#include "common_ps_fxc.h"
|
|
#include "shader_constant_register_map.h"
|
|
|
|
const float4 g_Color : register( c0 );
|
|
const float g_HDRColorScale : register( c1 );
|
|
|
|
const float4 g_FogParams : register( PSREG_FOG_PARAMS );
|
|
const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT );
|
|
|
|
sampler TexSampler : register( s0 );
|
|
|
|
#if ( CASCADED_SHADOW_MAPPING == 1 )
|
|
sampler CSMDepthAtlasSampler : register( s15 );
|
|
#define CASCADE_SIZE 3
|
|
#define CSM_ENABLED 1
|
|
#include "csm_common_fxc.h"
|
|
#endif
|
|
|
|
struct PS_INPUT
|
|
{
|
|
float2 baseTexCoord : TEXCOORD0; // Base texture coordinate
|
|
float4 color : TEXCOORD2; // Vertex color (from lighting or unlit)
|
|
float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog
|
|
};
|
|
|
|
float4_color_return_type main( PS_INPUT i ) : COLOR
|
|
{
|
|
|
|
float4 sample = tex2D( TexSampler, i.baseTexCoord );
|
|
|
|
sample.rgb *= i.color.rgb;
|
|
|
|
float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w );
|
|
|
|
#if ( (CASCADED_SHADOW_MAPPING == 1) && (DYN_CSM_ENABLED == 1) )
|
|
float flCSMShadow = CSMComputeShadowing( i.worldPos_projPosZ.xyz );
|
|
flCSMShadow = (flCSMShadow * 0.7f) + 0.3f;
|
|
sample.rgb *= flCSMShadow;
|
|
#endif
|
|
|
|
sample = FinalOutput( sample, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR );
|
|
|
|
return sample;
|
|
}
|
|
|