유니티/쉐이더

05/03 유니티 쉐이더 UV가 Time으로 흘러가게 하기

박준희 2021. 5. 3. 16:53
728x90

 

 

Shader "Custom/Test"
{
    Properties
    {
        
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _UV("uv value", Range(-1, 1)) = 0
        _USpeed("Uspeed", Range(-2, 2)) = 0
        _VSpeed("Vspeed", Range(-2, 2)) = 0
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        #pragma surface surf Standard fullforwardshadows

       
        sampler2D _MainTex;

        struct Input
        {
            float2 uv_MainTex;
        };

        float _UV;
        float _USpeed;
        float _VSpeed;

        void surf (Input IN, inout SurfaceOutputStandard o)
        {
            float4 c = tex2D(_MainTex, float2(IN.uv_MainTex.x + _Time.y * _USpeed, IN.uv_MainTex.y + _Time.y * _VSpeed));
            //float4 c = tex2D(_MainTex, IN.uv_MainTex + _UV);
            o.Emission = c.rgb;
            
        }
        ENDCG
    }
    FallBack "Diffuse"
}
728x90