Skip to content

Instantly share code, notes, and snippets.

View kpprt's full-sized avatar

Christian Kauppert kpprt

View GitHub Profile
@kpprt
kpprt / CS_CameraShake.tcl
Last active September 1, 2017 11:27
A more advanced camera shake generator for Nuke that combines up to 3 shakes of different frequencies and amplitudes. It also provides an auto-scale function and a shake curve preview.
set cut_paste_input [stack 0]
version 10.5 v3
push $cut_paste_input
Group {
name CS_CameraShake1
tile_color 0x9c0000ff
selected true
xpos 2820
ypos -1210
addUserKnob {20 CS_CameraShake}
@kpprt
kpprt / open_file_folders.py
Last active August 23, 2017 15:19
Calling this script in Nuke opens all file paths in the Explorer/Finder within the current selection of enabled nodes. It can also recurse into enabled groups and apply a filter that only opens paths from specific types of nodes, e.g. Read or Write.
import os
import platform
import subprocess
def open_file_folders(nodes, filter = None, recurseGroups = True):
for n in nodes:
if n.knob('disable') and n['disable'].value() == True:
#print 'skipping {0} because it is disabled'.format(n['name'].value())
continue
if recurseGroups and isinstance(n, nuke.Group):
@kpprt
kpprt / CS_PSCrop.tcl
Created July 25, 2017 08:16
Simple Crop that works like the change canvas size function in Photoshop. Its intended to be used to crop mattepaintings that have been extended over the size of the frame. It can also be used to find out how much mattepainting outside the frame is needed due to camera movement. Afterwards the crop can be inverted to fit the frame again (the ext…
set cut_paste_input [stack 0]
version 10.5 v4
push $cut_paste_input
Group {
name CS_PSCrop1
tile_color 0xa57aaaff
selected true
xpos -1690
ypos -466
addUserKnob {20 CS_PSCrop}
@kpprt
kpprt / CS_ColorCorners.tcl
Created April 12, 2016 15:03
Create color overlays at the corners of an image in Nuke. Might be helpful for matching colors of a corner pin.
set cut_paste_input [stack 0]
version 9.0 v8
push $cut_paste_input
Group {
name CS_ColorCorners1
selected true
xpos 840
ypos -130
addUserKnob {20 CS_ColorCorners}
addUserKnob {20 corner1 l "Bottom Left Corner" n 1}
@kpprt
kpprt / CS_STMap.tcl
Created April 11, 2016 09:47
Simple STMap for Nuke that also supports alpha.
set cut_paste_input [stack 0]
version 9.0 v8
CheckerBoard2 {
inputs 0
format "1920 1080 0 0 1920 1080 1 HD_1080"
name CheckerBoard1
selected true
xpos -150
ypos -417
}
@kpprt
kpprt / bash_snippets.sh
Last active August 8, 2017 16:46
A collection of short one line bash snippets.
#!/bin/bash
# find hidden files recursively from the current folder which file names are not starting with a dot
find . -flags +hidden -name \[\!.\]\*
# unhide all files recursively from the current folder which file names are not starting with a dot
find . -flags +hidden -name \[\!.\]\* -exec chflags nohidden {} \;
# simple search and replace in all file names of current folder
# echo is there for preview, remove it to actually execute the command
@kpprt
kpprt / CS_EdgeExtend.tcl
Last active February 10, 2018 18:17
A simple edge extend node for Nuke.
set cut_paste_input [stack 0]
version 9.0 v8
push 0
push $cut_paste_input
Group {
inputs 2
name CS_EdgeExtend1
selected true
xpos -150
ypos 1214
@kpprt
kpprt / CS_CropToBBox.tcl
Last active March 7, 2019 17:51
Dynamically crop to the current or an external bounding box in Nuke. This might save performance e.g. when piping in a roto shape bbox of a garbage matte.
set cut_paste_input [stack 0]
version 10.5 v7
push $cut_paste_input
Group {
name CS_CropToBBox1
tile_color 0xa57aaaff
addUserKnob {20 CS_CropToBBox}
addUserKnob {41 numpixels l "Add Pixels" T AdjBBox1.numpixels}
addUserKnob {41 softness T Crop1.softness}
addUserKnob {41 reformat T Crop1.reformat}
@kpprt
kpprt / serialize_node.py
Last active March 17, 2016 18:12
Serialize a node to text in a NoOp node in Nuke. This could be helpful if some nodes of plugins etc. are causing problems on other machines like render slaves even if they are not connected in the node tree, but you also don't want to delete them.
# TODO:
# disconnect the SerializedNode completely
# set the position of the SerializedNode to the source node
# optional: after restoring the source node, reconnect all former inputs correctly
# (could be tricky when the script has changed in the meantime)
# optional: create the invisible node via python instead of pasting TCL code
for n in nuke.selectedNodes():
node_as_string = 'set cut_paste_input [stack 0]\npush $cut_paste_input\n' + n.Class() + ' {'
node_as_string += n.writeKnobs(nuke.TO_SCRIPT | nuke.WRITE_ALL)
@kpprt
kpprt / make_file_paths_relative.py
Last active September 3, 2017 17:29
Make all file references relative in a Nuke script when they start with the project directory (case-sensitive)
def remove_prefix(text, prefix):
if text.startswith(prefix):
return text[len(prefix):]
return text
undo = nuke.Undo()
undo.begin("make file paths relative")
project_dir = nuke.Root()['project_directory'].value()
if not project_dir.endswith('/'):