Nuke tcl script expressions

The following is a list of functions that can be used in tcl Nuke expressions. More...

Functions

 true
 false
 pi
 sin x
 cos x
 tan x
 asin x
 acos x
 atan x
 sinh x
 cosh x
 tanh x
 ceil x
 floor x
 exp x
 log x
 log10 x
 sqrt x
 atan2 x, y
 hypot x, y
 fmod x, y
 pow x, y
 abs x
 fabs x
 rint x
 trunc x
 int x
 min x, y,...
 max x, y,...
 equal a, test1, test2,...
 inrange a, first, last,...
 pow2 x
 clamp x
 clamp x, min, max
 to_sRGB x
 toSRGB x
 from_sRGB byte
 fromSRGB x
 to_Cineon x
 toCineon x
 from_Cineon x
 fromCineon x
 toRec709 x
 fromRec709 x
 toViperLog x
 fromViperLog x
 toPanalog x
 fromPanalog x
 toREDLog x
 fromREDLog x
 toAlexaV3LogC x
 fromAlexaV3LogC x
 toPLogLin x
 fromPLogLin x
 toSLog x
 fromSLog x
 toSLog1 x
 fromSLog1 x
 toSLog2 x
 fromSLog2 x
 toSLog3 x
 fromSLog3 x
 toCLog x
 fromCLog x
 toProtune x
 fromProtune x
 to_byte x
 from_byte byte
 isfinite x
 isnormal x
 isnan x
 isinf x
 signbit x
 copysign x, y
 noise x, y, z
 random x, y, z
 fBm x, y, z, octaves, lucanarity, gain
 turbulence x, y, z, octaves, lucanarity, gain
 mantissa x
 exponent x
 logb x
 ldexp x
 degrees x
 radians x
 step a, x
 smoothstep a, b, x
 lerp a, b, x
 mix a, b, x
 lerp x0, y0, x1, y1, x
 curve frame
 value frame
 y frame
 frame
 t
 first_frame
 format
 actual_format
 height
 inputs
 last_frame
 pixel_aspect
 width
 error
 clones
 animated
 keys
 has_expression
 derivative
 derivative frame
 derivative n, frame
 integrate a, b
 inverse y

Detailed Description

The following is a list of functions that can be used in tcl Nuke expressions.

Nuke's expression language is a subpart of a tcl expression. This is a list of all functions available in expressions.

It is easily possible to access the values of knobs in the same node by simply providing their name, possibly followed by an index name (e.g. saturation.g returns the green component of a slider named 'saturation' in the same node).

A knob name can be prepended with a Node name to reference a different Node. Parent nodes can be referenced through the keyword 'parent', and the root node via 'root' (e.g. parent.CCorrect2.contrst.r).


Function Documentation

true (

Always returns 1

See also:
false
false (

Always returns 0

See also:
true
pi (

returns the value for pi (3.141592654...). Both "PI" and "pi" work.

sin (

returns the sine of x (x is in radians)

See also:
asin, cos, tan, sinh
cos (

returns the cosine of x (x is in radians)

See also:
acos, sin, tan, cosh
tan (

returns the tangent of x (x is in radians)

See also:
atan, cos, sin, tanh, atan2
asin (

calculates the arc sine of x; that is the value whose sine is x. If x is less than -1 or greater 1, asin returns nan (not a number)

See also:
sin, sinh, acos, atan
acos (

calculates the arc sine of x; that is the value whose sine is x. If x is less than -1 or greater 1, asin returns nan (not a number)

See also:
cos, cosh, asin, atan
atan (

calculates the arc tangent of x; that is the value whose tangent is x. The return value will be between -PI/2 and PI/2.

See also:
tan, tanh, acos, asin, atan2
sinh (

returns the hyperbolic sine of x, which is defined mathematically as (exp(x) - exp(-x)) / 2.

See also:
sin, asin, cosh, tanh
cosh (

returns the hyperbolic cosine of x, which is defined mathematically as (exp(x) + exp(-x)) / 2.

See also:
cos, acos, sinh, tanh
tanh (

returns the hyperbolic tangent of x, which is defined mathematically as sinh(x) / cosh(x).

See also:
tan, atan, sinh, cosh
ceil (

round x up to the nearest integer.

See also:
floor, trunc, rint
floor (

round x down to the nearest integer.

See also:
ceil, trunc, rint
exp (

returns the value of e (the base of natural logarithms) raised to the power of x.

See also:
log, log10
log (

returns the natural logarithm of x.

See also:
log10, exp
log10 (

returns the base-10 logarithm of x.

See also:
log, exp
sqrt (

returns the non-negative square root of x.

See also:
pow, pow2
atan2 ( ,
 

calculates the arc tangent of the two variables x and y. This function is useful to calculate the angle between to vectors.

See also:
sin, cos, tan, asin, acos, atan, hypot
hypot ( ,
 

returns the sqrt(x*x + y*y). This is the length of the hypotenuse of a right-angle triangle with sides of length x and y.

See also:
atan2
fmod ( ,
 

computes the remainder of dividing x by y. The return value is x - n * y, where n is the quotient of x / y, rounded towards zero to an integer.

See also:
ceil, floor
pow ( ,
 

returns the value of x raised to the power of y.

See also:
log, exp, pow
abs (

returns the absolute value of the floating-point number x.

See also:
fabs
fabs (

returns the absolute value of the floating-point number x.

See also:
abs
rint (

round x to the nearest integer.

See also:
ceil, floor, int, trunc
trunc (

round x to the nearest integer not larger in absolute value.

See also:
ceil, floor, int, rint
int (

round x to the nearest integer not larger in absolute value.

See also:
ceil, floor, trunc, rint
min ( ,
,
  ... 

return the smallest of all values

See also:
max, clamp
max ( ,
,
  ... 

return the greatest of all values

See also:
min, clamp
equal ( ,
test1  ,
test2  ,
  ... 

Return true if a equals any of the other arguments

See also:
inrange
inrange ( ,
first  ,
last  ,
  ... 

Return true if a is between first and last, inclusive. You can give more than one range by adding more pairs of arguments.

See also:
equal
pow2 (

returns the value of x raised to the power of 2.

See also:
pow
clamp (

return x clamped to [0.0 ... 1.0]

See also:
min, max
clamp ( ,
min  ,
max   

return x clamped to [min ... max]

See also:
min, max
to_sRGB (

Convert using the default 8-bit LUT defined in the root node, then multiplies by 255. Thus this will convert an internal value to the 8-bit number that would normally be written to a file. (this used to be hard-coded to the sRGB standard, thus the name of this function)

See also:
fromSRGB, to_byte, and to<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. toCineon.
toSRGB (

Convert using the default 8-bit LUT defined in the root node. Thus this will convert an internal value to the unclamped normalised number that would normally be written to a file. (this used to be hard-coded to the sRGB standard, thus the name of this function)

See also:
fromSRGB, to_byte, and to<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. toCineon.
from_sRGB ( byte 

Does the inverse of to_sRGB.

See also:
toSRGB, from_byte, and from<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. fromCineon.
fromSRGB (

Inverse of toSRGB.

See also:
toSRGB, from_byte, and from<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. fromCineon.
to_Cineon (

Converts using the default log conversion defined in the root node, then scales to the 0-1023 range. Thus this will convert an internal value to the number that would be written to a Cineon or dpx file. By default 0 turns into 95 (the black point), 1 turns into 685 (the white point). The number 13.5217 turns into the highest legal Cineon number of 1023. The number -.00565 turns into 0, and -.011 turns into -infinity.

See also:
fromCineon, to_byte, and to<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. toCineon.
toCineon (

Converts using the default log conversion defined in the root node. Thus this will convert an internal value to the unclamped normalised number that would be written to a Cineon or dpx file.

See also:
fromCineon, to_byte, and to<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. toCineon.
from_Cineon (

Inverse of to_Cineon.

See also:
toCineon, from_byte, and from<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. fromCineon.
fromCineon (

Inverse of toCineon.

See also:
toCineon, from_byte, and from<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. fromCineon.
toRec709 (

Converts using the Rec709 log conversion defined in the root node. Thus this will convert an internal value to the unclamped normalised number that would be written to a Rec709 file.

See also:
fromRec709, to_byte, and to<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. toCineon.
fromRec709 (

Inverse of toRec709.

See also:
toRec709, from_byte, and from<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. fromCineon.
toViperLog (

Converts using the Viper log conversion defined in the root node. Thus this will convert an internal value to the unclamped normalised number that would be written to a Viper file.

See also:
fromViperLog, to_byte, and to<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. toCineon.
fromViperLog (

Inverse of toViperLog.

See also:
toViperLog, from_byte, and from<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. fromCineon.
toPanalog (

Converts using the Panalog log conversion defined in the root node. Thus this will convert an internal value to the unclamped normalised number that would be written to a Panalog file.

See also:
fromPanalog, to_byte, and to<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. toCineon.
fromPanalog (

Inverse of toPanalog.

See also:
toPanalog, from_byte, and from<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. fromCineon.
toREDLog (

Converts using the RED log conversion defined in the root node. Thus this will convert an internal value to the unclamped normalised number that would be written to a RED file.

See also:
fromREDLog, to_byte, and to<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. toCineon.
fromREDLog (

Inverse of toREDLog.

See also:
toREDLog, from_byte, and from<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. fromCineon.
toAlexaV3LogC (

Converts using the Alexa V3 logC conversion defined in the root node.

See also:
fromAlexaV3LogC, to_byte, and to<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. toCineon.
fromAlexaV3LogC (

Inverse of toAlexaV3LogC.

See also:
toAlexaV3LogC, from_byte, and from<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. fromCineon.
toPLogLin (

Converts using the PLogLin conversion defined in the root node.

See also:
fromPLogLin, to_byte, and to<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. toCineon.
fromPLogLin (

Inverse of toPLogLin.

See also:
toPLogLin, from_byte, and from<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. fromCineon.
toSLog (

Converts using the Sony S-Log conversion defined in the root node. This one is wrong! It is deprecated. Use toSLog1 instead.

See also:
fromSLog1, to_byte, and to<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. toCineon.
fromSLog (

Inverse of toSLog. This one is wrong! It is deprecated. Use fromSLog1 instead.

See also:
toSLog1, from_byte, and from<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. fromCineon.
toSLog1 (

Converts using the Sony S-Log1 conversion defined in the root node.

See also:
fromSLog1, to_byte, and to<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. toCineon.
fromSLog1 (

Inverse of toSLog1.

See also:
toSLog1, from_byte, and from<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. fromCineon.
toSLog2 (

Converts using the Sony S-Log2 conversion defined in the root node.

See also:
fromSLog2, to_byte, and to<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. toCineon.
fromSLog2 (

Inverse of toSLog2.

See also:
toSLog1, from_byte, and from<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. fromCineon.
toSLog3 (

Converts using the Sony S-Log3 conversion defined in the root node.

See also:
fromSLog3, to_byte, and to<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. toCineon.
fromSLog3 (

Inverse of toSLog3.

See also:
toSLog1, from_byte, and from<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. fromCineon.
toCLog (

Converts using the Canon CLog conversion defined in the root node.

See also:
fromCLog, to_byte, and to<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. toCineon.
fromCLog (

Inverse of toCLog.

See also:
toCLog, from_byte, and from<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. fromCineon.
toProtune (

Converts using the GoPro Protune conversion defined in the root node.

See also:
fromProtune, to_byte, and to<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. toCineon.
fromProtune (

Inverse of toProtune.

See also:
toProtune, from_byte, and from<colorspace> where <colorspace> can be replaced by any of the options found on the root node, e.g. fromCineon.
to_byte (

Convert using the default screen conversion defined in the root node, then multiplies by 255. Thus this will convert an internal value to the 8-bit number that would be put into the screen buffer or texture map. By default this is the same as to_sRGB.

See also:
from_byte, toSRGB, toRec709, toCineon, toViperLog, toPanalog, toREDLog, toAlexaV3LogC, toPLogLin, toSLog1
from_byte ( byte 

Does the inverse of to_byte.

isfinite (

x is not NAN, not infinity, and not zero.

isnormal (

isfinite(x) and x is large enough to be a normalized double. This returns false for zero and very small values such as 1e-320.

isnan (

Return true (1) if x is a NAN.

isinf (

Return true (1) if x is positive or negative infinity. Note that NAN returns false.

signbit (

Return true (1) if x has it's sign bit set, including -0 and -NAN, which is a different result than x<0.

copysign ( ,
 

If signbit(y) return -abs(x), else return +abs(x).

noise ( ,
,
 

creates a 3D noise value.

This produces a signed range centered on zero. The absolute maximum range is from -1.0 to 1.0. This produces zero at all integers, so you should rotate the coordinates somewhat (add a fraction of y and z to x, etc) if you want to use this for random number generation. The y and z arguments are optional, if missing they are zero.

See also:
random, fBm, turbulence
random ( ,
,
 

creates a pseudo random value between 0 and 1. It will always generate the same value for the same x, y and z. Calling random wth no arguments will create a different value on every invocation. The y and z arguments are optional, if missing they are zero.

See also:
noise, fBm, turbulence
fBm ( ,
,
,
octaves  ,
lucanarity  ,
gain   

Fractional Brownian Motion. This is the sum of octaves calls to noise. For each of them the noise xyz point is multiplied by pow(lucanarity,i) and the noise output is multiplied by pow(gain,i). For normal use lucanarity should be greater than 1 and gain should be less than 1.

See also:
noise, random, turbulence
turbulence ( ,
,
,
octaves  ,
lucanarity  ,
gain   

This is the same as fBm except the absolute value of the noise function is used.

See also:
fBm, noise, random
mantissa (

returns the normalized fraction. If the argument x is not zero, the normalized fraction is x times a power of two, and is always in the range 1/2 (inclusive) to 1 (exclusive). If x is zero, then the normalized fraction is zero and exponent returns zero.

See also:
exponent
exponent (

exponent of x.

See also:
mantissa, ldexp
logb (

same as exponent

See also:
mantissa, exponent
ldexp (

returns the result of multiplying the floating-point number x by 2 raised to the power exp.

See also:
exponent
degrees (

convert the angle x from radians into degrees

See also:
radians
radians (

convert the angle x from degrees into radians

See also:
degrees
step ( ,
 

returns 0 if x is less than a, returns 1 otherwise. Matches the step function other shading languages.

See also:
smoothstep, lerp
smoothstep ( ,
,
 

returns 0 if x is less than a, returns 1 if x is greater or equal to b, returns a smooth cubic interpolation otherwise. Matches the smoothstep function in other shading languages.

See also:
step, lerp
lerp ( ,
,
 

Returns a if x==0, returns b if x==1, and returns a value between a and b if x is between 0 and 1. Actual return value is a+(b-a)*x. Matches the lerp function in other shading languages.

See also:
step, smoothstep
mix ( ,
,
 

same as lerp

See also:
step, smoothstep, lerp
lerp ( x0  ,
y0  ,
x1  ,
y1  ,
 

Return the y value of the point on the straight line between x0,y0 and x1,y1 that has the given x value. This is y0+(y1-y0)*(x-x0)/(x1-x0).

curve ( frame 

Returns the y value of the animation curve (this is the curve defined by the keyframes as though there was no expression). The frame arugment is optional, if missing the current frame is used.

See also:
value, y
value ( frame 

Evaluates the y value for an animation at the given frame. The frame arugment is optional, if missing the current frame is used.

See also:
y, curve
y ( frame 

Evaluates the y value for an animation at the given frame. This is useful when generating keys as it will place them on the existing curve. The frame arugment is optional, if missing the current frame is used.

See also:
value, curve
frame (

Return the current frame number.

See also:
x, t

Current frame for this node. Prefix with "nodename." to get it for other nodes.

t (

Return the current frame number.

See also:
x, frame
first_frame (

First frame in frame range for this node. Prefix with "nodename." to get it for other nodes.

format (

The full-size format output by this node. You must follow this with:

  • .width for the width in pixels
  • .height for the height in pixels
  • .x for the left edge of the image bounding box (usually 0)
  • .y for the bottom edge of the image bounding box (usually 0)
  • .r for the right edge of the image bounding box (usually width)
  • .t for the top edge of the image bounding box (usually height)
  • .w which is the same as format.r-format.x
  • .h which is the same as #format.t-format.y
  • .pixel_aspect for horizontal_pixel_size/vertical_pixel_size

Prefix with "nodename." to get it for other nodes.

actual_format (

The actual format output by this node. This is the full-size format scaled to the nearest integers to match the current proxy scaling, and is the actual size and format of any image file output by this node.

  • .width for the width in pixels
  • .height for the height in pixels
  • .x for the left edge of the image bounding box (usually 0)
  • .y for the bottom edge of the image bounding box (usually 0)
  • .r for the right edge of the image bounding box (usually width)
  • .t for the top edge of the image bounding box (usually height)
  • .w which is the same as format.r-format.x
  • .h which is the same as format.t-format.y
  • .pixel_aspect for horizontal_pixel_size/vertical_pixel_size

Prefix with "nodename." to get it for other nodes.

height (

Same as format.height

inputs (

Number of inputs for this node. Prefix with "nodename." to get it for other nodes.

last_frame (

Last frame in frame range for this node. Prefix with "nodename." to get it for other nodes.

pixel_aspect (

Same as format.pixel_aspect

width (

Current shutter setting for this node. Prefix with "nodename." to get it for other nodes.

Same as format.width

error (

Returns 1 if trying to use the node would produce an error. Prefix with "nodename." to get it for other nodes. The error may be on it or on one of it's inputs. Use the error_node and error_message tcl commands to retrieve more information about the error.

clones (

Returns the number of clones the node has. If there are two nodes that are clones of each other, they both return 1. Normal nodes return zero. Prefix with "nodename." to get it for other nodes.

animated (

True if the value changes over time.

  • Prefix with "nodename." to get it for any knob on a node.
  • Prefix with "knobname." to get it for only a single knob
  • Prefix with "knob.field." to get it for only one field of a knob.
keys (

Returns the number of keyframes set in the animation, or zero if it is not animated or there is only an expression. For nodes or multi-field knobs this returns the first number of keys that is not zero.

  • Prefix with "nodename." to get it for any knob on a node.
  • Prefix with "knobname." to get it for only a single knob
  • Prefix with "knob.field." to get it for only one field of a knob.
has_expression (

Returns true if there is an expression (other than just "curve").

  • Prefix with "nodename." to get it for any knob on a node.
  • Prefix with "knobname." to get it for only a single knob
  • Prefix with "knob.field." to get it for only one field of a knob.
derivative (

Return the first derivative at the current frame.

  • Prefix with "knobname." to get it for the first field of a knob
  • Prefix with "knob.field." to get it for a different knob or field
derivative ( frame 

Return the first derivative at the given frame.

  • Prefix with "knobname." to get it for the first field of a knob
  • Prefix with "knob.field." to get it for a different knob or field
derivative ( ,
frame   

Return the n'th derivative at the given frame. If n is less than 1 this returns value.

  • Prefix with "knobname." to get it for the first field of a knob
  • Prefix with "knob.field." to get it for a different knob or field
integrate ( ,
 

Returns the numerical integral between time a and b.

  • Prefix with "knobname." to get it for the first field of a knob
  • Prefix with "knob.field." to get it for a different knob or field
inverse (

Returns the value of x such that knob(x)==y. This is designed to invert color lookup tables, and currently only works if the knob has a positive derivative everywhere. y is optional, if missing the current frame is used.

  • Prefix with "knobname." to get it for the first field of a knob
  • Prefix with "knob.field." to get it for a different knob or field