Skip to content

Instantly share code, notes, and snippets.

Expression {
expr0 "isinf(r) ? ((r(x+1,y)+r(x+1,y+1)+r(x+1,y-1)+r(x,y+1)+r(x,y-1)+r(x-1,y+1)+r(x-1,y)+r(x-1,y-1))/8) : r"
expr1 "isinf(g) ? ((g(x+1,y)+g(x+1,y+1)+g(x+1,y-1)+g(x,y+1)+g(x,y-1)+g(x-1,y+1)+g(x-1,y)+g(x-1,y-1))/8) : g"
expr2 "isinf(b) ? ((b(x+1,y)+b(x+1,y+1)+b(x+1,y-1)+b(x,y+1)+b(x,y-1)+b(x-1,y+1)+b(x-1,y)+b(x-1,y-1))/8) : b"
expr3 a
name infToAverage
selected true
xpos -68
ypos -273
}
@jedypod
jedypod / DOLLAR_GUI_HANDLER.nk
Created July 7, 2016 16:40
DOLLAR_GUI_HANDLER is a node to remove $gui expressions on Nuke nodes in a script. It is based on $gui Expression Finder by Falk Hofmann, but the code is re-written to be more robust, and to have functionality to remove $gui expressions as if the script were being rendered on the farm, instead of reverting back to the GUI values.
NoOp {
name DOLLAR_GUI_HANDLER
tile_color 0xd94848ff
hide_input true
addUserKnob {20 Handler l "\$gui Handler"}
addUserKnob {1 nodelist}
nodelist "H_high_low_switch.Switch1, RF_Yorktown_DEFOCUS.SHIT_SWITCHER, RF_Yorktown_BG1.ScanlineRender4, ScanlineRender1"
addUserKnob {26 ""}
addUserKnob {22 find_gui_nodes l "Find \$gui Nodes" T "# Find all nodes with knobs that have \$gui expressions\nnodelist = \[]\nfor node in nuke.allNodes(recurseGroups=True):\n for knob in node.knobs():\n if node\[knob].hasExpression():\n if '\$gui' in node\[knob].toScript():\n if node not in nodelist:\n nodelist.append(node)\n\nnodelist_comma = ', '.join(\[item.fullName() for item in nodelist])\nprint nodelist_comma\nnuke.thisNode()\['nodelist'].setValue(nodelist_comma)" +STARTLINE}
addUserKnob {22 remove_gui_expression l "Remove \$gui Expression" -STARTLINE T "# Remove \$gui expression\n#thisNode = nuke.selectedNode()\nthisNode = nuke.thisNode()\nnodelist_comma = thisNod
@jedypod
jedypod / DofCalc.nk
Last active December 4, 2022 14:58
DofCalc visualizes the near and far limit depth of field given a specified lens focal length, aperture, filmback size, and focus distance. Useful for visualizing plausible focus ranges given a matchmove camera and lidar scan.
set cut_paste_input [stack 0]
push $cut_paste_input
Group {
name DofCalc
label "<left>\nfocal length: \[format \"%.0f\" \[value f]]\nf-stop: \[format \"%.2f\" \[value N]]\nsubject dist: \[format \"%.2f\" \[value s]]\n\nhyperfocal dist: \[format \"%.2f\" \[value H]]\n---------------------------\ndof: \[format \"%.2f\" \[value dof]]\ndof near: \[format \"%.2f\" \[value Dn]]\ndof far: \[format \"%.2f\" \[value Df]]"
addUserKnob {20 DofCalc}
addUserKnob {4 depth_unit l "depth unit" t "Set your depth unit" M {mm cm dm m inch ft}}
depth_unit ft
addUserKnob {41 s l subject_distance T VAR.s}
addUserKnob {41 f l focal_length T VAR.f}
@jedypod
jedypod / CornerPinOffset
Created August 3, 2019 00:57
CornerPin node with offset controls for each corner. Useful for tweaking cornerpin after all keyframes are baked (e.g. , from a tracker), in case you need to cheat the perspective or something else.
set cut_paste_input [stack 0]
push $cut_paste_input
Group {
name CornerPinOffset
tile_color 0x9073adff
addUserKnob {20 PinControl}
addUserKnob {26 CornerPinControls l "" +STARTLINE T "<font size=5><b>Corner Pin Data</b></font>"}
addUserKnob {20 CornerPinData l "" +STARTLINE n 1}
addUserKnob {41 to1 T cpMaster.to1}
addUserKnob {41 enable1 -STARTLINE T cpMaster.enable1}
@jedypod
jedypod / BalanceGrade.nk
Last active December 4, 2022 14:50
BalanceGrade - A Nuke tool to neutralize and balance the color of multiple input plates. Can be used with the CalibrateMacbeth or mmColorTarget toolsets to calibrate gamut as well.
set cut_paste_input [stack 0]
push $cut_paste_input
Group {
name BalanceGrade
tile_color 0x6c9de1ff
addUserKnob {20 BalanceGrade}
addUserKnob {26 ColorMatrix_label l "@b;ColorMatrix" T " "}
addUserKnob {41 matrix T ColorMatrix.matrix}
addUserKnob {22 reset_mtx l Reset T "nuke.thisNode()\['matrix'].setValue(\[1,0,0,0,1,0,0,0,1])" +STARTLINE}
addUserKnob {26 ""}
@jedypod
jedypod / pworld_to_stmap_example.nk
Created February 16, 2020 20:38
PWorld to STMap Example
set cut_paste_input [stack 0]
version 12.0 v4
Camera2 {
inputs 0
translate {{curve x1 0.1968241632 s0 x20 1.389938712 s0} {curve x1 0.6442195177 s0 x20 0.4735943973 s0} {curve x1 5.948436737 s0 x20 7.470496655 s0}}
rotate {{curve x1 2.000000954 s0 x20 0.8000015616 s0} {curve x1 7.399996758 s0 x20 6.199992657 s0} {curve x1 2.669668575e-08 s0 x20 -1.334151278e-08 s0}}
name Camera1
selected true
xpos -140
ypos -918
@jedypod
jedypod / connect_to_closest.py
Created November 6, 2019 15:04
Nuke python script to connect each selected node's 0th input to the nearest node.
"""
# Add to menu.py
import connect_to_closest
nuke.toolbar('Nuke').addCommand('Edit/Node/Connect Multiple', 'connect_to_closest.run()', 'meta+shift+y', shortcutContext=2)
"""
import nuke
import math
@jedypod
jedypod / GamutCompression_blinkscript.cpp
Last active September 12, 2022 11:10
Jed Smith Gamut Compression Development
kernel GamutCompression : ImageComputationKernel<ePixelWise> {
Image<eRead, eAccessPoint, eEdgeClamped> src;
Image<eWrite> dst;
param:
float threshold;
float cyan;
float magenta;
float yellow;
int method;
@jedypod
jedypod / DefocusSwirlyBokeh.nk
Last active June 8, 2022 04:37
Creates Defocus with Swirly Bokeh aka Cat's Eye Bokeh. Based on Alexander Kulikov's CatsEyeDefocus: www.nukepedia.com/blink/filter/catseyedefocus.
set cut_paste_input [stack 0]
push $cut_paste_input
Group {
name DefocusSwirlyBokeh
tile_color 0xb16f43ff
addUserKnob {20 DefocusSwirlyBokeh}
addUserKnob {6 usegpu l "use gpu" t "You REALLY need a good GPU to use this node effectively. With CPU it will be excruciatingly slow." +STARTLINE}
usegpu true
addUserKnob {7 size l "bokeh size" t "The size of your defocus." R 2 100}
size 25
@jedypod
jedypod / roto_python_examples.nk
Last active May 6, 2022 19:36
some examples for setting expressions in the python api for the nuke rotopaint system
set cut_paste_input [stack 0]
push $cut_paste_input
RotoPaint {
cliptype none
curves {{{v x3f99999a}
{f 0}
{n
{layer Root
{f 2097152}
{t x44800000 x44428000}