Dave Girard's 101 Autodesk® Maya® Tips is now available in Kindle, interactive iPad edition and DRM-free EPUB/PDF editions. Work faster, cry less. Read more about the ebook.

Follow cgbeige on Twitter

Topics by tag:

Recently published articles by Dave G:

Free downloads by Dave G:

Mac OS X-only downloads:

Amazing Python Script for Nuke That Creates a 3D Camera from a V-Ray EXR Image

If you do compositing in Nuke, you know it can be annoying to get camera data in and out of a 3D package like Maya or Max. Imported camera data quickly gets outdated when new frames are rendered, which forces you to jump back and forth between your 3D app and Nuke. Fortunately, yesterday I discovered a script for Nuke that makes it dead simple to generate camera data from the camera metadata embedded in V-Ray’s EXR-rendered images. After installing the Python script as a menu item, just select a V-Ray EXR render and the script will make a camera node that you can plug into a 3D scene template. It’s amazing:

It even works with animations, meaning you never have to jump back to your 3D app to get new camera data – just kick out a new camera node for the newer EXR frames.

So, here is how you install it. Grab the Python code from the Pastebin site here. Paste it to a new plain text file in your Nuke scripts folder. In OS X and Linux, that’s ~/.nuke/ (where ~/ is your home folder). OS X users can make short work of it by doing this in the terminal after copying the code:

pbpaste > ~/.nuke/createExrCamVray.py

pbpaste is a command line version of a pasteboard paste command in OS X (pbcopy does a copy if you want to pipe to the clipboard). Next, add the call to the script to your Nuke menu bar by adding these lines to the end of Nuke’s menu.py file (For me, it’s located in /Applications/Nuke6.3v4/Nuke6.3v4.app/Contents/MacOS/plugins/menu.py):

import createExrCamVray
m = menubar.addMenu("V-Ray")
m.addCommand("Create Camera from EXR", "createExrCamVray.createExrCamVray()")

The code is wrapping on my blog site, so it’s better to grab it from this text file. Then, once you relaunch Nuke, you’ll be set up.

6 notes | Permalink