Shader "Custom/CloudsShader"
{
    Properties
    {
        _MainTex("Main Texture", 2D) = "white" {}
        _MainTexScrollX("Main Texture Scroll X", Float) = 0.001
        _MainTexScrollY("Main Texture Scroll Y", Float) = 0.001

        _NoiseTex("Noise Texture", 2D) = "white" {}
        _NoiseTexScrollX("Noise Texture Scroll X", Float) = 0.001
        _NoiseTexScrollY("Noise Texture Scroll Y", Float) = 0.001

        _Color("Tint Color", Color) = (0.37, 0.37, 0.37, 1.0)
    }

    SubShader
    {
        Tags { "Queue"="Transparent" "RenderType"="Transparent" }
        Blend One One  // Additive blending
        ZWrite Off
        Cull Off

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            sampler2D _MainTex;
            half _MainTexScrollX;
            half _MainTexScrollY;

            sampler2D _NoiseTex;
            half _NoiseTexScrollX;
            half _NoiseTexScrollY;

            float4 _Color;

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv1 : TEXCOORD0;
                float2 uv2 : TEXCOORD1;
                float4 vertex : SV_POSITION;
            };

            v2f vert(appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                // Textures scrolling
                o.uv1 = v.uv + float2(_MainTexScrollX, _MainTexScrollY) * _Time.y;
                o.uv2 = v.uv + float2(_NoiseTexScrollX, _NoiseTexScrollY) * _Time.y;
                return o;
            }

            fixed4 frag(v2f i) : SV_Target
            {
                fixed4 tex1 = tex2D(_MainTex, i.uv1);
                fixed4 tex2 = tex2D(_NoiseTex, i.uv2);
                return tex1 * tex2 * _Color;
            }
            ENDCG
        }
    }

    FallBack "Unlit/Transparent"
}
