Nuke Knowledge Base

Nuke stuff I need the interwebs to remember for me.


Remapping values with the lerp() function

Someone on here (*cough*) went to great lengths to create a ValueMapper node a few years ago. Turns out, you can do the same thing much easier with the lerp() function. Like this:

Yeah, I know. Where was this function all these years?

Linearly interpolate animation curves with the lerp() function

Using random or noise functions to create movement like camera shakes can become annoying because it’s not always easy (or feasible) to control what’s going on between key frames. In that case you can “posterize” the result using the lerp() function like this:

with yourFunction referencing your original random curve and step being the interval in frames in which you want to sample that curve (so 5 would sample every 5th key frame, .2 would sample 5 times in-between key frames etc…).

Dealing with Inf or -Inf pixels

Inf pixels are a pain, because the empty areas of a render could be inf as well. So sampling the z with an expression node and using the value of an adjacent pixel for each of them will mess up your edges. If possible, try sampling the surrounding area instead. This will leave the edges intact but deal with the odd erroneous pixel.


Dealing with NaN pixels

When there are NaN pixels in your render you can either use the value of an adjacent pixel or the average of all adjacent pixels to fix it. The latter will probably give better results, but won’t work when there’s another NaN pixel next to the first one. In an expression node, type:



Mirroring animation timing using tcl

To mirror your animation curves, you can use some simple expressions. Let’s say you animated an object from frame 0-50, and now you want to mirror it to frame 51-100.

Just write the following in your specific knob:

This uses the command:

which will hold the animation on frame x. So what the above example does, it checks if the current frame is 50 or above. If this is true, it frameholds 50-(frame-50), which at frame 52 for example is …

So on frame 52, it frameholds frame 48. If the frame is under 50, is just gives you your current animated value.

This is pretty useful for creating walk-arounds or anything symmetrical, when you’re too lazy to animate everything. :-)

, , , ,

Restrict number of decimals when working with float and tcl

Say, you need to animate a number and want one decimal. You link a text node to a floating point slider to get the job done, however, it will output a never-ending string of digits that nobody really cares about. You can format this, however. Have no fear.

, , , , ,

Split and use topnode’s filename

For file conversions or prep-jobs, if you want to use the original input’s filename in the final write node, you can use the following snippet of code.


random() function in tcl

Well. It goes like this:

Sample image from within the expression node

To sample the incoming colour values, in an expression node type the following for the required channels:

Split file path in TCL

To split the contents of a file value field in read or write nodes, you can type this expression: