docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Expression node

    Use the Expression node to specify a complex mathematical expression as a string instead of using multiple Math nodes.

    Input ports

    The number and type of input ports automatically adjust to the values of the node controls. Unity adds an input port for each variable in the expression in the text field.

    Output port

    Name Type Description
    Out Depends on the selected Type in the node controls. The value resulting from the expression specified in the text field.

    Controls

    Name Description
    Type Specifies the data type to use for all input and output ports of the node. The options are:
    • Vector 1
    • Vector 2
    • Vector 3
    • Vector 4
    (Text field) Use this field to specify the mathematical expression. The field supports the following:
    • Math operators: +, -, *, /, and parentheses.
    • HLSL intrinsic functions: for example, frac and saturate.
    • Vector swizzling: for example, a.xw.
    • Vector construction: float2(x, y).

    Example

    If you specify the expression:

    a + b * c / 2

    • Unity adds three input ports to the node: A, B, and C.
    • If you input 1, 2, and 10, the node calculates 1 + 2 * 10 / 2 and outputs the result to the Out port.

    Note: If you use Shader Graph math nodes instead, the example requires three separate nodes: Divide, Multiply, and Add.

    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)