Table Of Contents

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




Returns the absolute value of Input. For example, a value of -1.0 will be returned as 1.0.

Add




Returns Input 1 + Input 2.

ArcCosine




Returns the arc-cosine of Input. When Radians is selected, the output range will be between 0 and PI, otherwise 0 and 180 degrees.

ArcSine




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.

ArcTan2




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.

ArcTangent




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.

Bias




Returns a curved bias of Input by Bias, using the following Ken Perlin formula: pow( Input, log(Bias)/log(0.5) )

Change Range




Returns Input remapped from Old Range values to New Range values, with an optional clamp.

Cosine




Returns the cosine of Input. When Radians is selected, the input will be assumed to be in radians, otherwise degrees.

Cross Product




Returns the outer product perpendicular vector of Input 1 and Input 2 vectors, using the following formula:

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




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

Normalize




Returns a normalized vector of Input, with a new vector length of 1.0.

Div




Returns Input 1 / Input 2.

Exp




Returns the exponential of Input, using the following formula: e^Input

This is the inverse function of Ln.

Floor




Returns the integer part of Input. For example, 1.5 will be returned as 1.0.

Frac




Returns the fractional part of Input. For example, 1.5 will be returned as 0.5.

Gain




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

Invert




Returns the 1 - Input.

Ln




Returns the natural logarithm (to base e) of Input.

This is the inverse function of Exp.

Log




Returns the logarithm of Input to Base.

This is the inverse function of Pow.

Max




Returns the maximum of Input 1 and Input 2.

Min




Returns the minimum of Input 1 and Input 2.

Mix




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.

Mod




Returns the modulo of Input by Divisor. For example 7 modulo 5 will be returned as 2.

This is the remainder of Input / Divisor.

Mul




Returns Input 1 * Input 2.

Neg




Returns 0 - Input.

Pow




Returns Base^Exponent.

This is the inverse function of Log.

Rcp




Returns 1 / Input.

Saturate




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.

Sign




Returns -1 if Input is a negavitve number and 1 otherwise.

Sine




Returns the sine of Input. When Radians is selected, the input will be assumed to be in radians, otherwise degrees.

Sqrt




Returns the square-root of Input.

Sub




Returns Input 1 - Input 2.

Tangent




Returns the tangent of Input. When Radians is selected, the input will be assumed to be in radians, otherwise degrees.

Vector Length




Returns the length of vector Input.

Vector To Scalars




Returns the vector Input split into its three scalar components, using the following formula:

outX = Input.x

outY = Input.y

outZ = Input.z