1. 적용되기 전
2. 적용된 후

 

Shader "Custom/Metalic"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _Glossiness ("Smoothness", Range(0,1)) = 0.5
        _Metallic ("Metallic", Range(0,1)) = 0.0
        _BumpMap("Normalmap", 2D) = "bump" {}

    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }

        CGPROGRAM
        #pragma surface surf Standard fullforwardshadows
        #pragma target 3.0

        sampler2D _MainTex;
        sampler2D _BumpMap;

        struct Input
        {
            float2 uv_MainTex;
            float2 uv_BumpMap;
        };

        half _Smoothness;
        half _Metallic;

        

        void surf (Input IN, inout SurfaceOutputStandard o)
        {
            fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
            fixed4 n = tex2D(_BumpMap, IN.uv_BumpMap);
            float3 normal = UnpackNormal(n);
            o.Normal = float3(normal.x * 2, normal.y * 2, normal.z);

            o.Albedo = c.rgb;
            o.Metallic = _Metallic;
            o.Smoothness = _Smoothness;

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

 

 

+++

 

NomalMap의 강도 조절바 추가해서 조절 해보기

 

3. Stength 조절 적용

 

Shader "Custom/Metalic"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _Glossiness ("Smoothness", Range(0,1)) = 0.5
        _Metallic ("Metallic", Range(0,1)) = 0.0
        _BumpMap("Normalmap", 2D) = "bump" {}
         _NormalStength("Normal Stength", Range(0.1, 2)) = 0

    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }

        CGPROGRAM
        #pragma surface surf Standard fullforwardshadows
        #pragma target 3.0

        sampler2D _MainTex;
        sampler2D _BumpMap;
        float _NormalStength;

        struct Input
        {
            float2 uv_MainTex;
            float2 uv_BumpMap;
        };

        half _Smoothness;
        half _Metallic;

        

        void surf (Input IN, inout SurfaceOutputStandard o)
        {
            fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
            fixed4 n = tex2D(_BumpMap, IN.uv_BumpMap);
            float3 normal = UnpackNormal(n);
            o.Normal = float3(normal.x * _NormalStength, normal.y * _NormalStength, normal.z);

            o.Albedo = c.rgb;
            o.Metallic = _Metallic;
            o.Smoothness = _Smoothness;

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

 

 

+++

 

Occlusion 적용하기

 

4. 적용하기 전
5. 적용 후

 

미세하게 음영이 짙어진 것이 눈에 보인다.

 

Shader "Custom/Metalic"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _Glossiness ("Smoothness", Range(0,1)) = 0.5
        _Metallic ("Metallic", Range(0,1)) = 0.0
        _BumpMap("Normalmap", 2D) = "bump" {}
         _NormalStength("Normal Stength", Range(0.1, 2)) = 0
         
        _Occlusion("Occlusion", 2D) = "white" {}

    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }

        CGPROGRAM
        #pragma surface surf Standard fullforwardshadows
        #pragma target 3.0

        sampler2D _MainTex;
        sampler2D _BumpMap;
        
        sampler2D _Occlusion;
        float _NormalStength;

        struct Input
        {
            float2 uv_MainTex;
            float2 uv_BumpMap;
            
        };

        half _Smoothness;
        half _Metallic;

        

        void surf (Input IN, inout SurfaceOutputStandard o)
        {
            fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
            fixed4 n = tex2D(_BumpMap, IN.uv_BumpMap);
            
            fixed4 occlusion = tex2D(_Occlusion, IN.uv_MainTex);
            o.Occlusion = occlusion;
            
            float3 normal = UnpackNormal(n);
            o.Normal = float3(normal.x * _NormalStength, normal.y * _NormalStength, normal.z);

            o.Albedo = c.rgb;
            o.Metallic = _Metallic;
            o.Smoothness = _Smoothness;

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

+ Recent posts