docs.unity3d.com
  • Manual
  • Scripting API
  • Changelog
  • License
    Show / Hide Table of Contents
    • About Shader Graph
    • Getting started with Shader Graph
      • Creating a new Shader Graph Asset
      • My first Shader Graph
      • Shader Graph Window
        • Blackboard
        • Main Preview
        • Graph Inspector
      • Create Node Menu
      • Graph Settings Tab
      • Master Stack
      • Sticky Notes
      • Sub Graph
      • Color Modes
      • Precision Modes
      • Preview Mode Control
      • Custom Function Node
      • Shader Graph Preferences
      • Samples
    • Upgrade Guides
      • Upgrade to Shader Graph 10.​0.​x
    • Inside Shader Graph
      • Shader Graph Asset
      • Graph Target
      • Sub Graph Asset
        • Speed​Tree 8 Sub Graph Assets
      • Node
        • Port
        • Custom Port Menu
        • Edge
      • Property Types
      • Keywords
      • Data Types
      • Port Bindings
      • Shader Stage
      • Surface options
      • Custom Interpolators
    • Node Library
      • Artistic
        • Adjustment
          • Channel Mixer
          • Contrast
          • Hue
          • Invert Colors
          • Replace Color
          • Saturation
          • White Balance
        • Blend
          • Blend
        • Filter
          • Dither
        • Mask
          • Channel Mask
          • Color Mask
        • Normal
          • Normal Blend
          • Normal From Height
          • Normal From Texture
          • Normal Reconstruct Z
          • Normal Strength
          • Normal Unpack
        • Utility
          • Colorspace Conversion
      • Channel
        • Combine
        • Flip
        • Split
        • Swizzle
        • Branch On Input Connection
      • Input
        • Basic
          • Boolean
          • Color
          • Constant
          • Integer
          • Slider
          • Time
          • Float
          • Vector 2
          • Vector 3
          • Vector 4
        • Geometry
          • Bitangent Vector
          • Instance ID
          • Normal Vector
          • Position
          • Screen Position
          • Tangent Vector
          • UV
          • Vertex Color
          • Vertex ID
          • View Direction
          • View Vector
        • Gradient
          • Blackbody
          • Gradient
          • Sample Gradient
        • High Definition Render Pipeline
          • Diffusion Profile
          • Exposure
          • HD Scene Color
        • Lighting
          • Ambient
          • Baked GI
          • Main Light Direction
          • Reflection Probe
        • Matrix
          • Matrix 2x2
          • Matrix 3x3
          • Matrix 4x4
          • Transformation Matrix
        • Mesh Deformation
          • Compute Deformation
          • Linear Blend Skinning
        • PBR
          • Dielectric Specular
          • Metal Reflectance
        • Scene
          • Camera
          • Eye Index
          • Fog
          • Object
          • Scene Color
          • Scene Depth
          • Screen
        • Texture
          • Calculate Level Of Detail Texture 2D Node
          • Cubemap Asset
          • Gather Texture 2D Node
          • Sample Cubemap
          • Sample Reflected Cubemap
          • Sample Texture 2D
          • Sample Texture 2D Array
          • Sample Texture 2D LOD
          • Sample Texture 3D
          • Sample Virtual Texture
          • Sampler State
          • Split Texture Transform
          • Texel Size
          • Texture 2D Array Asset
          • Texture 2D Asset
          • Texture 3D Asset
      • Math
        • Advanced
          • Absolute
          • Exponential
          • Length
          • Log
          • Modulo
          • Negate
          • Normalize
          • Posterize
          • Reciprocal
          • Reciprocal Square Root
        • Basic
          • Add
          • Divide
          • Multiply
          • Power
          • Square Root
          • Subtract
        • Derivative
          • DDX
          • DDXY
          • DDY
        • Interpolation
          • Inverse Lerp
          • Lerp
          • Smoothstep
        • Matrix
          • Matrix Construction
          • Matrix Determinant
          • Matrix Split
          • Matrix Transpose
        • Range
          • Clamp
          • Fraction
          • Maximum
          • Minimum
          • One Minus
          • Random Range
          • Remap
          • Saturate
        • Round
          • Ceiling
          • Floor
          • Round
          • Sign
          • Step
          • Truncate
        • Trigonometry
          • Arccosine
          • Arcsine
          • Arctangent
          • Arctangent2
          • Cosine
          • Degrees To Radians
          • Hyperbolic Cosine
          • Hyperbolic Sine
          • Hyperbolic Tangent
          • Radians To Degrees
          • Sine
          • Tangent
        • Vector
          • Cross Product
          • Distance
          • Dot Product
          • Fresnel Effect
          • Projection
          • Reflection
          • Rejection
          • Rotate About Axis
          • Sphere Mask
          • Transform
        • Wave
          • Noise Sine Wave
          • Sawtooth Wave
          • Square Wave
          • Triangle Wave
      • Procedural
        • Noise
          • Gradient Noise
          • Simple Noise
          • Voronoi
        • Shapes
          • Ellipse
          • Polygon
          • Rectangle
          • Rounded Polygon
          • Rounded Rectangle
        • Checkerboard
      • Utility
        • Logic
          • All
          • And
          • Any
          • Branch
          • Branch On Input Connection
          • Comparison
          • Is Front Face
          • Is Infinite
          • Is Na​N
          • Nand
          • Not
          • Or
        • High Definition Render Pipeline
          • Emission
          • Eye
            • Circle​Pupil​Animation
            • Cornea​Refraction
            • Eye​Surface​Type​Debug
            • Iris​Limbal​Ring
            • Iris​Offset
            • Iris​Out​Of​Bound​Color​Clamp
            • Iris​UVLocation
            • Sclera​Iris​Blend
            • Sclera​Limbal​Ring
            • Sclera​UVLocation
          • Fabric
            • Thread​Map​Detail
          • UVCombine
        • Custom Function
        • Keyword
        • Preview
        • Subgraph
        • Subgraph Dropdown node
      • UV
        • Flipbook
        • Polar Coordinates
        • Radial Shear
        • Rotate
        • Spherize
        • Tiling And Offset
        • Triplanar
        • Twirl
        • Parallax Mapping
        • Parallax Occlusion Mapping
      • Block Nodes
        • Built In Blocks
    • Manual
    • Node Library
    • Utility
    • Logic
    • Branch

    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 evaluated in the shader, and the branch not used will be discarded.

    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 = Predicate ? True : False;
    }
    
    In This Article
    • Description
    • Ports
    • Generated Code Example
    Back to top
    Terms of use
    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