Math Nodes
Note
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here
In the Shader Designer, math nodes perform algebraic, logic, trigonometric, and other mathematical operations.
Note
When you work with math nodes in the Shader Designer, type promotion is especially evident. To learn how type promotion affects input parameters, see the "Promotion of inputs" section in Shader Designer Nodes.
Math node reference
Node | Details | Properties |
---|---|---|
Abs | Computes the absolute value of the specified input per component. For each component of input X , negative values are made positive so that every component of the result has a positive value.Input: X : float , float2 , float3 , or float4 The values for which to determine the absolute value. Output: Output : same as input X The absolute value, per component. |
None |
Add | Computes the component-wise sum of the specified inputs per component. For each component of the result, the corresponding components of input X and input Y are added together.Input: X : float , float2 , float3 , or float4 One of the values to add together. Y : same as input X One of the values to add together. Output: Output : same as input X The sum, per component. |
None |
Ceil | Computes the ceiling of the specified input per component. The ceiling of a value is the smallest integer that's greater than or equal to that value. Input: X : float , float2 , float3 , or float4 The values for which to compute the ceiling. Output: Output : same as input X The ceiling, per component. |
None |
Clamp | Clamps each component of the specified input to a predefined range. For each component of the result, values that are below the defined range are made equal to the minimum value in the range, values that are above the defined range are made equal to the maximum value in the range, and values that are in the range are not changed. Input: X : float , float2 , float3 , or float4 The values to clamp. Output: Output : same as input X The clamped value, per component. |
Max The largest possible value in the range. Min The smallest possible value in the range. |
Cos | Computes the cosine of the specified input, in radians, per component. For each component of the result, the cosine of the corresponding component, which is provided in radians, is calculated. The result has components that have values in the range of [-1, 1]. Input: X : float , float2 , float3 , or float4 The values to compute the cosine of, in radians. Output: Output : same as input X The cosine, per component. |
None |
Cross | Computes the cross product of the specified three-component vectors. You can use the cross product to compute the normal of a surface that's defined by two vectors. Input: X : float3 The vector on the left-hand-side of the cross product. Y : float3 The vector on the right-hand-side of the cross product. Output: Output : float3 The cross product. |
None |
Distance | Computes the distance between the specified points. The result is a positive scalar value. Input: X : float , float2 , float3 , or float4 One of the points to determine the distance between. Y : same as input X One of the points to determine the distance between. Output: Output : same as input X The distance. |
None |
Divide | Computes the component-wise quotient of the specified inputs. For each component of the result, the corresponding component of input X is divided by the corresponding component of input Y .Input: X : float , float2 , float3 , or float4 The dividend values. Y : same as input X The divisor values. Output: Output : same as input X The quotient, per component. |
None |
Dot | Computes the dot product of the specified vectors. The result is a scalar value. You can use the dot product to determine the angle between two vectors. Input: X : float , float2 , float3 , or float4 One of the terms. Y : same as input X One of the terms. Output: Output : float The dot product. |
None |
Floor | Computes the floor of the specified input per component. For each component of the result, its value is the largest whole integer value that's less than or equal to the corresponding component of the input. Every component of the result is a whole integer. Input: X : float , float2 , float3 , or float4 The values for which to compute the floor. Output: Output : same as input X The floor, per component. |
None |
Fmod | Computes the component-wise modulus (remainder) of the specified inputs. For each component of the result, some integral (whole-number) multiple, m, of the corresponding component of input Y is subtracted from the corresponding component of input X , leaving a remainder. The multiple, m, is chosen such that the remainder is less than the corresponding component of input Y and has the same sign as the corresponding component of input X . For example, fmod(-3.14, 1.5) is -0.14.Input: X : float , float2 , float3 , or float4 The dividend values. Y : same as input X The divisor values. Output: Output : same as input X The modulus, per component. |
None |
Frac | Removes the integral (whole-number) part of the specified input per component. For each component of the result, the integral part of the corresponding component of the input is removed, but the fractional part and sign are retained. This fractional value falls in the range [0, 1). For example, the value -3.14 becomes the value -0.14. Input: X : float , float2 , float3 , or float4 The values for which to compute the fractional part. Output: Output : same as input X The fractional part, per component. |
None |
Lerp | Linear Interpolation. Computes the component-wise weighted average of the specified inputs. For each component of the result, the weighted average of the corresponding components of the inputs X and Y . The weight is provided by Percent , a scalar, and is uniformly applied to all components. You can use this to interpolate between points, colors, attributes, and other values.Input: X : float , float2 , float3 , or float4 The originating value. When Percent is zero, the result is equal to this input.Y : same as input X The terminal value. When Percent is one, the result is equal to this input.Percent : float A scalar weight that's expressed as a percentage of the distance from input X towards input Y .Output: Output : same as input X A value that's collinear with the specified inputs. |
None |
Multiply Add | Computes the component-wise multiply-add of the specified inputs. For each component of the result, the product of the corresponding components of the inputs M and A is added to the corresponding component of input B . This operation sequence is found in common formulas—for example, in the point-slope formula of a line, and in the formula to scale and then bias an input.Input: M : float , float2 , float3 , or float4 One of the values to multiply together. A : same as input M One of the values to multiply together. B : same as input M The values to add to the product of the other two inputs. Output: Output : same as input M The result of the multiply-add, per component. |
None |
Max | Computes the component-wise maximum of the specified inputs. For each component of the result, the greater of the corresponding components of the inputs is taken. Input: X : float , float2 , float3 , or float4 One of the values for which to compute the maximum. Y : same as input X One of the values for which to compute the maximum. Output: Output : same as input X The maximum value, per component. |
None |
Min | Computes the component-wise minimum of the specified inputs. For each component of the result, the lesser of the corresponding components of the inputs is taken. Input: X : float , float2 , float3 , or float4 One of the values for which to compute the minimum. Y : same as input X One of the values for which to compute the minimum. Output: Output : same as input X The minimum value, per component. |
None |
Multiply | Computes the component-wise product of the specified inputs. For each component of the result, the corresponding components of the inputs X and Y are multiplied together.Input: X : float , float2 , float3 , or float4 One of the values to multiply together. Y : same as input X One of the values to multiply together. Output: Output : same as input X The product, per component. |
None |
Normalize | Normalizes the specified vector. A normalized vector retains the direction of the original vector, but not its magnitude. You can use normalized vectors to simplify calculations where the magnitude of a vector is not important. Input: X : float2 , float3 , or float4 The vector to normalize. Output: Output : same as input X The normalized vector. |
None |
One Minus | Computes the difference between 1 and the specified input per component. For each component of the result, the corresponding component of the input is subtracted from 1. Input: X : float , float2 , float3 , or float4 The values to be subtracted from 1. Output: Output : same as input X The difference between 1 and the specified input, per component. |
None |
Power | Computes the component-wise exponentiation (power) of the specified inputs. For each component of the result, the corresponding component of input X is raised to the power of the corresponding component of the input Y .Input: X : float , float2 , float3 , or float4 The base values Y : same as input X The exponent values. Output: Output : same as input X The exponentiation, per component. |
None |
Saturate | Clamps each component of the specified input to the range [0, 1]. You can use this range to represent percentages and other relative measurements in calculations. For each component of the result, the corresponding component values of the input that are less than 0 are made equal to 0, values that are larger than 1 are made equal to 1, and values that are in the range are not changed. Input: X : float , float2 , float3 , or float4 The values to saturate. Output: Output : same as input X The saturated value, per component. |
None |
Sin | Computes the sine of the specified input, in radians, per component. For each component of the result, the sine of the corresponding component, which is provided in radians, is calculated. The result has components that have values in the range [-1, 1]. Input: X : float , float2 , float3 , or float4 The values to compute the sine of, in radians. Output: Output : same as input X The sine, per component. |
None |
Sqrt | Computes the square root of the specified input, per component. For each component of the result, the square root of the corresponding component is calculated. Input: X : float , float2 , float3 , or float4 The values for which to compute the square root. Output: Output : same as input X The square root, per component. |
None |
Subtract | Computes the component-wise difference of the specified inputs. For each component of the result, the corresponding component of input Y is subtracted from the corresponding component of input X . You can use this to compute the vector that extends from the first input to the second.Input: X : float , float2 , float3 , or float4 The values to be subtracted from. Y : same as input X The values to subtract from input X .Output: Output : same as input X The difference, per component. |
None |
Transform 3D Vector | Transforms the specified 3-D vector into a different space. You can use this to bring points or vectors into a common space so that you can use them to perform meaningful calculations. Input: Vector : float3 The vector to transform. Output: Output : float3 The transformed vector. |
From System The native space of the vector. To System The space to transform the vector into. |