Category Archives: Tools

Here I share tools that I’ve developed to make my compositing life easier.

PostageStamp Tools

I sometimes like to use PostageStamp nodes in my Nuke scripts when I need to connect one place in my script to another place that is far away. PostageStamp nodes with hidden inputs function as a visual marker for what the thing is that is being “imported” from another place in the script.

There are some frustrations with using PostageStamp nodes though.

First when you Ctrl/Cmd-click a node to select all upstream nodes and move them, nodes are selected through the hidden inputs of postageStamps, so you can accidentally move nodes that might be in a totally different place in your script.

Second, when you want to cut or copy and paste a section of your node graph, all PostageStamps with hidden inputs will be disconnected. This tool posted on Nukepedia got me thinking about how to fix this particular frustration, and I finally got around to writing something that works reliably.

This tool monkeypatches the cut/copy/paste behavior in Nuke to handle PostageStamps as a special exception. It stores what node each one is connected to in a knob on the node itself, so that it can reconnect to the right place when you paste it.

It also adds a shortcut to create a new PostageStamp node, and adds some helpful things like a button to connect it to the selected node (useful if you need to connect it to a node that’s really far away, and don’t want to drag a pipe for hours, or select one and then select the other and hit Y).

Here is the code.

And here’s how to add it to your

import postageStampTools
nuke.toolbar('Nodes').addCommand('Other/PostageStamp', 'postageStampTools.create()', 'alt+shift+p')"Nuke").addCommand('Edit/Cut', lambda: postageStampTools.cut(), 'ctrl+x')"Nuke").addCommand('Edit/Copy', lambda: postageStampTools.copy(), 'ctrl+c')"Nuke").addCommand('Edit/Paste', lambda: postageStampTools.paste(), 'ctrl+v')

Posted in Tools | Leave a comment

Tracker Link Tools

Nuke Tracker Link Tools – Code

Tracker Link Tools Interface
It is often the case that you need link things to a Tracker node. It could be a Roto, RotoPaint, or SplineWarp layer that has linked transforms, or a Tracker node that links its transforms to a parent tracker. Tracker Link Tools is a script to do these things.

The script has two functions. The first is to create a linked Roto node. If you have a tracker node selected, and have installed it as described, press Alt-O, and a Roto node will be created with a layer linked to the selected Tracker node. Sometimes you might want to create a linked layer in an existing Roto, RotoPaint or SplineWarp node. No problem, just select as many target nodes as you want, along with your Tracker node, and press Alt-O to run the script. All selected target nodes will have a linked layer added to them.

The other function is to create a linked Transform node. Sometimes you have a Tracker or a Transform node, and you need to apply the same transformation in many places in your Nuke script. You could create many copies of your original Tracker or Transform node, or you could use this script to create a TransformLink node. Select as many parent Tracker or Transform nodes, and press Alt-L. Linked Transform nodes will be created for each.

The TransformLink node has some extra features compared to a regular Transform node. By default, when it is created, it will be linked using a relative transform. This means that on the identity frame specified, the transformation will be zeroed out. This identity frame is separate from the parent Tracker node. You can switch the node from Matchmove to Stabilize functionality by checking the ‘invert’ knob.

Sometimes, especially if you are linking to a parent node that is a Transform, you will just want to inherit the exact transformation of the parent node. If this is the case, you can click the Delete Rel button, and it will remove the relative transformation. Once the TransformLink node is created, you can also use the Set Target button to link it to a different Tracker or Transform node. You can also bake the expressions on the transform knobs with the Bake Expressions button.

This node might seem redundant to the built-in functionality of Nuke7’s Tracker node that lets you create a Matchmove or Stabilize transform. Unfortunately the transform nodes that are created using this method are burdened by excessive python code on the ‘invert’ knob, which is evaluating constantly, degrading Nuke’s UI performance. Turn on “Echo python commands to output window” in the Preferences under Script Editor. In a heavy script with a few of these nodes, you will probably notice stuttery UI responsiveness and freezing.

Put the file somewhere in your nuke path. You can add the script as commands to your Nodes panel. This code creates a custom menu entry called “Scripts”. I have them set to the shortcuts Alt-O and Alt-L.

import tracker_link
nuke.toolbar('Nodes').addMenu('Scripts').addCommand('Link Roto', 'tracker_link.link_roto()', 'alt+o')
nuke.toolbar('Nodes').addMenu('Scripts').addCommand('Link Transform', 'tracker_link.link_transform()', 'alt+l')

Posted in Tools | Tagged , , | 5 Responses

Bake Roto

Bake Roto Nuke Script – Code

Bake Roto Interface
Bake Roto is a python script that will bake an arbitrary control vertex on a Nuke Rotopaint shape or stroke into position data. This is inspired by Magno Borgo‘s BakeRotoShapesToTrackers script. Baking is nearly instantaneous, and takes into account transforms for shapes parented under layers that have animations or expression links.

Select a Roto or RotoPaint node and run the script. Don’t forget to turn on the “toolbar label points” button to see the cv numbers. It’s on my list to make the interface for this better. I should learn PySide better and make a selectable list of CV points instead of a dropdown. Soon, when there is time!
[gist id=6968830]

Posted in Tools | Leave a comment

Distort Tracks

Distort Tracks Nuke Gizmo – Code

Distort Tracks Gizmo Interface
This gizmo reformats and/or distorts tracking data based on a uv distortion map input. When you are working with CG elements in your comp that are undistorted and padded resolution, sometimes it is useful to reconcile tracking data from a 3d position through a camera into screen space. This data can then be used to do stuff in 2d: track in lens flares, matchmove roto or splinewarps, etc. The problem is that when this tracking data comes back from our padded undistorted 3d scene into distorted, unpadded resolution comp land, it doesn’t line up.

Connect the UV input to a uv distortion map and set the channel that holds it, (for example, a LensDistortion node set to output type Displacement, outputting a UV distortion map into the forward.u and forward.v channels)
Set the padded resolution format and the destination format: Padded resolution is the overscan resolution that you are distorting from, Destination format is the comp resolution you end up in. If they are the same, set them both to be the same.
Add as many tracking points as you want and copy or link the data in. You can show or hide the input and output tracks for convenience. (It is easier to copy the data of many tracks in if you don’t see the output track knobs.)
Hit Execute, and all tracks will be distorted. The output tracking data will be copied into each tracks respective trk_out_# knob.

iDistort Input will theoretically let you plug an iDistort map in and have your tracking data distorted by it. UVMap Animation enabled will severely limit the speed at which the uvmap image data can be sampled, but will enable animated distortion maps.
Note that right now this only works with reformat types set to center, no resize, such as you would use when cropping a padded resolution cg plate back to comp resolution before distorting it. Theoretically this gizmo should work to ‘reformat’ tracking data as well. If you plug in an ‘identity’ uvmap, the tracking data should be undistorted, but reformatted from the source format to the destination format.
Also note that the distorted track output will switch to the reformatted track at the bounds of frame, so that the distorted track does not suddenly pop to 0,0 where the distortion map turns black.

Huge thanks to Ivan Busquets for the ninja-comp technique used to invert the UV Map using a DisplaceGeo.

Posted in Tools | Leave a comment