NUKE SCRIPT: Camera Projection SetPosted by Dave W. - > Nuke 6.3v8 | 09/15/2012
Custom scripts for quickly creating camera projections. Set contains two Python scripts for creating a new camera based off of a selected source camera at the current Viewer frame. The scripts work based on the current selection in the DAG: 1 'Camera' node (required) and 1 'img' input node (optional).
The 'Camera Project Current Frame' command creates a new 'ProjCamS' node that has baked the values of the selected source camera at the current frame. A 'Project3D' node is created and automatically receives the 'cam' input from the new 'ProjCamS' node. In addition, if a texture input node that the 'Project3D' node accepts (i.e. Read, Roto, Blur, etc) is selected as well as the source camera, the texture input node will be connected as well. This command is a lightweight version for quick camera projection creation and use.
The 'Camera Project Source' command is much like the previous command with some extra options available. Instead of immediately baking the source camera values, the new 'ProjCamM' node expression links back to the source camera in case the source camera is known to be modified or changed. A new tab called 'Frame_Settings' is made available in the 'ProjCamM' node which allows the user to specify an frame to reference from the source camera, allowing quick adjustments after creation. A 'SET CURRENT FRAME' button will set the projection frame to the current Viewer frame along with a 'LOCK/UNLOCK FRAME' button enables/disables the user from updating the projection frame, allowing one to not accidentaly change the projection frame value. Finally, a 'BAKE FRAME' button mimcs the 'ProjCamS' node by breaking the expression links with the source camera and storing the values as keyframe animation, reducing processing time.
Some useful/interesting expressions for the 'projected frame' knob are given here:
Type: frame > # & frame < ## ? frame : 0
Type: frame > # & frame < ## ? frame : frame <= # ? # : ##
...where # and ## are two different frame numbers that specifiy a range: range( #, ## ).
NOTE: There are some limitations in regards to what node types the 'Project3D' node can use as 'img' inputs - in this case (or if no 'img' input node is specified at all), the scripts will still create the 'ProjCam' and 'Project3D' nodes; however the selected 'img' input node will not be connected.
DIRECT LINK (HD) : DW// Tutorial 03: Nuke - Camera Projection (Custom Scripts)