Version: Unity 6.2 Alpha (6000.2)
Language : English
Validate and correct materials in the Built-In Render Pipeline
Material Validator window reference for the Built-In Render Pipeline

Make a shader compatible with the Material Validator in the Built-In Render Pipeline

The Material Validator works with any Materials that use Unity’s Standard shader or surface shadersA streamlined way of writing shaders for the Built-in Render Pipeline. More info
See in Glossary
. However, custom shadersA program that runs on the GPU. More info
See in Glossary
require a pass named “META”. Most custom shaders that support lightmapping already have this pass defined. See documentation on Lightmapping and shaders for more details.

Carry out the following steps to make your custom shader compatible with the Material Validator:

  1. Add the following pragma to the meta pass: #pragma shader_feature EDITOR_VISUALIZATION
  2. In the UnityMetaInput structure, assign the specular colorThe color of a specular highlight.
    See in Glossary
    of the Material to the field called SpecularColor, as shown in the code example below.

Here is an example of a custom meta pass:

Pass
{
    Name "META" 
    Tags { "LightMode"="Meta" }

    Cull Off

    CGPROGRAM
    #pragma vertex vert_meta
    #pragma fragment frag_meta

    #pragma shader_feature _EMISSION
    #pragma shader_feature _METALLICGLOSSMAP
    #pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
    #pragma shader_feature ___ _DETAIL_MULX2
    #pragma shader_feature EDITOR_VISUALIZATION

    float4 frag_meta(v2f_meta i) : SV_TARGET
    {
        UnityMetaInput input;
        UNITY_INITIALIZE_OUTPUT(UnityMetaInput, input);
        float4 materialSpecularColor = float4(1.0f, 0.0f, 0.0f, 1.0f);
        float4 materialAlbedo = float4(0.0f, 1.0f, 0.0f, 1.0f);
        input.SpecularColor = materialSpecularColor;
        input.Albedo = materialAlbedo;

        return UnityMetaFragment(input);
    }  
}

对文档有任何疑问,请移步至开发者社区提问,我们将尽快为您解答
Validate and correct materials in the Built-In Render Pipeline
Material Validator window reference for the Built-In Render Pipeline
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961