數學節點Math nodes

在著色器設計工具中,數學節點負責執行代數、邏輯、三角及其他數學運算。In the Shader Designer, math nodes perform algebraic, logic, trigonometric, and other mathematical operations.

注意

當您使用著色器設計工具中的數學節點時,特別常見型別提升。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
AbsAbs 根據每個元件計算指定輸入的絕對值。Computes the absolute value of the specified input per component.

對於輸入 X 的每個元件,負值都會轉成正值,以讓結果的每個元件都有正值。For each component of input X, negative values are made positive so that every component of the result has a positive value.

輸入:Input:

Xfloatfloat2float3float4X: float, float2, float3, or float4
這些值可以決定絕對值。The values for which to determine the absolute value.

Output:

Output:與輸入 X 相同Output: same as input X
依每個元件而定的絕對值。The absolute value, per component.
None
加入Add 根據每個元件計算指定輸入的整體元件總和。Computes the component-wise sum of the specified inputs per component.

對於結果的每個元件,會將輸入 X 與輸入 Y 的對應元件相加。For each component of the result, the corresponding components of input X and input Y are added together.

輸入:Input:

Xfloatfloat2float3float4X: float, float2, float3, or float4
要相加的其中一個值。One of the values to add together.

Y:與輸入 X 相同Y: same as input X
要相加的其中一個值。One of the values to add together.

輸出:Output:

Output:與輸入 X 相同Output: same as input X
每個元件的總和。The sum, per component.
None
CeilCeil 根據每個元件計算指定輸入的上限。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:

Xfloatfloat2float3float4X: float, float2, float3, or float4
要計算上限的值。The values for which to compute the ceiling.

輸出:Output:

Output:與輸入 X 相同Output: same as input X
每個元件的上限。The ceiling, per component.
None
ClampClamp 將指定輸入的每個元件限縮在預先定義的範圍內。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:

Xfloatfloat2float3float4X: float, float2, float3, or float4
要限縮的值。The values to clamp.

輸出:Output:

Output:與輸入 X 相同Output: same as input X
每個元件限縮後的值。The clamped value, per component.
MaxMax
範圍內最大的可能值。The largest possible value in the range.

MinMin
範圍內最小的可能值。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. 結果之元件的值在 [-1, 1] 範圍內。The result has components that have values in the range of [-1, 1].

輸入:Input:

Xfloatfloat2float3float4X: float, float2, float3, or float4
要以弧度為單位計算餘弦函數的值。The values to compute the cosine of, in radians.

輸出:Output:

Output:與輸入 X 相同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: float3X: float3
交叉乘積左側的向量。The vector on the left-hand-side of the cross product.

Y: float3Y: float3
交叉乘積右側的向量。The vector on the right-hand-side of the cross product.

輸出:Output:

Output: float3Output: float3
外積。The cross product.
None
距離Distance 計算指定兩點之間的距離。Computes the distance between the specified points.

結果為正純量值。The result is a positive scalar value.

輸入:Input:

Xfloatfloat2float3float4X: float, float2, float3, or float4
要判斷之間距離的其中一個點。One of the points to determine the distance between.

Y:與輸入 X 相同Y: same as input X
要判斷之間距離的其中一個點。One of the points to determine the distance between.

輸出:Output:

Output:與輸入 X 相同Output: same as input X
距離。The distance.
None
劃分Divide 計算指定輸入的整體元件商數。Computes the component-wise quotient of the specified inputs.

對於結果的每個元件,將輸入 X 的對應元件除以輸入 Y 的對應元件。For each component of the result, the corresponding component of input X is divided by the corresponding component of input Y.

輸入:Input:

Xfloatfloat2float3float4X: float, float2, float3, or float4
被除數的值。The dividend values.

Y:與輸入 X 相同Y: same as input X
除數的值。The divisor values.

輸出:Output:

Output:與輸入 X 相同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:

Xfloatfloat2float3float4X: float, float2, float3, or float4
其中一項。One of the terms.

Y:與輸入 X 相同Y: same as input X
其中一項。One of the terms.

輸出:Output:

Output: floatOutput: 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:

Xfloatfloat2float3float4X: float, float2, float3, or float4
要計算下限的值。The values for which to compute the floor.

輸出:Output:

Output:與輸入 X 相同Output: same as input X
每個元件的下限。The floor, per component.
None
FmodFmod 計算指定輸入的整體元件模數 (餘數)。Computes the component-wise modulus (remainder) of the specified inputs.

對於結果的每個元件,輸入 Y 之對應元件的有些整數倍數 m 會和輸入 X 的對應元件相減,因而留下餘數。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. 倍數 m 已選取,因此,餘數會小於輸入 Y 的對應元件,並且具有與輸入 X 之對應元件相關的符號。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. 例如,fmod(-3.14, 1.5) 是 -0.14。For example, fmod(-3.14, 1.5) is -0.14.

輸入:Input:

Xfloatfloat2float3float4X: float, float2, float3, or float4
被除數的值。The dividend values.

Y:與輸入 X 相同Y: same as input X
除數的值。The divisor values.

輸出:Output:

Output:與輸入 X 相同Output: same as input X
每個元件的模數。The modulus, per component.
None
FracFrac 根據每個元件移除指定輸入的整數部分。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. 這個分數值會落在 [0, 1] 範圍內。This fractional value falls in the range [0, 1). 例如,值 -3.14 會變成值 -0.14。For example, the value -3.14 becomes the value -0.14.

輸入:Input:

Xfloatfloat2float3float4X: float, float2, float3, or float4
要計算分數部分的值。The values for which to compute the fractional part.

輸出:Output:

Output:與輸入 X 相同Output: same as input X
每個元件的分數部分。The fractional part, per component.
None
LerpLerp 線性插補。Linear Interpolation. 計算指定輸入的整體元件加權平均。Computes the component-wise weighted average of the specified inputs.

對於結果的每個元件,則是輸入 XY 之對應元件的加權平均。For each component of the result, the weighted average of the corresponding components of the inputs X and Y. 加權是由 Percent,即純量所提供,並且會一致地套用至所有元件。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:

Xfloatfloat2float3float4X: float, float2, float3, or float4
起始值。The originating value. Percent 為零,結果會等於這個輸入。When Percent is zero, the result is equal to this input.

Y:與輸入 X 相同Y: same as input X
端點值。The terminal value. Percent 為一,結果會等於這個輸入。When Percent is one, the result is equal to this input.

Percent: floatPercent: float
以百分比表示輸入 X 與輸入 Y 之間距離的純量加權。A scalar weight that's expressed as a percentage of the distance from input X towards input Y.

輸出:Output:

Output:與輸入 X 相同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.

對於結果的每個元件,輸入 MA 的對應元件乘積會加入輸入 B 的對應元件。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:

Mfloatfloat2float3float4M: float, float2, float3, or float4
要相乘的其中一個值。One of the values to multiply together.

A:與輸入 M 相同A: same as input M
要相乘的其中一個值。One of the values to multiply together.

B:與輸入 M 相同B: same as input M
要加入其他兩個輸入乘積的值。The values to add to the product of the other two inputs.

輸出:Output:

Output:與輸入 M 相同Output: same as input M
每個元件的乘積和結果。The result of the multiply-add, per component.
None
MaxMax 計算指定輸入的整體元件最大值。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:

Xfloatfloat2float3float4X: float, float2, float3, or float4
要計算最大值的其中一個值。One of the values for which to compute the maximum.

Y:與輸入 X 相同Y: same as input X
要計算最大值的其中一個值。One of the values for which to compute the maximum.

輸出:Output:

Output:與輸入 X 相同Output: same as input X
每個元件的最大值。The maximum value, per component.
None
MinMin 計算指定輸入的整體元件最小值。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:

Xfloatfloat2float3float4X: float, float2, float3, or float4
要計算最小值的其中一個值。One of the values for which to compute the minimum.

Y:與輸入 X 相同Y: same as input X
要計算最小值的其中一個值。One of the values for which to compute the minimum.

輸出:Output:

Output:與輸入 X 相同Output: same as input X
每個元件的最小值。The minimum value, per component.
None
Multiply 計算指定輸入的整體元件乘積。Computes the component-wise product of the specified inputs.

對於結果的每個元件,輸入 XY 的對應元件會相乘。For each component of the result, the corresponding components of the inputs X and Y are multiplied together.

輸入:Input:

Xfloatfloat2float3float4X: float, float2, float3, or float4
要相乘的其中一個值。One of the values to multiply together.

Y:與輸入 X 相同Y: same as input X
要相乘的其中一個值。One of the values to multiply together.

輸出:Output:

Output:與輸入 X 相同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:

Xfloat2float3float4X: float2, float3, or float4
要正規化的向量。The vector to normalize.

輸出:Output:

Output:與輸入 X 相同Output: same as input X
已正規化的向量。The normalized vector.
None
一個負差One Minus 根據每個元件計算 1 到指定的輸入之間的差異。Computes the difference between 1 and the specified input per component.

對於結果的每個元件,輸入的對應元件會減去 1。For each component of the result, the corresponding component of the input is subtracted from 1.

輸入:Input:

Xfloatfloat2float3float4X: float, float2, float3, or float4
要減去 1 的值。The values to be subtracted from 1.

輸出:Output:

Output:與輸入 X 相同Output: same as input X
每個元件從 1 到指定的輸入之間的差異。The difference between 1 and the specified input, per component.
None
電源Power 計算指定輸入的整體元件乘冪。Computes the component-wise exponentiation (power) of the specified inputs.

對於結果的每個元件,輸入 X 的對應元件會自乘至輸入 Y 之對應元件的乘冪。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:

Xfloatfloat2float3float4X: float, float2, float3, or float4
基底值The base values

Y:與輸入 X 相同Y: same as input X
指數值。The exponent values.

輸出:Output:

Output:與輸入 X 相同Output: same as input X
每個元件的乘冪。The exponentiation, per component.
None
飽和Saturate 將指定輸入的每個元件限縮在預先定義的範圍 [0, 1] 內。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. 對於結果的每個元件,輸入小於 0 的對應元件值都會視為等於 0,大於 1 的值都會視為等於 1,而範圍內的值則不會變更。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:

Xfloatfloat2float3float4X: float, float2, float3, or float4
要使之飽和的值。The values to saturate.

輸出:Output:

Output:與輸入 X 相同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. 結果之元件的值在 [-1, 1] 範圍內。The result has components that have values in the range [-1, 1].

輸入:Input:

Xfloatfloat2float3float4X: float, float2, float3, or float4
要以弧度為單位計算正弦函數的值。The values to compute the sine of, in radians.

輸出:Output:

Output:與輸入 X 相同Output: same as input X
每個元件的正弦函數。The sine, per component.
None
SqrtSqrt 根據每個元件計算指定輸入的平方根。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:

Xfloatfloat2float3float4X: float, float2, float3, or float4
要計算平方根的值。The values for which to compute the square root.

輸出:Output:

Output:與輸入 X 相同Output: same as input X
每個元件的平方根。The square root, per component.
None
減去Subtract 計算指定輸入的整體元件差值。Computes the component-wise difference of the specified inputs.

對於結果的每個元件,輸入 Y 的對應元件會減去輸入 X 的對應元件。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:

Xfloatfloat2float3float4X: float, float2, float3, or float4
要相減的值。The values to be subtracted from.

Y:與輸入 X 相同Y: same as input X
要從輸入 X 減去的值。The values to subtract from input X.

輸出:Output:

Output:與輸入 X 相同Output: same as input X
每個元件的差值。The difference, per component.
None
轉換 3D 向量Transform 3D Vector 將指定的 3D 向量轉換成不同的空間。Transforms the specified 3D 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: float3Vector: float3
要轉換的向量。The vector to transform.

輸出:Output:

Output: float3Output: float3
已轉換的向量。The transformed vector.
從系統From System
向量的原始空間。The native space of the vector.

至系統To System
轉換向量的目標空間。The space to transform the vector into.