Version: 5.5
조명 데이터 에셋
GI Visualizations in the Scene view

머티리얼 프로퍼티와 GI 시스템

오브젝트가 표시되는 방법은 셰이더가 결정합니다.

Legacy and current Shader mappings
Shader mappings in Unity versions 3 and 4 work in a different way to Shader mappings in Unity 5 onwards. The legacy Shader mappings are still supported in Unity 5 onwards. See Legacy material mappings, below.

Unity 3.x 및 4.x 버전에서는 머티리얼 프로퍼티부터 라이트매퍼 머티리얼 프로퍼티까지 간단한 매핑을 사용했습니다. 대부분은 아무런 문제없이 작동했지만 명명 규칙, 태그, 문자열에 기반하고 있었습니다. 사실상 특정한 방식으로 동작하도록 효율적으로 하드 코딩되었기 때문에 커스텀 표면 프로퍼티는 사용할 수 없었습니다. Unity 5.0 버전 이후부터는 유연한 셰이더 매핑이 적용되었습니다.

Meta pass (Unity 5.0 onwards)

알베도와 이미시브는 특수 메타 셰이더 패스를 통해 렌더링됩니다. 라이트맵 정적 게임 오브젝트는 라이트맵 공간에서 GPU를 사용하여 렌더링됩니다. 즉, 게임 오브젝트가 화면과 라이트매퍼에 표시되는 방식이 서로 다르므로 셰이더를 커스터마이즈할 수 있습니다.

The Meta pass decouples the albedo and emissive, which Enlighten uses from regular Shader passes. This allows you to control GI without affecting the Shader used for real-time rendering. The standard Shader contains a Meta pass by default.

메타 패스 플로
메타 패스 플로

메타 패스는 Unity 에디터에서 금속성 표면을 나타내기 위한 알베도를 내부적으로 처리하는 방법입니다. Enlighten은 광원의 디퓨즈 전송을 처리하고 각 반사마다 표면 알베도를 사용합니다. 검정색이거나 거의 검정색인 알베도의 금속성 표면은 광원을 반사하지 않습니다. 알베도를 렌더링하는 셰이더 패스는 금속 색조를 사용하여 알베도를 더 밝은 컬러로 편향시킵니다. 나무, 플라스틱, 돌, 콘크리트, 가죽, 피부와 같은 유전체는 흰색 스페큘러 반사율을 가집니다. 금속은 분광 스페큘러 반사율을 가집니다.

참고: 메타 패스를 사용하면 DynamicGI.SetEmissive만큼 빠르지는 않지만 단일 컬러로 제한되지 않으므로 더 유연합니다.

Legacy material mappings

Unity 5.0 이상의 빌트인 레거시 셰이더에는 이미 메타 패스가 있습니다. Unity 버전 5.0 이하에서 프로젝트를 업그레이드한다면 메타 패스를 추가해야 합니다. 방법은 아래의 메타 패스가 포함된 셰이더 예제를 참조하십시오.

To enable color-based RGB transparency, add a Texture property called _TransparencyLM to the Shader. This transparency is defined in the opposite way to alpha-based transparency. Here a pixel with value (1, 0, 0) is fully transparent to the red light component and fully opaque to green and blue components, which results in a red shadow. For the same reason, a white Textures is fully transparent, while a black Texture is fully opaque.

_TransparencyLM ("Transmissive Color", 2D) = "white" {}

참고: Unity 에디터는 셰이더의 프로퍼티와 Transparent, Tree, Leaf, Leaves 등과 같은 경로/이름 키워드로 특정 레거시 셰이더를 감지합니다.

Example Shader with a Meta pass

아래 셰이더에서는 GI 시스템 전용 커스텀 알베도 컬러와 텍스처를 지정할 수 있습니다.

Shader "Custom/metaPassShader"{
 
    Properties {
        _Color ("Color", Color)=(1,1,1,1)
        _MainTex ("Albedo (RGB)",2D)="white"{}
        _Glossiness ("Smoothness", Range(0,1))=0.5
        _Metallic ("Metallic", Range(0,1))=0.0
 
        _GIAlbedoColor ("Color Albedo (GI)", Color)=(1,1,1,1)
        _GIAlbedoTex ("Albedo (GI)",2D)="white"{}
    }
 
    SubShader {
    // ------------------------------------------------------------------
    // Extracts information for lightmapping, GI (emission, albedo, ...)
    // This pass is not used during regular rendering.
        Pass
        {
            Name "META"
            Tags {"LightMode"="Meta"}
            Cull Off
            CGPROGRAM
 
            #include"UnityStandardMeta.cginc"
 
            sampler2D _GIAlbedoTex;
            fixed4 _GIAlbedoColor;
            float4 frag_meta2 (v2f_meta i): SV_Target
            {
                // We're interested in diffuse & specular colors
                // and surface roughness to produce final albedo.
               
                FragmentCommonData data = UNITY_SETUP_BRDF_INPUT (i.uv);
                UnityMetaInput o;
                UNITY_INITIALIZE_OUTPUT(UnityMetaInput, o);
                fixed4 c = tex2D (_GIAlbedoTex, i.uv);
                o.Albedo = fixed3(c.rgb * _GIAlbedoColor.rgb);
                o.Emission = Emission(i.uv.xy);
                return UnityMetaFragment(o);
            }
           
            #pragma vertex vert_meta
            #pragma fragment frag_meta2
            #pragma shader_feature _EMISSION
            #pragma shader_feature _METALLICGLOSSMAP
            #pragma shader_feature ___ _DETAIL_MULX2
            ENDCG
        }
       
        Tags {"RenderType"="Opaque"}
        LOD 200
 
        CGPROGRAM
        // Physically-based Standard lighting model, and enable shadows on all light types
        #pragma surface surf Standard fullforwardshadows nometa
        // Use Shader model 3.0 target, to get nicer looking lighting
        #pragma target 3.0
 
        sampler2D _MainTex;
 
        struct Input {
            float2 uv_MainTex;
        };
       
        half _Glossiness;
        half _Metallic;
        fixed4 _Color;
       
        void surf (Input IN,inout SurfaceOutputStandard o){
            // Albedo comes from a texture tinted by color
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex)* _Color;
            o.Albedo = c.rgb;
            // Metallic and smoothness come from slider variables
            o.Metallic = _Metallic;
            o.Smoothness = _Glossiness;
            o.Alpha = c.a;
        }
        ENDCG
    }
 
    FallBack "Diffuse"
}
조명 데이터 에셋
GI Visualizations in the Scene view