유니티/쉐이더

05/04 유니티 쉐이더 Smoothness 연습

박준희 2021. 5. 4. 15:46
728x90

 

 

Shader "Custom/Test"
{
    Properties
    {
        
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _MainTex2("Albedo (RGB)", 2D) = "white" {}
        _MainTex3("Albedo (RGB)", 2D) = "white" {}
        _MainTex4("Albedo (RGB)", 2D) = "white" {}
        _Glossiness("Smoothness", Range(0,1)) = 0
        
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        #pragma surface surf Standard 

        
        sampler2D _MainTex;
        sampler2D _MainTex2;
        sampler2D _MainTex3;
        sampler2D _MainTex4;

        struct Input
        {
            float2 uv_MainTex;
            float2 uv_MainTex2;
            float2 uv_MainTex3;
            float2 uv_MainTex4;
            float4 color:COLOR;
        };

        half _Glossiness;
        half _Metallic;
        fixed4 _Color;
        

        void surf (Input IN, inout SurfaceOutputStandard o)
        {
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
            fixed4 e = tex2D(_MainTex2, IN.uv_MainTex);
            fixed4 f = tex2D(_MainTex3, IN.uv_MainTex);
            fixed4 g = tex2D(_MainTex4, IN.uv_MainTex);
            //o.Albedo = c.rgb;
            
            o.Albedo = c.rgb; 
            o.Albedo = lerp(o.Albedo, e, IN.color.r);
            o.Albedo = lerp(o.Albedo, f, IN.color.g);
            o.Albedo = lerp(o.Albedo, g, IN.color.b);

            o.Smoothness = (IN.color.r * 0.5) + _Glossiness + 0.3;
            
        }
        ENDCG
    }
    FallBack "Diffuse"
}
728x90