运算节点

../../../../_images/compositing_node-types_CompositorNodeMath.png

运算节点。

运算节点 的功能是执行数学运算。

输入

The inputs of the node are dynamic. Some inputs are only available in certain operations. For instance, the Addend input is only available in the Multiply Add operator.

Input Value. Trigonometric functions read this value as radians.

Addend

Input Addend.

Base

Input Base.

Exponent

Input Exponent.

Epsilon

Input Epsilon.

Distance

Input Distance.

Min

Input Minimum.

Max

Input Maximum.

Increment

Input Increment.

Scale

Input Scale.

Degrees

Input Degrees.

Radians

Input Radians.

属性

操作

The mathematical operator to be applied to the input values:

Functions
Add

The sum of the two values.

Subtract

The difference between the two values.

Multiply

The product of the two values.

Divide

The division of the first value by the second value.

Multiply Add

The sum of the product of the two values with Addend.

Power

The Base raised to the power of Exponent.

Logarithm

The log of the value with a Base as its base.

Square Root

The square root of the value.

Inverse Square Root

One divided by the square root of the value.

Absolute

The input value is read with without regard to its sign. This turns negative values into positive values.

Exponent

Raises Euler's number to the power of the value.

Comparison
Minimum

Outputs the smallest of the input values.

Maximum

Outputs the largest of two input values.

Less Than

Outputs 1.0 if the first value is smaller than the second value. Otherwise the output is 0.0.

Greater Than

Outputs 1.0 if the first value is larger than the second value. Otherwise the output is 0.0.

Sign

Extracts the sign of the input value. All positive numbers will output 1.0. All negative numbers will output -1.0. And 0.0 will output 0.0.

Compare

Outputs 1.0 if the difference between the two input values is less than or equal to Epsilon.

Smooth Minimum

Smooth Minimum.

Smooth Maximum

Smooth Maximum.

Rounding
Round

Round the input value to the nearest integer.

Floor

Rounds the input value down to the nearest integer.

Ceil

Rounds the input value up to the nearest integer.

Truncate

Outputs the integer part of the value.

Fraction

Fraction.

Modulo

Outputs the remainder once the first value is divided by the second value.

Wrap

Outputs a value between Min and Max based on the absolute difference between the input value and the nearest integer multiple of Max less than the value.

Snap

Round the input value to down to the nearest integer multiple of Increment.

Ping-pong

The output value is moved between 0.0 and the Scale based on the input value.

Trigonometric
Sine

The Sine of the input value.

Cosine

The Cosine of the input value.

Tangent

The Tangent of the input value.

Arcsine

The Arcsine of the input value.

Arccosine

The Arccosine of the input value.

Arctangent

The Arctangent of the input value.

Arctan2

Outputs the Inverse Tangent of the first value divided by the second value measured in radians.

Hyperbolic Sine

The Hyperbolic Sine of the input value.

Hyperbolic Cosine

The Hyperbolic Cosine of the input value.

Hyperbolic Tangent

The Hyperbolic Tangent of the input value.

Conversion
To Radians

Converts the input from degrees to radians.

To Degrees

Converts the input from radians to degrees.

钳制

Limits the output to the range (0.0 to 1.0). See Clamp.

输出

数值输出。

范例

自定义Z深度通道节点设置

../../../../_images/compositing_types_converter_math_manual-z-mask.png

最大值与最小值功能举例。

此范例场景输入数据由 渲染层 节点提供,距离摄影机10BU左右有个矩形物体。在另一个渲染层节点底部的输入连接端口上连有一个覆盖视图左半部距离摄影机7BU单位的平面。两个渲染层节点通过映射值节点分离Z缓冲区(Z深度)为20(乘以0.5,输入框如图所示)并且最小值/最大值的范围限分别限定在 0.0/1.0。

“使用最小值”功能是依据靠近摄影机的像素将Z深度值选择出来;也可以选择矩形部分的平面Z深度值。背景有个初始的Z深度值,值限定为1.0(显示为白色)。在“使用最大值”范例中,矩形的Z深度值比图像平面要大,因此更靠近左侧,但是图像平面(FlyCam)渲染层Z值初始在右侧(对应于1.0),因此他们被选择。

使用正弦功能得到不断循环的变化数

../../../../_images/compositing_types_converter_math_sine.png

使用正弦功能举例。

This example has a Time node putting out a linear sequence from 0 to 1 over the course of 101 frames. At frame 25, the output value is 0.25. That value is multiplied by 2 × pi (6.28) and converted to 1.0 by the Sine function, since \(sin(2 × pi/ 4) = sin(pi/ 2) = +1.0\).

因为正弦函数将数值输出限定在(-1.0 to 1.0)之间, 映射值 节点比例缩放原取值范围 (-1 to 1)到 0.0 到1.0,将极值通过offset(偏移量)选项加1操作(结果范围为 0 to 2),,将结果和size(尺寸)选项中0.5进行相乘运算(缩放输出范围在0-1范围之间)。 颜色渐变 默认将输出值转为灰度范围。因此用中性灰用数值0来表示,黑色和白色分别用正弦值-1和1来表示。由此得到数学公式表示形式 \(sin(pi/ 2) = 1.0\)。这就像有了用户自己的输出视觉颜色计算器,将这一系列前后相连的节点进行动画就得到了周期往复不断循环的灰度颜色范围序列。

将这个功能引申,比如,图片的alpha通道形成渐入/渐出特效。改变Z深度通道的景深位置。改变颜色通道值使其有规律的进行色彩变化。

提亮(缩放)通道

../../../../_images/compositing_types_converter_math_multiply.png

比例缩放单一通道范例。

范例中有一个 运算: 相乘 节点增加图像的亮度通道(Y)使其颜色变得更亮。使用 映射值 节点的 “使用最小值” 和 “使用最大值”复选框来限定颜色的输出值在合理的区间范围之内。用这个方法,用户可以在高动态范围图像(HDRI)上应用对数函数。在这个特定范例中,使用一个 亮度/对比度 节点 对亮度进行简单控制。

重新限定颜色选择(色调分离)

../../../../_images/compositing_types_converter_math_posterization.png

色调分离范例。

此范例中,我们重新限定颜色值为以下数值中之一:0, 0.2, 0.4, 0.6, 0.8, 1。

To split up a continuous range of values between 0 and 1 to certain set of values, the following function is used: \(round(x × n - 0.5) / (n - 1)\), where "n" is the number of possible output values, and "x" is the input pixel color. Read more about this function.

Blender中执行上述节点树的最终函数输出。我们通过在其中串入 ”运算“ 节点 将每个颜色值 (取值范围从 0 to 1),分别乘以6,则现有的数值分布(取值范围从0 到 6 ),再将此结果通过参数 0.5 进行偏移值操作 (-0.5 to 5.5), 然后四舍五入数值到最邻近的整数 (结果值为 0, 1, 2, 3, 4, 5), 然后和数字5进行相除操作,最终将颜色像素值分割为 (0.0, 0.2, 0.4, 0.6, 0.8, 1.0)。

就彩色图像而言,用户需要使用 分离RGBA 节点分离RGB混合颜色值为单独的R,G,B颜色通道。