Nuke Knowledge Base

Nuke stuff I need the interwebs to remember for me.

Welcome

Howdy, stranger.
This is a collection of tips and tricks, code snippets and home-brewed gizmos, set up as a personal go-to library among friends. Feel free to browse and use whatever you find here. If you know something that’s missing in this database and would like to contribute, you can simply shoot me an e-mail to julian@yellow-ant.net. I’ll make sure to give you proper credit.
Resident contributors: [php snippet=1]

Set Custom Attributes on All New Nodes with Python

Especially when sharing scripts between artists, keeping tabs on who did what becomes a necessity. Labelling all newly created nodes with the users name, for example, might be a good idea. You can do that with a simple Python script in the script editor (or, if your pipeline is more advanced, put it in the menu.py and have it read out the logged in username or somesuch).

 

, ,

Set Roto Shape Attributes

You can access the attributes of shapes with Python script, for example to set a random opacity value per shape in a given roto node.

There’s more in-depth information on the Foundry forums:
http://community.thefoundry.co.uk/discussion/topic.aspx?f=190&t=103073
http://community.thefoundry.co.uk/discussion/topic.aspx?f=190&t=102867
http://community.thefoundry.co.uk/discussion/topic.aspx?f=190&t=102009

Rotate World Normals to Camera

You can create cam normals from a world normals pass, if you have the camera. Create a ColorMatrix node and then Ctrl-Drag the first three columns of the camera’s World Matrix section into the three rows of the ColorMatrix (so, what’s top-to-bottom in the World Matrix of the cam should end up left-to-right in the ColorMatrix). That should do the trick.

(This assumes a left-handed coordinate system with green as the y-axis pointing up.)

, , , ,

Set Expression via Python

To set an expression e.g. on a Dropdown-Menu, you’ll have to use Python instead of being able to drag’n’drop one knob to the other.

In case you would like to switch the antialiasing inside a Scanline Renderer to “high” when rendering on the farm, but keep working in the GUI with “none”, you could use a line like this:

Of Course you can use this for every kind of knob. Quite useful to link transformation and rotation order in 3d space, too.

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?

Taking the edge off the Sharpen node

It is a good idea to sharpen only the luminance of the image and leave the chrominance untouched. To this effect, convert the colour space to YPrPb before sharpening. This will avoid outlines along saturated areas.

twostrip

A re-creation of the physical two-strip technicolor process. State: beta.

twostrip offers a basic level of controls over how the input is treated and separated. There’s also an option to output the strip mattes instead of the final treated image, so you can use your own grain or go completely nuts with it.  (more…)

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:

or

 

Previous Posts