#ifndef URP_SHADOW_INCLUDED
#define URP_SHADOW_INCLUDED

//#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"

float4 unity_ShadowFadeCenterAndType;
float4 _LightShadowData;
/*

//SAMPLER(samplerunity_ShadowMask);

half4 ShadowFade(inout Light light, half3 positionWS, half4 shadowMask)
{
#if defined(LIGHTMAP_ON) && defined(SHADOWS_SHADOWMASK) && defined(LIGHTMAP_SHADOW_MIXING) //ShadowMask   SHADOWS_SHADOWMASK + LIGHTMAP_SHADOW_MIXING
    return min(light.shadowAttenuation, shadowMask.r);
#endif

#if defined(LIGHTMAP_ON) && defined(SHADOWS_SHADOWMASK) && !defined(LIGHTMAP_SHADOW_MIXING) // Distance shadowmask  SHADOWS_SHADOWMASK
    half dist = distance(_WorldSpaceCameraPos, positionWS);
    return lerp(light.shadowAttenuation, shadowMask, saturate(dist * _LightShadowData.z - _LightShadowData.w));
#endif

    return light.shadowAttenuation;
}

#if defined(LIGHTMAP_ON) && defined(SHADOWS_SHADOWMASK)
half4 SampleShadowMask(float2 lightmapUV)
{
    return SAMPLE_TEXTURE2D(unity_ShadowMask, samplerunity_ShadowMask, lightmapUV);
}
#endif

void MixRealtimeAndBakedGI(inout Light light, half3 normalWS, inout half3 bakedGI, half4 shadowMask, half3 positionWS)
{
#if defined(_MIXED_LIGHTING_SUBTRACTIVE) && defined(LIGHTMAP_ON)
    bakedGI = SubtractDirectMainLightFromLightmap(light, normalWS, bakedGI);
#endif
    light.shadowAttenuation = ShadowFade(light, positionWS, shadowMask);
}


*/
sampler2D _ShadowTex;
float _DirX;
float _DirY;
//half _IsRotate;
float _Speed;
half _ShadowAlphaRatio;
half _SHADOW_SWITCH;
float4 VertCalaShadow(float4 posW, half _DirX, half _DirY)
{
	posW.x = posW.x / 6000 * _DirX;
	posW.y = posW.z / 6000 * _DirY;
	return posW;
}
float FragCalaShadowAtten(float atten, half4 posW, half _Time_y, half _Speed, half _ShadowAlphaRatio, sampler2D _ShadowTex)
{
	float2 uv = float2(posW.x, posW.y);
	half s = _Time_y * _Speed;
	//half2 offset1 = half2(uv.x*cos(s) - uv.y*sin(s), uv.y*cos(s) + uv.x*sin(s)) - uv;
	half2 offset2 = half2(s, s);
	//uv += ((offset1 * _IsRotate) + offset2 * (1 - _IsRotate));
	uv += offset2;
	half4 shadow = tex2D(_ShadowTex, float2(uv.x - 0.5, uv.y - 0.5));
	shadow.a *= _ShadowAlphaRatio;
	atten *= _SHADOW_SWITCH?(1 - shadow.a):1;
	return atten;
}
#endif