본문으로 바로가기
반응형




The resource was provided by Kim Hyung Il, who created Perfect Knight.

https://assetstore.unity.com/packages/3d/characters/humanoids/perfect-knight-4889








Unity Standard Shader Sample version



StandardShader.zip



When you unzip the compressed file, you will see below files.


UnityKorea/StandardSmoothenss

UnityKorea/StandardSmoothenssAlphaTest

UnityKorea/StandardRoughness

UnityKorea/StandardRoughnessAlphaTest




The Shader file works by putting it anywhere in the Unity Project folder(usually by creating a Shader folder). The default environment settings can be found at the link below.


Unity Look dev setting guide : http://illu.tistory.com/1262






Color : Adjust the overall color.

Albedo : Albedo texture.

Normal Map : Normal texture
Norma Intensity : Control the normal intensity(It just change normal texture's G channel only)


Sometimes the normal map used by 3DS Max or Unreal is turned upside down. If you type -1 and get it right, you can invert the G channel of the normal textures in Photoshaop



Masking Texture

R : Metallic
G : Occlusion 
A : Smoothness, Roughness


Each uses RGB channel and can be adjusted with the following parameters.


Smoothness and roughness are computed by inverting each value, so it is safe to use any shader.
However, if you want to use the texture exported as roughness in Smoothness, you can adjust Smoothness value to 0 instead of 1.








Change Specular - Glossiness map convert to Roughness - Metallic map.





If you use occlusion texture, please enable and use the toggle below. This is used to make masking texture with black background. It will be activated only when you use it because the character is blackened when you do not use texture.






Emissive Parameter


This menu is activated to give a partially glowing effect. It uses all RGB values and can be set up with additional colors.




Toggle : Activate the emissive parameters. 


Emissive Color : Set the emissive colors. Emissive


Emissive Texture : Emissive texture setting. using RGB colors.


Emissive Inten : Change the emissive intensity. E








Off : 2side : this is for 2side menu(mesh culling)


off : draw mesh back and forward. Tri (Poly counter) doubles because you draw the face back and forth. If possible, we recommend that you make the back side of the part you need.

front : culling front.

back : culling back. this is a default


AlphaTestShader has only 0 and 1, so it is used when using alpha texture.







If Realtime is checked in the Lighting menu, which is opened by opening Window / Lighting / Settings item, environment light source is calculated by using resources checked in the 'Environment Reflection' item (usually Skybox).






First, uncheck the box inside the red box.







In the Hierarchy menu, Light selects a reflection probe.






You have to change the HDR texture properties in your project from 2D to Cube, and you can apply this source to the Reflection probe. If you change the Type to Custom and click select, you can select from the HDR sources in the project.





If you select the Reflection probe, you will see a yellow solid line that must be within this solid line to be covered by the Reflection probe. The range can be adjusted by the value in Box size.





You can use it to check the results of various environments in advance.




In addition, you can find a guide to applying Post Processing through the link below.



Resource Export (1) : http://illu.tistory.com/1264
Unity Setting (2)     : http://illu.tistory.com/1269
Post Processing (3) : http://illu.tistory.com/1272

Post Processing (4) : http://illu.tistory.com/1274










Shader code is below


Shader "UnityKorea/StandardSmoothness" {
   
   
    Properties {
   
      [Header(Simple StandardShader)]
         [Space(20)]
       
        _Color ("Color", Color) = (1,1,1,1)
       
       
      [Space(20)]
       
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
       
        [Normal][NoScaleOffset]_BumpMap("Normal Map", 2D) = "bump" {}

        [Space(10)]
        _BumpScale("Normal Intensity", Float) = 1.0
       
        [NoScaleOffset]_MetallicGlossMap("Meatllic(R), Occlusion(G), Smoothness(A)", 2D) = "white" {}
   
   
   
       [Space(20)]
       
        _Metallic ("Metallic", Range(0,1)) = 0.5
        _Glossiness ("Smoothness", Range(0,1)) = 0.5


        [Space(10)]       
        [MaterialToggle(_Ocu_ON)] _Ocu("Occlusion Toggle", float) = 0
        _OccInten("Occlusion", Range(0, 1)) = 1

       
        [Space(30)]
        [Header(Emissive Parameter)]
        [MaterialToggle(_Emi_ON)] _Emi("Emissive Toggle", float) = 0
        _EmissiveColor("Emissive Color", Color) = (1,1,1,1)
        _EmissiveTex ("Emissive Texture(RGB)", 2D) = "white" {}
        _EmissiveInten("Emissive Inten", Range(0, 5)) = 1

       
        [Space(20)]
        [Enum(UnityEngine.Rendering.CullMode)] _Cull ("Off : 2side", Float) = 2
       
       
    }
   
   
   
    SubShader {
       
        Tags { "RenderType"="Opaque" }
        LOD 200
        Cull [_Cull]
       


        CGPROGRAM
       
        #pragma surface surf Standard fullforwardshadows
        #pragma target 3.0
        #pragma shader_feature _Emi_ON
        #pragma shader_feature _Ocu_ON

       

        sampler2D _MainTex;
        sampler2D _BumpMap;
        sampler2D _MetallicGlossMap;
       
       
       

        struct Input {
           
           
            float2 uv_MainTex;
   
    };

   
        half _Glossiness;
        half _Metallic;
        half _BumpScale;
        half _OccInten;
       
        fixed4 _Color;
       
        #if _Emi_ON
       
        sampler2D _EmissiveTex;
        fixed4 _EmissiveColor;
        half _EmissiveInten;
       
        #endif

       
        UNITY_INSTANCING_BUFFER_START(Props)
       
        UNITY_INSTANCING_BUFFER_END(Props)

        void surf (Input IN, inout SurfaceOutputStandard o) {
       
            fixed4 c  = tex2D(_MainTex, IN.uv_MainTex) * _Color;
            fixed3 nm = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex));
            fixed4 sg = tex2D(_MetallicGlossMap, IN.uv_MainTex);
       
            o.Albedo = c.rgb;
           
           
            o.Normal = nm * fixed3(1, _BumpScale, 1);
       
            o.Metallic   = sg.r * _Metallic;
            o.Smoothness = sg.a * _Glossiness;


            #if _Ocu_ON

            o.Occlusion = sg.g * _OccInten;

            #endif


           
            #if _Emi_ON
           
            fixed3 em = tex2D(_EmissiveTex, IN.uv_MainTex);
           
            o.Emission = em * _EmissiveColor * _EmissiveInten;
           
            #endif
           

           
           
            //o.Alpha = 1;
        }
       
        ENDCG
    }
   
    FallBack "Diffuse"
   
}


반응형