Version: 5.4 beta (switch to 5.3)
ShaderLab: SubShader
ShaderLab: Culling & Depth Testing

ShaderLab: Pass

The Pass block causes the geometry of an object to be rendered once.

Syntax

Pass { [Name and Tags] [RenderSetup] }

The basic pass command contains a list of render state setup commands.

Name and tags

A Pass can define its Name and arbitrary number of Tags - name/value strings that communicate Pass’ intent to the rendering engine.

Render State Setup

A pass sets up various states of the graphics hardware, for example should alpha blending be turned on, should depth testing be used, and so on. The commands are these:

Cull

Cull Back | Front | Off

Set polygon culling mode. See Cull and Depth page for details.

ZTest

ZTest (Less | Greater | LEqual | GEqual | Equal | NotEqual | Always)

Set depth buffer testing mode. See Cull and Depth page for details.

ZWrite

ZWrite On | Off

Set depth buffer writing mode. See Cull and Depth page for details.

Blend

Blend sourceBlendMode destBlendMode
Blend sourceBlendMode destBlendMode, alphaSourceBlendMode alphaDestBlendMode
BlendOp colorOp
BlendOp colorOp, alphaOp
AlphaToMask On | Off

Sets alpha blending, alpha operation, alpha-to-coverage modes. See Blending page for details.

ColorMask

ColorMask RGB | A | 0 | any combination of R, G, B, A

Set color channel writing mask. Writing ColorMask 0 turns off rendering to all color channels. Default mode is writing to all channels (RGBA), but for some special effects you might want to leave certain channels unmodified, or disable color writes completely.

Offset

Offset OffsetFactor, OffsetUnits

Set Z buffer depth offset. See Cull and Depth page for details.

Legacy Fixed Function Shader Commands

A number of commands are used for writing legacy “fixed function style” shaders. This is considered deprecated functionality, as writing surface shaders or shader programs allows much more flexibility. However, for very simple shaders writing them in fixed function style might be somewhat easier, so here’s the commands. All of them are ignored when not using fixed function shaders.

Fixed Function Lighting and Material

Lighting On | Off
Material { Material Block }
SeparateSpecular On | Off
Color Color-value
ColorMaterial AmbientAndDiffuse | Emission

All these control fixed function per-vertex lighting: turns it on, sets up material colors, turns on specular highlights, provides default color if vertex lighting is off, and controls how the mesh vertex colors affect lighting. See Material page for details.

Fixed Function Fog

Fog { Fog Block }

Set fixed function fog parameters. See Fog page for details.

Fixed Function AlphaTest

AlphaTest (Less | Greater | LEqual | GEqual | Equal | NotEqual | Always) CutoffValue

Turns on fixed function alpha testing. See Alpha Testing page for details.

Fixed Function Texture Combiners

After the render state setup, you can specify a number of textures and their combining modes to apply using SetTexture commands:

SetTexture textureProperty { combine options }

Details

Shader passes interact with Unity’s rendering pipeline in several ways; for example a pass can indicate that it should only be used for deferred shading using Tags command. Certain passes can also be executed multiple times on the same object; for example in forward rendering the “ForwardAdd” pass type will be executed multiple times, based on how many lights are affecting the object. See Render Pipeline page for details.

See Also

There are several special passes available for reusing common functionality or implementing various high-end effects:

  • UsePass includes named passes from another shader.
  • GrabPass grabs the contents of the screen into a texture, for use in a later pass.
ShaderLab: SubShader
ShaderLab: Culling & Depth Testing