#ifndef URP_HOLE_INCLUDED
#define URP_HOLE_INCLUDED

sampler2D _HoleTex;
float4x4 _HoleProj_VP;
float _HoleRSpeed;

float2 GetHoleUV(float4 worldPos)
{
    float4 uvShadow = mul(_HoleProj_VP, worldPos);
    uvShadow = uvShadow / uvShadow.w;
    //uvShadow.x = (uvShadow.x + 1.0f) *  0.5f;
    //uvShadow.y = (uvShadow.y + 1.0f) *  0.5f;
    
    float2 uv = uvShadow.xy;
    uv = float2(uv.x * cos(-_HoleRSpeed * _Time.x) - uv.y * sin(-_HoleRSpeed * _Time.x), uv.x * sin(-_HoleRSpeed * _Time.x) + uv.y * cos(-_HoleRSpeed * _Time.x));
    uv += float2(0.5f, 0.5f);
    return uv;
}

float4 GetHoleColor(float2 UV)
{
    return tex2D(_HoleTex, UV);
}

float4 GetHoleColor(float4 worldPos)
{
    //float2 uv = GetHoleUV(worldPos);
    //return float4(uv.x, uv.y, 1, 1);
    return GetHoleColor(GetHoleUV(worldPos));
}

void MixHole(float4 HoleColor)
{
    if (HoleColor.r < 0.1f)
        discard;
}

void MixHole(float2 HoldTexUV)
{
    MixHole(GetHoleColor(HoldTexUV));
}

#endif