Introduction | 引言

Redshift supports a wide variety of commonly used math operation shaders for both scalar values and vectors. These simple shaders are all listed here.
对于标量值和矢量,红移支持各种常用的数学操作着色器。这些简单的着色器都在这里了。

Abs | 绝对值

💡Math Shaders | 数学着色器 - 图1

Returns the absolute value of Input. For example, a value of -1.0 will be returned as 1.0.
获得输入值的绝对值。例如,-1.0的值将作为1.0返还。

Add | 求和

💡Math Shaders | 数学着色器 - 图2

Returns Input 1 + Input 2.
获得输入值1 + 输入值2。

ArcCosine | 反余弦

💡Math Shaders | 数学着色器 - 图3

Returns the arc-cosine of Input. When Radians is selected, the output range will be between 0 and PI, otherwise 0 and 180 degrees.
获得输入值的反余弦值。当选择弧度时,输出范围将在0和 PI 之间,否则为0和180度。

ArcSine | 反正弦

💡Math Shaders | 数学着色器 - 图4

Returns the arc-sine of Input. When Radians is selected, the output range will be between -PI/2 and PI/2, otherwise -90 and 90 degrees.
获得输入值的弧正弦值。当选择弧度时,输出范围将在 -PI/2和 PI/2之间,否则为 -90和90度。

ArcTan2 | 反正切2

💡Math Shaders | 数学着色器 - 图5

Returns the arc-tangent of Input 1 _and Input 2. When _Radians is selected, the output range will be between -PI/2 and PI/2, otherwise -90 and 90 degrees.
反三角函数中的反正切,获得输入值1和输入值2的反正切值。当选择弧度时,输出范围将在 -PI/2和 PI/2之间,否则为 -90和90度。

ArcTangent | 反正切

💡Math Shaders | 数学着色器 - 图6

Returns the arc-tangent of Input. When Radians is selected, the output range will be between -PI/2 and PI/2, otherwise -90 and 90 degrees.
获得输入值的反正切。当选择弧度时,输出范围将在 -PI/2和 PI/2之间,否则为 -90和90度。

Bias | 偏差

💡Math Shaders | 数学着色器 - 图7

Returns a curved bias of Input by Bias, using the following Ken Perlin formula: pow( Input, log(Bias)/log(0.5) )
使用以下 Ken Perlin 公式获得偏置输入的曲线偏差值: pow (Input,log (Bias)/log (0.5))

Change Range | 变化范围

💡Math Shaders | 数学着色器 - 图8

Returns Input remapped from Old Range values to _New Range _values, with an optional clamp.
使用可选的限制,将输入值从旧范围值重新映射到新范围值。

Cosine | 余弦

💡Math Shaders | 数学着色器 - 图9

Returns the cosine of Input. When Radians is selected, the input will be assumed to be in radians, otherwise degrees.
获得输入值的余弦值。当选择弧度时,将假定输入值为弧度,否则为度。

Cross Product | 叉乘(向量叉积)

💡Math Shaders | 数学着色器 - 图10

Returns the outer product perpendicular vector of Input 1 and Input 2 _vectors, using the following formula:
获得输入值1和输入值2向量的外积垂直向量,使用以下公式:
out.x = Input1.y*Input2.z - Input1.z*Input2.y
out.y = Input1.z*Input2.x - Input1.x*Input2.z
out.z = Input1.x*Input2.y - Input1.y*Input2_.x

Dot Product | 点乘(向量点积)

💡Math Shaders | 数学着色器 - 图11

Returns the inner product of Input 1 and Input 2 vectors, using the following formula: Input1.x Input2.x + Input1.y Input2.y + Input1.z Input2.z
获得输入值1和输入值2向量的内积,使用以下公式:
**输入值1.x
输入值2.x + 输入值1.y 输入值2.y + 输入值1.z 输入值2.z**

Normalize | 归一化

💡Math Shaders | 数学着色器 - 图12

Returns a normalized vector of Input, with a new vector length of 1.0.
获得标准化的输入值矢量,新的矢量长度为1.0。

Div | 相除

💡Math Shaders | 数学着色器 - 图13

Returns Input 1 / Input 2.
求两个数的商和余数,获得输入值1/输入值2。

Exp | 指数

💡Math Shaders | 数学着色器 - 图14

Returns the exponential of Input, using the following formula: e^Input
使用以下公式获得输入值的指数: e ^ 输入值

This is the inverse function of Ln. 这里是自然对数的反函数

Floor | 向下取整

💡Math Shaders | 数学着色器 - 图15

Returns the integer part of Input. For example, 1.5 will be returned as 1.0.
获得输入值的整数部分。例如,1.5将作为1.0返还。

Frac | 取小数

💡Math Shaders | 数学着色器 - 图16

Returns the fractional part of Input. For example, 1.5 will be returned as 0.5.
获得输入值的小数部分。例如,1.5将作为0.5返还。(获得标量或每个矢量中各分量的小数部分)

Gain | 增益

💡Math Shaders | 数学着色器 - 图17

Returns a contrast gain of Input by Gain, using the following Ken Perlin formula:
Bias( 2 Input, 1 - Gain ) 0.5 ; if Input < 0.5
1 - Bias( 2 - 2 Input, 1 - Gain ) 0.5 ; otherwise
使用以下 Ken Perlin 公式,通过增益获得输入值的相对增益,
如果输入值 < 0.5,偏差值(2 输入值,1-增益值) 0.5;
其他情况下,1-偏差值 (2-2 输入值,1-增益值) 0.5;

Invert | 反转

💡Math Shaders | 数学着色器 - 图18

Returns the 1 - Input.
获得1- 输入值。

Ln | 自然对数

💡Math Shaders | 数学着色器 - 图19

Returns the natural logarithm (to base e) of Input.
获得输入值的自然对数值(以 e 为基)。

This is the inverse function of Exp. 指数的反函数,(同底的对数函数与指数函数互为反函数)

Log | 对数

💡Math Shaders | 数学着色器 - 图20

Returns the logarithm of Input to Base.
将输入值的对数返还到基数

This is the inverse function of Pow. 幂的反函数

Max | 最大

💡Math Shaders | 数学着色器 - 图21

Returns the maximum of Input 1 and Input 2.
获得输入值1和输入值2的最大值。

Min | 最小

💡Math Shaders | 数学着色器 - 图22

Returns the minimum of Input 1 and Input 2.
获得输入值1和输入值2的最小值。

Mix | 混合

💡Math Shaders | 数学着色器 - 图23

Returns Input 1 linearly interpolated to Input 2 by Mix. When Mix is 0.0, Input 1 will be returned. When Mix is 1.0, Input 2 will be returned.
获得输入值1通过混合线性插值到输入值2。当混合值为0.0时,将获得输入值1。当混合值为1.0时,将获得输入值2。

Mod | 求余

💡Math Shaders | 数学着色器 - 图24

Returns the modulo of Input by Divisor. For example 7 modulo 5 will be returned as 2.
获得由除数输入表示的除法。例如,7除5将作为2返还。(**获得两数相除的余数**)

This is the remainder of Input / Divisor. 这是输入值/除数的剩余部分

Mul | 相乘

💡Math Shaders | 数学着色器 - 图25

Returns Input 1 Input 2.
获得输入值1
输入值2。

Neg | 求补

💡Math Shaders | 数学着色器 - 图26

Returns 0 - Input.
获得0-输入值。

Pow | 幂(次方)

💡Math Shaders | 数学着色器 - 图27

Returns Base^Exponent.
获得基数 ^ 指数。
This is the inverse function of Log. 这是对数函数的倒数

Rcp | 倒数

💡Math Shaders | 数学着色器 - 图28

Returns 1 / Input.
获得1/输入值。

Saturate | 钳制

💡Math Shaders | 数学着色器 - 图29

Returns Input clamped to values between 0 and 1, inclusively. For example -1.5 will be returned as 0.0 and 1.5 will be returned as 1.0.
获得输入限制到0到1之间的值,包括。例如-1.5将作为0.0返还,而1.5将作为1.0返还。

Sign | 符号函数(判正负)

💡Math Shaders | 数学着色器 - 图30

Returns -1 if Input is a negavitve number and 1 otherwise.
数学上的符号函数是获得一个整型变量,指出参数的正负号,如果输入值是一个负数,获得 -1,否则获得1。

Sine | 正弦

💡Math Shaders | 数学着色器 - 图31

Returns the sine of Input. When Radians is selected, the input will be assumed to be in radians, otherwise degrees.
获得输入值的正弦值。当选择弧度时,将假定输入值为弧度,否则为度。

Sqrt | 平方根

💡Math Shaders | 数学着色器 - 图32

Returns the square-root of Input.
获得输入值的平方根。(**一个非负实数的平方根)**

Sub | 相减

💡Math Shaders | 数学着色器 - 图33

Returns Input 1 - Input 2.
获得输入值1-输入值2。

Tangent | 切线

💡Math Shaders | 数学着色器 - 图34

Returns the tangent of Input. When Radians is selected, the input will be assumed to be in radians, otherwise degrees.
获得输入值的切线值。当选择弧度时,将假定输入值为弧度,否则为度。

Vector Length | 矢量长度

💡Math Shaders | 数学着色器 - 图35

Returns the length of vector Input.
获得矢量输入值的长度。

Vector To Scalars | 矢量到标量

💡Math Shaders | 数学着色器 - 图36

Returns the vector Input split into its three scalar components, using the following formula:
使用以下公式将矢量 Input 分解为三个标量组件:
outX = Input.x
输入
outY = Input.y
输入
outZ = Input.z
1.2.2