Branch Node | Shader Graph | 7.1.8
docs.unity3d.com
    Show / Hide Table of Contents

    Branch Node

    Description

    Provides a dynamic branch to the shader. If input Predicate is true the return output will be equal to input True, otherwise it will be equal to input False. This is determined per vertex or per pixel depending on shader stage. Both sides of the branch will be calculated in the shader, even if one is never output.

    Ports

    Name Direction Type Binding Description
    Predicate Input Boolean None Determines which input to returned
    True Input Dynamic Vector None Returned if Predicate is true
    False Input Dynamic Vector None Returned if Predicate is false
    Out Output Boolean None Output value

    Generated Code Example

    The following example code represents one possible outcome of this node.

    void Unity_Branch_float4(float Predicate, float4 True, float4 False, out float4 Out)
    {
        Out = lerp(False, True, Predicate);
    }
    
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023