float4 g_fResolution : register(c0); float3 g_vLightDir : register(c1); float4 g_fTime : register(c3); sampler1D dif : register(s2); sampler1D spec : register(s3); sampler2D shadowSampler : register(s4); sampler2D depthSampler : register(s5); static float4 g_fSpecularPower = {1.15f, 1.05f, 1.0f, 1.25f}; struct psIn { float4 c : COLOR0; float2 t : TEXCOORD0; float3 n : TEXCOORD1; float3 v : TEXCOORD2; float4 s : TEXCOORD3; float3 w : TEXCOORD4; }; float4 ps_main(psIn i):color { // Shadow AA float2 sc = i.s.xy / i.s.w; float aa = abs( tex2D(depthSampler, sc).x - i.s.z ); float2 ddaa = float2(ddx(aa), ddy(aa)); float2 aaetc = sign(-ddaa) * g_fResolution.zw; sc += aaetc * saturate(4.f * aa); float3 fColor = lerp( float3(1, 0.126, 0.251), float3(255, 224, 32) / 255, 0.5f + 0.5f * cos( g_fTime.x * 0.1f ) ); fColor = lerp( fColor, float3(64, 192, 96) / 255, 0.5f + 0.5f * cos( g_fTime.x * 0.3f ) ); fColor = lerp(i.c.xyz, fColor, 0.75f * (g_fTime.x > 130 * 64) * saturate(-i.w.x + 0.5f) ); //float fS= 0.2f + 0.8f * tex2D(shadowSampler, sc); float3 n = normalize(i.n); float3 v = normalize(i.v); // Lighting //fColor.xyz *= tex1D( dif, fS * ( 0.5f + 0.5f * dot( n, -g_vLightDir) ) ); fColor.xyz *= tex1D( dif, ( 0.5f + 0.5f * dot( n, -g_vLightDir) ) ); // Specular highlights float3 h = normalize( v + -g_vLightDir ); float s = dot(n, h); //fColor += g_fSpecularPower * tex1D(spec, fS * ( 0.5f + 0.5f * s ) ); fColor += g_fSpecularPower * tex1D(spec,( 0.5f + 0.5f * s ) ); float fGlow = ( g_fTime.x < 0 ) ? saturate( -106.5f - ( g_fTime.x / 32.0f ) ) : 1.0f - saturate( g_fTime.w ); fGlow = saturate( fGlow - ( 0.5f + 0.5f * cos(g_fTime.x * 0.5f + i.w.x * 0.1f) ) * (g_fTime.x > 130 * 64) ); return float4(fColor, fGlow ); }