Version: 2022.1
ShaderLab: specifying package requirements
ShaderLab: grouping commands with the Category block

ShaderLab: commands

This page contains information on using commands in the ShaderLabUnity’s language for defining the structure of Shader objects. More info
See in Glossary
language.

ShaderLab commands fall into these categories:

  • Commands for setting the render state on the GPU.
  • Commands that create a Pass with a specific purpose.
  • Legacy “fixed function style” commands that allow you to create shaderA program that runs on the GPU. More info
    See in Glossary
    programs without writing HLSL.

You can group ShaderLab commands together with the Category block.

Commands for setting render state

Use these commands within a Pass block to set the render state for that Pass, or within a SubShader block to set the render state for that SubShader and any Passes that it contains.

  • AlphaToMask: sets the alpha-to-coverage mode.
  • BlendTransition from one animation to another animation smoothly and seamlessly, such as blending a character’s walking and running animations according to the character’s speed.
    See in Glossary
    : enables and configures alpha blending.
  • BlendOp: sets the operation used by the Blend command.
  • ColorMask: sets the color channel writing mask.
  • Conservative: enables and disables conservative rasterizationThe process of generating an image by calculating pixels for each polygon or triangle in the geometry. This is an alternative to ray tracing.
    See in Glossary
    .
  • Cull: sets the polygon culling mode.
  • Offset: sets the polygon depth offset.
  • Stencil: configures the stencil test, and what to write to the stencil bufferA memory store that holds an 8-bit per-pixel value. In Unity, you can use a stencil buffer to flag pixels, and then only render to pixels that pass the stencil operation. More info
    See in Glossary
    .
  • ZClip: sets the depth clip mode.
  • ZTest: sets the depth testing mode.
  • ZWrite: sets the depth bufferA memory store that holds the z-value depth of each pixel in an image, where the z-value is the depth for each rendered pixel from the projection plane. More info
    See in Glossary
    writing mode.

Pass commands

Use these commands in a SubShader to define a Pass with a specific purpose.

  • UsePass defines a Pass that imports the contents of a named Pass from another Shader objectAn instance of the Shader class, a Shader object is container for shader programs and GPU instructions, and information that tells Unity how to use them. Use them with materials to determine the appearance of your scene. More info
    See in Glossary
    .
  • GrabPass creates a Pass that grabs the contents of the screen into a texture, for use in a subsequent Pass.

Legacy “fixed function style” commands

These are documented on the page ShaderLab legacy functionality.

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