본문 바로가기

유니티/수업 내용

[Shader] BlinnPhong - Specular

Shader "Custom/Belt"
{
    Properties
    {
        _MainTexture("MainTexture", 2D) = "white" {}
        _BumpMap("BumpMap", 2D) = "bump" {}
        _SpecColor ("Specular Color", Color) = (1,1,1,1)
        _Gloss ("Gloss", Range(0, 1)) = 1
        _Specular ("Specular", Range(0, 1)) = 1
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }

        CGPROGRAM
        #pragma surface surf BlinnPhong
        #pragma target 3.0

        sampler2D _MainTexture;
        sampler2D _BumpMap;

        //_SpecColor 변수로 받으면 안됨

        float _Gloss;
        float _Specular;

        struct Input
        {
            float2 uv_MainTexture;
            float2 uv_BumpMap;
        };

        void surf (Input IN, inout SurfaceOutput o)
        {
            float4 c = tex2D(_BumpMap, IN.uv_BumpMap);
            o.Normal = UnpackNormal(c);
            o.Gloss = _Gloss;      //스펙큘러의 강도, 0:둔탁, 1:매끄러움
            o.Specular = _Specular;   //스펙큘러의 크기, 0과 가까워질수록 커진다
            o.Albedo = tex2D(_MainTexture, IN.uv_MainTexture).rgb;
        }
        ENDCG
    }
    FallBack "Diffuse"
}

 

기존 마테리얼 쉐이더
BlinnPhong - Specular 커스텀 쉐이더 적용

 

SurfaceOutputStandard 메탈릭
SurfaceOutput 스펙큘러

 

SurfaceOutput 에선 Metallic, Smoothness, Occlusion 을 쓸수없다

'유니티 > 수업 내용' 카테고리의 다른 글

[shader] 반짝거리기  (0) 2022.01.18
[Shader] Metallic, Smoothness, UnpackNormal  (0) 2022.01.18
[Shader] Texture polybrush  (0) 2022.01.18
[Shader] Texture_Fire  (0) 2022.01.18
Shader Warning  (0) 2022.01.18