Unity水流动效果Shader

Shader "Custom/WaterFlow"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
		_Speed("Speed", float) = 0.5
    }
    SubShader
    {
 		Tags { "Queue" = "AlphaTest" "IgnoreProjector" = "Ture" "RenderType" = "TransparentCutout" }
        Pass
        {
			Tags {"LightMode" = "ForwardBase"}
			ZWrite off
			Blend SrcAlpha OneMinusSrcAlpha

            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

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

            struct v2f
            {
                float2 uv : TEXCOORD0;
                float4 vertex : SV_POSITION;
            };

            v2f vert (appdata v)
            {
                v2f o;				
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = v.uv;
                return o;
            }

            sampler2D _MainTex;
			float _Speed;

            fixed4 frag (v2f i) : SV_Target
            {
				float2 tmpUV = i.uv;
				tmpUV.x += _Speed * _Time.x;
                fixed4 col = tex2D(_MainTex, tmpUV);
                return col;
            }
            ENDCG
        }
    }
}

猜你喜欢

转载自blog.csdn.net/zouxin_88/article/details/124493215