Mathematical Shader Processes
From C4 Engine Wiki
|
Absolute Value
| |
|
Inputs: Value A Output: Value of size matching A Calculates the absolute value of each component of the input A. | |
|
Add
| |
|
Inputs: Values A and B Output: Value of size matching larger of A and B Calculates the componentwise sum of the inputs A and B. LOD: If either input is high-detail only, then the other input is passed through unchanged in the low-detail shader. | |
|
Average
| |
|
Inputs: Values A and B Output: Value of size matching larger of A and B Calculates the componentwise average of the inputs A and B. LOD: If either input is high-detail only, then the other input is passed through unchanged in the low-detail shader. | |
|
Cosine
| |
|
Inputs: Scalar A Output: Scalar Calculates the cosine of the input A, where the input is measured in radians. | |
|
Cross Product
| |
|
Inputs: 3D vectors A and B Output: 3D vector Calculates the cross product of the inputs A and B. | |
|
Divide
| |
|
Inputs: Value A, Scalar B Output: Value of size matching A Calculates the quotient of each component of the input A and the scalar input B. Tip: If you're dividing by a constant value, then it would be more efficient to multiply by the reciprocal of the constant. For example, you should multiply by 0.5 instead of dividing by 2.0. | |
|
Dot Product 3D
| |
|
Inputs: 3D vectors A and B Output: Scalar Calculates the dot product of the inputs A and B. | |
|
Dot Product 4D
| |
|
Inputs: 4D vectors A and B Output: Scalar Calculates the dot product of the inputs A and B. | |
|
Exp Base 2
| |
|
Inputs: Scalar A Output: Scalar Calculates 2 raised to the power given by the input A. | |
|
Expand
| |
|
Inputs: Value A Output: Value of size matching A Multiplies each component of the input A by 2.0 and then subtracts 1.0. | |
|
Floor
| |
|
Inputs: Value A Output: Value of size matching A Calculates the floor of each component of the input A. To calculate a ceiling, negate the input and output of the Floor process. | |
|
Fraction
| |
|
Inputs: Value A Output: Value of size matching A Calculates the fraction of each component of the input A. The fraction of a number is the difference between that number and its floor. | |
|
Invert
| |
|
Inputs: Value A Output: Value of size matching A Subtracts each component of the input A from 1.0. | |
|
Linear Interpolate
| |
|
Inputs: Values A, B, and t Output: Value of size matching largest of A, B, and t Calculates the linear interpolation between the components of A and B using the components of the input t as the interpolation parameter. LOD: If either input A or B is high-detail only, then the other input in that pair is passed through unchanged in the low-detail shader, and the input t is ignored. | |
|
Log Base 2
| |
|
Inputs: Scalar A Output: Scalar Calculates the logarithm base 2 of the input A. If the input is not positive, then the result is undefined. | |
|
Maximum
| |
|
Inputs: Values A and B Output: Value of size matching larger of A and B Calculates the componentwise maximum of the inputs A and B. LOD: If either input is high-detail only, then the other input is passed through unchanged in the low-detail shader. | |
|
Minimum
| |
|
Inputs: Values A and B Output: Value of size matching larger of A and B Calculates the componentwise minimum of the inputs A and B. LOD: If either input is high-detail only, then the other input is passed through unchanged in the low-detail shader. | |
|
Multiply
| |
|
Inputs: Values A and B Output: Value of size matching larger of A and B Calculates the componentwise product of the inputs A and B. LOD: If either input is high-detail only, then the other input is passed through unchanged in the low-detail shader. | |
|
Multiply Add
| |
|
Inputs: Values A, B, and C Output: Value of size matching largest of A, B, and C Calculates the componentwise product of the inputs A and B and then adds the components of the input C. LOD: If any two inputs are high-detail only, then the third input is passed through unchanged in the low-detail shader. If only the input C is high-detail only, then the product of the inputs A and B is calculated. If only the input A or only the input B is high-detail only, then the sum of the other input in that pair and the input C is calculated. | |
|
Normalize
| |
|
Inputs: 3D vector A Output: 3D vector Normalizes the input A. If the input is the zero vector, then the result is undefined. | |
|
Power
| |
|
Inputs: Scalars A and B Output: Scalar Calculates the input A raised to the power of the input B. Tip: If you're just squaring a value, then it would be more efficient to multiply the value by itself. That is, you should calculate A*A using the Multiply process instead of raising A to the power of 2. | |
|
Reciprocal
| |
|
Inputs: Scalar A Output: Scalar Calculates the reciprocal of the input A. If the input is zero, then the result is undefined. | |
|
Reciprocal Square Root
| |
|
Inputs: Scalar A Output: Scalar Calculates the reciprocal square root of the input A. If the input is not positive, then the result is undefined. | |
|
Round
| |
|
Inputs: Value A Output: Value of size matching A Rounds each component of the input A to the nearest integer. | |
|
Saturate
| |
|
Inputs: Value A Output: Value of size matching A Clamps each component of the input A to the range [0,1]. | |
|
Set if Greater Equal
| |
|
Inputs: Values A and B Output: Value of size matching larger of A and B For each component of the inputs A and B, the corresponding component of the output is set to 1.0 if the component of A is greater than or equal to the same component of B, and 0.0 otherwise. | |
|
Set of Less Than
| |
|
Inputs: Values A and B Output: Value of size matching larger of A and B For each component of the inputs A and B, the corresponding component of the output is set to 1.0 if the component of A is less than the same component of B, and 0.0 otherwise. | |
|
Sine
| |
|
Inputs: Scalar A Output: Scalar Calculates the sine of the input A, where the input is measured in radians. | |
|
Square Root
| |
|
Inputs: Scalar A Output: Scalar Calculates the square root of the input A. If the input is not positive, then the result is undefined. | |
|
Subtract
| |
|
Inputs: Values A and B Output: Value of size matching larger of A and B Calculates the componentwise difference of the inputs A and B. LOD: If either input is high-detail only, then the other input is passed through unchanged in the low-detail shader. | |






























