Version: 2020.3
ShaderLab
ShaderLab: defining material properties

ShaderLab: defining a Shader object

To define a Shader object in ShaderLab, use a Shader block. This page contains information on using Shader blocks.

For information on how a Shader object works, and the relationship between Shader objects, SubShaders and Passes, see Shader objects introduction.

개요

A Shader object is a Unity-specific concept; it is a wrapper for shader programs and other information. It lets you define multiple shader programs in the same file, and tell Unity how to use them.

A Shader object has a nested structure; it organizes information into structures called SubShaders and Passes.

렌더 파이프라인 호환성

Feature name 빌트인 렌더 파이프라인 유니버설 렌더 파이프라인(URP) 고해상도 렌더 파이프라인(HDRP) Custom SRP
ShaderLab: Shader block 지원 지원 지원 지원

Using the Shader block

Inside the Shader block, you can:

Signature 기능
Shader "<name>"
{
    <optional: Material properties>
    <One or more SubShader definitions>
    <optional: custom editor>
    <optional: fallback>
}
Defines a Shader object with a given name.

예제

This example code demonstrates the basic syntax and structure of a Shader object. The example Shader object has a single SubShader that contains a single pass. It defines Material properties, a CustomEditor, and a Fallback.

Shader "Examples/ShaderSyntax"
{
    CustomEditor = "ExampleCustomEditor"

    Properties
    {
        // Material property declarations go here
    }
    SubShader
    {
        // The code that defines the rest of the SubShader goes here

        Pass
        {
           // The code that defines the Pass goes here
        }
    }

    Fallback "ExampleFallbackShader"
}

For example custom shaders that are compatible with different render pipelines, see Example custom shaders

ShaderLab
ShaderLab: defining material properties
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961