ShaderLab syntax: Pass
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 Block }
- Defines a material to use in a vertex lighting pipeline. See material page for details.
- Lighting On | Off
- Turn vertex lighting on or off. See material page for details.
- Cull Back | Front | Off
- Set polygon culling mode.
- ZTest (Less | Greater | LEqual | GEqual | Equal | NotEqual | Always)
- Set depth testing mode.
- ZWrite On | Off
- Set depth writing mode.
- Fog { Fog Block }
- Set fog parameters.
- AlphaTest (Less | Greater | LEqual | GEqual | Equal | NotEqual | Always) CutoffValue
- Turns on alpha testing.
- Blend SourceBlendMode DestBlendMode
- Sets alpha blending mode.
- Color Color value
- Sets color to use if vertex lighting is turned off.
- 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.
- Offset OffsetFactor , OffsetUnits
- Set depth offset. Note that this command intentionally only accepts constants (i.e., not shader parameters) as of Unity 3.0.
- SeparateSpecular On | Off
- Turns separate specular color for vertex lighting on or off. See material page for details.
- 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.
Subsections
Page last updated: 2012-01-17