shader 屏幕出現效果。

vi1vi2vi3

 

Shader "Unlit/VideoEffect"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 100

        Pass
        {
            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;
            };

            sampler2D _MainTex;
            float4 _MainTex_ST;
            
            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                return o;
            }
            
            fixed4 frag (v2f i) : SV_Target
            {

                float2 uv = i.uv;
                float delays = _Time*10;
                delays = frac(delays);
                if (delays >= 1)
                    delays = 1;
                delays = 1 - delays;
                fixed4 col = fixed4(0,0,0,1);
                if (i.uv.x < i.uv.y)
                {
                    if (delays < i.uv.x)
                    {
                        uv = float2((1- uv.x) - delays, uv.y);
                        col = tex2D(_MainTex, uv);
                    }
                }
                else {
                    if (1 - delays > i.uv.x)
                    {
                        uv = float2((delays - uv.x), uv.y);
                        col = tex2D(_MainTex, uv);
                    }
                }

                // sample the texture  _Time 
                
                return col;
            }
            ENDCG
        }
    }
}

 

本人qq:344810449,歡迎探討研究。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章