Version: Unity 6 Beta (6000.0)
Language : English
ShaderLab: grouping commands with the Category block
ShaderLab command: Blend

ShaderLab command: AlphaToMask

Enables or disables alpha-to-coverage mode on the GPU.

Alpha-to-coverage mode can reduce the excessive aliasing that occurs when you use multisample anti-aliasing (MSAA) with shaders that use alpha testing, such as vegetation shaders. To do this, it modifies the multisample coverage mask proportionally to the alpha value in the output of the fragment shaderA program that runs on the GPU. More info
See in Glossary
result.

This command is intended for use with MSAA. If you enable alpha-to-coverage mode when you are not using MSAA, the results can be unpredictable; different graphics APIs and GPUs handle this differently.

Render pipeline compatibility

Feature name Built-in Render PipelineA series of operations that take the contents of a Scene, and displays them on a screen. Unity lets you choose from pre-built render pipelines, or write your own. More info
See in Glossary
Universal Render Pipeline (URP) High Definition Render Pipeline (HDRP) Custom SRP
AlphaToMask Yes Yes Yes Yes

Usage

This command makes a change to the render state. Use it in a Pass block to set the render state for that Pass, or use it in a SubShader block to set the render state for all Passes in that SubShader.

Signature Example syntax Function
AlphaToMask <state> AlphaToMask Off Enables or disables alpha-to-coverage mode.

Valid parameter values

Parameter Value Function
state On Enables alpha-to-coverage mode.
Off Disables alpha-to-coverage mode.

Examples

Shader "Examples/CommandExample"
{
    SubShader
    {
         // The rest of the code that defines the SubShader goes here.

        Pass
        {    
              // Enable alpha-to-coverage mode for this Pass
              AlphaToMask On
            
              // The rest of the code that defines the Pass goes here.
        }
    }
}

This example code demonstrates the syntax for using this command in a SubShader block.

Shader "Examples/CommandExample"
{
    SubShader
    {
         // Enable alpha-to-coverage mode for this SubShader
         AlphaToMask On

         // The rest of the code that defines the SubShader goes here.        

        Pass
        {    
              // The rest of the code that defines the Pass goes here.
        }
    }
}
ShaderLab: grouping commands with the Category block
ShaderLab command: Blend
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961