53 lines
No EOL
1.4 KiB
PostScript
53 lines
No EOL
1.4 KiB
PostScript
#include "common.h"
|
|
#include "lmodel.h"
|
|
#include "shadow.h"
|
|
|
|
uniform float3 view_shadow_proj;
|
|
|
|
#ifdef USE_SUNFILTER
|
|
float4 main ( float4 tc : TEXCOORD0, float4 tcJ : TEXCOORD1 ) : COLOR
|
|
{
|
|
float4 _P = tex2Dproj (s_position, tc) ;
|
|
_P.w = 1.f ;
|
|
float4 PS = mul (m_shadow, _P) ;
|
|
half s = shadowtest_sun(PS,tcJ)*sunmask(_P) ;
|
|
return s ;
|
|
}
|
|
#else
|
|
float4 main ( float4 tc : TEXCOORD0, float4 tcJ : TEXCOORD1 ) : COLOR
|
|
{
|
|
float4 _P = tex2Dproj (s_position, tc);
|
|
half4 _N = tex2Dproj (s_normal, tc);
|
|
|
|
// ----- light-model
|
|
half m = xmaterial ;
|
|
# ifndef USE_R2_STATIC_SUN
|
|
m = _P.w ;
|
|
# endif
|
|
half4 light = plight_infinity (m,_P,_N,Ldynamic_dir);
|
|
|
|
// ----- shadow
|
|
float4 P4 = float4 (_P.x,_P.y,_P.z,1.f);
|
|
float4 PS = mul (m_shadow, P4);
|
|
half s = sunmask (P4);
|
|
#if defined (USE_SJITTER) || SUN_QUALITY==2
|
|
s *= shadowtest_sun (PS,float4(0,0,0,0));
|
|
#else
|
|
s *= shadow (PS);
|
|
#endif
|
|
|
|
// Fading code
|
|
float2 tc_f = (PS.xy/PS.w)-float2(0.5f,0.5f);
|
|
// Fade only fron edges
|
|
tc_f *= step( -dot( tc_f, view_shadow_proj.xy ), 0 );
|
|
tc_f = abs( tc_f );
|
|
float border = 0.4f;
|
|
float fac_x = 1.f-saturate( ( tc_f.x - border )/(0.5f-border));
|
|
float fac_y = 1.f-saturate( ( tc_f.y - border )/(0.5f-border));
|
|
|
|
s += ((1-s)*(1-fac_x*fac_y));
|
|
//\ // Fading code
|
|
|
|
return blend (Ldynamic_color * light * s/*float4( 1.f, 0.2f, 0.2f, 1.f)*/,tc);
|
|
}
|
|
#endif |