Precomp
The Precomp node is like a Group node, but its content is stored in an independent .nk file. This allows you to save a subset of the node tree as a separate Nuke script, render the output of this saved script, and read the rendered output back into the main comp as a single image input. Precomp nodes can be useful in at least two ways:
• They can be used to reduce portions of the node tree to pre-rendered image inputs. This speeds up render time, as Nuke only has to process the single image input instead of all the nodes that were used to create it. Because the original nodes are saved in a separate .nk script, you also maintain access to them and can adjust them later if necessary.
• They enable a collaborative workflow. While one artist works on the main comp, others can work on the sections that have been exported using the Precomp node. These sections can be edited, versioned, and managed independent of the main comp.
You can also create this node by pressing Ctrl/Cmd+Shift+P on the Node Graph.
See also Group.
Inputs and Controls
Control (UI) |
Knob (Scripting) |
Default Value |
Function |
---|---|---|---|
Precomp Tab |
|||
file |
file |
N/A |
Sets the .nk script to use as the contents of the precomp. |
Reload |
reload_script |
N/A |
Click to reload the .nk script specified in the file control. |
Open |
open |
N/A |
Click to open the .nk script specified in the file control in a new Nuke session. |
Render |
render |
N/A |
Click to render the .nk script specified in the file control and output the results from the Precomp node. |
read file for output |
reading |
disabled |
When enabled, the Precomp node reads in the rendered precomp image rather than calculating the output of the precomp script. When disabled, Nuke calculates the output of the precomp script. |
missing frames |
on_error |
error |
Sets the behavior when there is an error opening the output file: • error - display an error message on any missing frames. • black - replace any missing frames with black. • checkerboard - replace any missing frames with a checkerboard image. • read input - display the result of the input tree rather than the rendered file on any missing frames. |
Reload |
reload_write |
N/A |
Click to re-read the image from disk. |
advanced |
|||
output node |
output |
N/A |
Sets the name of the Write node to use instead of the Output node in the precomp. You can use this control to override what is set as the Output node in the precomp script. |
enable |
use_output |
disabled |
When enabled, the Write node specified in the output node control is used instead of the Output node in the precomp. |
Step-by-Step Guides
Video Tutorials
NUKE's Precomp node with Frank Rueter from Foundry on Vimeo.
Nuke 6 introduces the Precomp node, or precomp workflow, which enables you to deal with more complex scripts in a more efficient way, as well as use a collaborative workflow with Nuke. So, in this tutorial we will investigate a few of its options.
This script here is a very straightforward matte painting. At the top here, we have a sky, and we have added a live action plate and some foreground in front of that all the way until we have our final framing. What I want to do now is replace the sky at the top with a Precomp node. I’m just going to select it, right-click, go to the Other > Precomp. That brings up a panel that prompts us for a Nuke script, a render sequence, channels, and what to do with the original nodes. Let’s start at the top. The Precomp script I want to generate with those selected nodes, I will call that skyPrecomp instead of the default Precomp1. The default location is where my current script is, and that’s fine. Then we have the render path for the intermediate renders, which I will change to point into the render sub-directory. I will call them skyPrecomp as well and save as an .exr.
When we render the Precomp, all I want to render is rgb because I don’t care about the other channels. And then finally, because we will be replacing the Precomp node, we get to choose what we do with the currently selected nodes. Do we want to keep them or just backdrop them (add backdrop) to keep them in our main script? Do we want to just keep them as is (no change) or do we want to delete them? Since I want to clean up my main comp, I will just delete them. And now, finally, when I hit OK, it will generate the skyPrecompV1 script and, in this case, we will just overwrite the one that already exists on disk. And the last step, Nuke prompts us to choose the node we want to use as the Precomp’s output. That will be fed into the main comp’s input. So, Crop24 was the node we looked at a second ago, and that’s the one we need, so I will hit OK.
All my nodes have now been replaced by a single Precomp node that makes my main comp a bit tidier. In the panel, you can see which Nuke script this Precomp node references, and if we want to see the internals of this external script, we just hit Open. That opens a new instance of Nuke and shows us the Nodes we just exported into the Precomp script. At the bottom of the node that we designated as our Precomp’s output, we will see the Write node that we defined with our skyPrecomp.exr sequence and the channels set to rgb. That’s what we just did in the Python panel, followed by an Output node. The Output node is not strictly required in the Precomp script, but it’s a good idea to have it because it makes it very obvious which node in the Precomp script feeds into the main comp. So, just to illustrate how this works now, I will just bring up the Viewer in my Precomp and deactivate all of the Grade nodes, for example. Save this, then back in my main comp I will hit Reload, and we will see the change of the external Precomp script reflected in our main comp because it’s been pulled in through this node. You will also notice that we get those input pipes. That’s because when you create a Precomp, it works in a very similar way to creating a Group node, which means every unconnected node in your Precomp, or your node selection, gets an Input node. I want to get rid of those because we don’t want any Inputs. I will select them, go to Edit > Select Similar > Class, and that will select all of the Input nodes in my script, and I will just Delete them. Save again, and now if I reload the script, those input pipes disappear, and everything is nice and tidy now.
Back in our Precomp, let’s reactivate the Grade and add this moon into the upper right corner. Let me version up my Write node. I will just go to Alt+up arrow or Edit > Node > Filename > Version Up. Now my Write node is version 02, I will go ahead and save a new version of my script: File > Save New Version. So our skyPrecomp becomes version 2 as well. In our main comp, we can use the same up versioning, so I will hit Alt+up arrow on my Precomp, which will change its version number and now point to the version 2 script.
So, you will see that we can now easily hand this over to a matte painter to keep working on the sky. Every time he saves, we can reload and we get his updated work in our main comp. Also, if this gets too heavy because this is actually live processing the external tree, we can always choose to Render the tree into its output. Let me just render the first frame, hit OK, and once the render is done, the option read file for output checks itself automatically. The Precomp node will go green and the auto-label will now tell you that it is now reading the image file from disk, rather than the Nuke script. This will obviously make your main comp run faster.
Now, lets go back to our Precomp script. We want to keep control of that moon in our main script, so I will cut that from here and paste it into our main comp. In order to combine the moon with our main script, we need an input pipe again. Since we deleted them, we will have to go back and create a new input. I will just attach an Input node as a placeholder for the moon in our Precomp script, and save again. Back in our main comp, I will hit Reload and we will see two things. First of all, we will get an error because the Precomp script has changed on disk, and therefore, its rendered file may be out-of-date. That’s what this error is saying. So, you should uncheck read file for output to make sure you are reading the up-to-date Precomp script from disk again, and now that we added an input node, we also get the new pipe. So, now we can plug the moon in here and keep control over it in the main comp, but it’s being combined with the Precomp script, according to where this input is in the Precomp script. That way, you can interlace your Precomp and your main comp, and still create a collaborative workflow.
Once all of this is done, let’s say we need to start a new shot and we want to start with an already existing Precomp script. All we need to do is create a Precomp node with nothing selected, and if nothing is selected, then all we get is an empty Precomp node. Now, we can manually browse for the already established Precomp, and there we are. Now we can start a new script with this Precomp node in place.