Unity水流动效果Shader

Unity水流动效果Shader_第1张图片

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
        }
    }
}

 

你可能感兴趣的:(Unity,unity,Shader,流动)