Legacy Documentation: Version 5.2
ShaderLab: Properties
ShaderLab: Pass

ShaderLab: SubShader

Each shader in Unity consists of a list of subshaders. When Unity has to display a mesh, it will find the shader to use, and pick the first subshader that runs on the user’s graphics card.

Syntax

Subshader { [Tags] [CommonState] Passdef [Passdef ...] }

Defines the subshader as optional tags, common state and a list of pass definitions.

Details

A subshader defines a list of rendering passes and optionally setup any state that is common to all passes. Additionally, subshader specific Tags can be set up.

When Unity chooses which subshader to render with, it renders an object once for each Pass defined (and possibly more due to light interactions). As each render of the object is an expensive operation, you want to define the shader in minimum amount of passes possible. Of course, sometimes on some graphics hardware the needed effect can’t be done in a single pass; then you have no choice but to use multiple passes.

Each pass definition can be a regular Pass, a Use Pass or a Grab Pass.

Any statements that are allowed in a Pass definition can also appear in Subshader block. This will make all passes use this “shared” state.

Example

// ...
SubShader {
    Pass {
        Lighting Off
        SetTexture [_MainTex] {}
    }
}
// ...

This subshader defines a single Pass that turns off any lighting and just displays a mesh with texture named _MainTex.

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