Linking Values

From RMIT Visual Effects
Jump to: navigation, search

Nuke is a very open application, which can be easily extended by the user. An example is the ease by which values in one node can be made to drive those in another. This is done by the use of expressions. One of the advantages of this that it can make complex animations easy to master, enabling many node parameters to be driven from one 'master' node.

How to copy and link values from one node to another

Below is shown how to copy the values from one node to another. This is done by 'Option' dragging the little icon that looks like a graph to its destination parameter. This will only copy the value from that particular frame, with no animation.

Copying a value from one node to another by 'option' dragging it.

To link the animation from one node to another we 'Command' drag it. This will automatically place one node in a slave relax hip to another. We can review this relationship 'under the hood' by 'Right' clicking on the value and selecting 'Edit expression'. A simple expression can be seen, the syntax of which is fairly obvious. In this case, the parameter 'Multiply3' is being driven by the parent 'Multiply3'.

An expression that references the values of one parameter to drive another.

This simple expression can be edited and elaborated on. In the case of the expression above it was changed from: parent:Multiply1.value to 1-(Multiply1.value). This simple maths inverts the child value.

Press 'Expand' and select and copy everything below this line, then paste into the Nuke node graph.

set cut_paste_input [stack 0]
version 9.0 v7
Constant {
 inputs 0
 channels rgb
 color 0.5
 format "1920 1080 0 0 1920 1080 1 HD_1080"
 name Constant2
 selected true
 xpos -62
 ypos 781
}
set N14f63b20 [stack 0]
Multiply {
 value {{1-(MultiplyMaster.value)}}
 name MultiplySlave
 selected true
 xpos -188
 ypos 958
}
push $N14f63b20
Multiply {
 value 1.28
 name MultiplyMaster
 selected true
 xpos 91
 ypos 965
}
CopyRectangle {
 inputs 2
 area {363 194.5 1750 801.5}
 name CopyRectangle3
 selected true
 xpos -64
 ypos 1094
}
Write {
 name Write2
 selected true
 xpos -64
 ypos 1126
}
StickyNote {
 inputs 0
 name StickyNote3
 label "Open MultiplyMaster and play\nwith its value. See how MultiplySlave\nis the oposite of its master. This is done\nwith a simple link expression (the invert of n\n= 1-n). "
 selected true
 xpos 194
 ypos 947
}

How to make brand new parameter knobs

The problem with using expressions in this manner is that they are bothersome to edit. Instead we can make a little widget that controls the expression. Here's how:

  1. Create a Multiply node.
  2. Make a NoOp node (its a kind of 'blank' node).
  3. Rename it 'Moderator'
  4. Right click on its tab and select 'Manage user knobs'.
  5. From the resulting dialogue box select 'Add / Floating Point Slider'. Edit it in the following way:
    • Name: 'multiplyvalue'
    • Label: 'multiply value' (a label can contain upper case letters and spaces)
    • Tooltip: 'This multiplies you fool!'
    • Minimum: '0'
    • Maximum: '1'
  6. Click done
  7. Now right click in the 'value' parameter of the Multiply and write: =value*Master.multiplyvalue
  8. Result!

You can now control the value of the Multiply, using the sliding value knob of 'Master'. Code snippet below demonstrates a simple example of such linking:

Press 'Expand' and select and copy everything below this line, then paste into the Nuke node graph.

set cut_paste_input [stack 0]
version 9.0 v7
StickyNote {
 inputs 0
 name StickyNote1
 label "Both the Add nodes are 'powerd' by an expression\nSee this page for examples:\nhttp://cameroncarson.com/nuke-wave-expressions\n\nA key value is animated using another expression\nlinked from the Moderaor node. Add1 is the inverse\nof Add2 (again using a simple expression). "
 selected true
 xpos -58
 ypos -149
}
Constant {
 inputs 0
 channels rgb
 color 0.066
 format "1920 1080 0 0 1920 1080 1 HD_1080"
 name Constant1
 selected true
 xpos -188
 ypos -169
}
set N19b4d920 [stack 0]
Add {
 value {{random(3,frame*Moderator.speed)}}
 name Add1
 selected true
 xpos -277
 ypos 7
}
push $N19b4d920
Add {
 value {{1-random(3,frame*Moderator.speed)}}
 name Add2
 selected true
 xpos -82
 ypos -6
}
CopyRectangle {
 inputs 2
 area {363 194.5 1750 801.5}
 name CopyRectangle1
 selected true
 xpos -184
 ypos 140
}
Write {
 name Write1
 selected true
 xpos -184
 ypos 273
}
Viewer {
 frame 3
 frame_range 1-100
 name Viewer1
 selected true
 xpos -184
 ypos 297
}
push $cut_paste_input
NoOp {
 name Moderator
 selected true
 xpos -368
 ypos -136
 addUserKnob {20 User}
 addUserKnob {7 speed}
 speed 0.31
}
StickyNote {
 inputs 0
 name StickyNote2
 label Animated!
 note_font_size 30
 selected true
 xpos -191
 ypos -293
}