Max’s Nuke Python, TCL and Expression Snippets

Just one more blog with python and TCL snippets that I use frequently in Nuke. More can be found on my github:

https://github.com/plasmax/nuke-python


Python 

https://docs.thefoundry.co.uk/nuke/100/pythonreference/
https://docs.thefoundry.co.uk/nuke/100/pythondevguide/

To remove all knobChanged, updateUI, autolabel callbacks from a nuke script:
[n.knob('knobChanged').setValue(None) for n in nuke.allNodes(recurseGroups=True)]
[n.knob('updateUI').setValue(None) for n in nuke.allNodes(recurseGroups=True)]
[n.knob('autolabel').setValue(None) for n in nuke.allNodes(recurseGroups=True)]


TCL 

 

http://www.nukepedia.com/tcl/tcl-reference

To get the session node id (e.g. node019b423b). Replace node_full_name with something like root.Group1.Group3.Grade2
node node_full_name

Advertisements

Maya Tips and Handy Scripts

Decided to keep a log of useful Maya MELscripts & settings I’ve collected from all over the web!

Camera Switching scripts http://forums.cgsociety.org/archive/index.php/t-983953.html
CameraListDialog.mel
SwitchPerspCam.mel

Wireframe Toggle On/Off (Useful for previewing surfaces on selected objects)
ToggleWireframe.mel

Reload All Textures in scene
UpdateAllSceneTextures.mel

Align Pivot to Central Base of object
BasePivot.mel

Toggle Between OS and QT Import/Export Dialog Window (Useful if Maya’s Dialog Runs Slow!)
OSExplorerDialogSwitcher.mel

Toggle Isolate Select Script
http://nerd.paololazatin.com/toggle-isolate-selected-in-maya/

ToggleIsolateSelected.mel

ToggleXray.mel
ObjectMaterialAttributes.mel
RefreshSelectedSwatches.mel
SetSelectedTextureNodeDirectory.py

Set Selected Objects’ Normal Angles to 45
ToggleXray.mel

Inverting Individual Texture Color Channels in Maya

I was looking for a way to invert the green channel of my normal map in Maya, so that I don’t have to flip it in photoshop for engine export (UDK, Skyrim Creation Kit, 3ds Max). 

Turns out it’s unbelievably simple.

Image

In the “File” Node that loads in your texture there are options for Color Gain and Color Offset. You can think of them as Multiply and Add/Subtract.

Quick explanation: Multiply (Color Gain) your chosen channel by -1 and add (Color Offset) 1 to your channel to invert it. Make sure colors are set to RGB, 0 to 1.0 in the color picker.

 

The maths behind it:

Value inversion can be done with: 1 – n (where n is whatever value the pixel has. White has a value of 1, black 0, middle grey 0.5. So a 70% grey, 0.7, will be inverted like this: 1 – 0.7 = 0.3)

Luckily this equation can be rewritten as (n*-1)+1=1-n ( and also as (n-1)*-1=1-n , though we will be using the first one).    

So first we need to Multiply our channel n by minus 1. In the case of the normal map, channel for green. 

Click on the swatch for Color Gain, make sure it’s set to RGB, 0 to 1.0 and type -1 in the G channel.

Click on the swatch for Color Offset, make sure it’s set to RGB, 0 to 1.0 and type 1 in the G channel.

 

Congratulations, you can now use correctly oriented normal maps in your Maya Viewport! This does not work in the Hardware Shader viewport mode, only with Viewport 2.0.

Matchmover HollywoodCameraWork

A quick test to see if matchmover’s capabilities can equal those of Boujou/Syntheyes/3dequalizer. A good solving engine but I find supervised tracking to be fairly limited in terms of reviewing tracks. Graph editing capabilities are fairly useful in refining solves. Working with interlaced footage produced many slowdowns and crashes, something I didn’t experience with regular plates. The software is in dire need of a lasso tool, along with several other very important updates. Favourite feature: holding Ctrl to scrub in the viewport.