Unity/수업 내용

[Unity 2020.3] Shader 코드 Albedo, Normal, Smoothness, Metallic

JSH1 2021. 11. 19. 13:21

base model


 

Albedo, Smoothness


 

Normal, Smoothness


 

Albedo, Normal, Smoothness


 

Shader "Custom/CussionShader"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _NormalMap ("Normal Map", 2D) = "white" {}
        _Metallic ("Metallic", Range(0,1)) = 0.0
        _Smoothness ("Smoothness", Range(0,1)) = 0.5
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }

        CGPROGRAM

        #pragma surface surf Standard

        sampler2D _MainTex, _NormalMap;

        struct Input
        {
            float2 uv_MainTex, uv_NormalMap;
        };

        float _Metallic;
        float _Smoothness;

        void surf (Input IN, inout SurfaceOutputStandard o)
        {
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
            o.Albedo = c;

            fixed4 n = tex2D (_NormalMap, IN.uv_NormalMap);
            o.Normal = UnpackNormal(n);

            o.Metallic = _Metallic;
            o.Smoothness = _Smoothness;
        }
        ENDCG
    }
    FallBack "Diffuse"
}