Version: 2018.4
ShaderLab: Properties
ShaderLab: Pass

ShaderLab: SubShader

Each shaderA small script that contains the mathematical calculations and algorithms for calculating the Color of each pixel rendered, based on the lighting input and the Material configuration. More info
See in Glossary
in Unity consists of a list of subshaders. When Unity has to display a meshThe main graphics primitive of Unity. Meshes make up a large part of your 3D worlds. Unity supports triangulated or Quadrangulated polygon meshes. Nurbs, Nurms, Subdiv surfaces must be converted to polygons. More info
See in Glossary
, 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 TagsA reference word which you can assign to one or more GameObjects to help you identify GameObjects for scripting purposes. For example, you might define and “Edible” Tag for any item the player can eat in your game. More info
See in Glossary
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