유니티/쉐이더

05/04 유니티 쉐이더 노멀 맵(범프 매핑)

박준희 2021. 5. 4. 18:20

좌 : 노멀 맵 적용 전     우 : 노멀 맵 적용 후

 

 

 

Shader "Custom/Standard"
{
    Properties
    {
        _Color ("Color", Color) = (1,1,1,1)
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _MainTex2 ("Albedo (RGB)", 2D) = "white" {}
        _SpecColor("Specular Color", color) = (1,1,1,1)
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        // Physically based Standard lighting model, and enable shadows on all light types
        #pragma surface surf BlinnPhong


        sampler2D _MainTex;
        sampler2D _MainTex2;

        struct Input
        {
            float2 uv_MainTex;
            float2 uv_MainTex2;
        };

        fixed3 _Tmp;

        void surf (Input IN, inout SurfaceOutput o)
        {
            // Albedo comes from a texture tinted by color
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
            fixed3 d = UnpackNormal(tex2D(_MainTex2, IN.uv_MainTex2));
            
            o.Normal = d;
            o.Specular = 0.5;
            o.Gloss = 1;
            o.Albedo = c.rgb;

            o.Alpha = c.a;
        }
        ENDCG
    }
    FallBack "Diffuse"
}