Legacy Documentation: Version 4.6.2
Language: English
ShaderLab syntax: SubShader
ShaderLab syntax: Color, Material, Lighting

ShaderLab syntax: Pass

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

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

Syntax

    Pass {[Name and Tags\] [RenderSetup\] [TextureSetup] }

The basic pass command contains an optional list of render setup commands, optionally followed by a list of textures to use.

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 Setup

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

Material

    Material {Material Block}

Defines a material to use in a vertex lighting pipeline. See Material page for details.

Lighting

    Lighting On | Off

Turn vertex lighting on or off. See Material page for details.

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 testing mode. See Cull and Depth page for details.

ZWrite

    ZWrite On | Off

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

Fog

Fog {Fog Block}

Set fog parameters. See Fog page for details.

AlphaTest

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

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

Blend

    Blend SourceBlendMode DestBlendMode

Sets alpha blending mode. See Blending page for details.

Color

    Color Color-value

Sets color to use if vertex lighting is turned off. See Material page for details.

ColorMask

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

Set color writing mask. Writing ColorMask 0 turns off rendering to all color channels. See Material page for details.

Offset

    Offset OffsetFactor, OffsetUnits

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

SeparateSpecular

    SeparateSpecular On | Off

Turns separate specular color for vertex lighting on or off. See Material page for details.

ColorMaterial

    ColorMaterial AmbientAndDiffuse | Emission

Uses per-vertex color when computing vertex lighting. See Material page for details.

Texture Setup

After the render state setup, you can specify a number of textures and their combining modes to apply using SetTexture commands: SetTexture texture property { [Combine options] }

The texture setup configures fixed function multitexturing pipeline, and is ignored if custom fragment shaders are used.

Details

Per-pixel Lighting

The per-pixel lighting pipeline works by rendering objects in multiple passes. Unity renders the object once to get ambient and any vertex lights in. Then it renders each pixel light affecting the object in a separate additive pass. See Render Pipeline for details.

Per-vertex Lighting

Per-vertex lighting is the standard Direct3D/OpenGL lighting model that is computed for each vertex. Lighting on turns it on. Lighting is affected by Material block, ColorMaterial and SeparateSpecular commands. See Material 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 syntax: SubShader
ShaderLab syntax: Color, Material, Lighting