Camera Chaser – a bit of MEL…

Repetitive tasks never bothered me in the past, to an extent… Maybe it’s age that’s causing me to reevaluate tasks that sometimes took several minutes to setup and just fix it with a small script. I started my current job 8 months back, along with using Mental Ray again. Like all renderers you get your ups and downs but one nuance that’s always bothered me is rendering with a lens shader on my camera and then trying to create mattes, occlusion or motion vectors etc. in MR. You arrive in your post production software and start looking through your passes to find strange shading and values on matte passes that live between 0 and 1. “Ahh $*#%, I’ve left the lens shader on…” In the past using “create layer override” to ignore a shader when rendering has worked… periodically… or not at all. It got to the point where it was so unreliable on the renderfarm that I would link up a fresh camera, pass all it’s values through to the child camera, snap it into place of the master camera and just run a layer override on the render layer for my camera. Why do all that when you can just click a button? So here it is, a very simple but useful script to do just that, along with an icon to download at the bottom.

[vr_jsp width=”100%” height=”300px”]<code>
if(`window -ex camChaseWin`)
deleteUI camChaseWin;
window -t “camChaser”
-bgc .45 .45 .45
-widthHeight 200 55
columnLayout -adjustableColumn true;
button -label “Create Camera” -c “camChaser()”;
button -label “Close” -c (“deleteUI -window ” + “camChaseWin”);
//setParent ..;
showWindow camChaseWin;

proc camChaser()
string $getCamName[] = `ls -sl`;
string $getCamShap[] = `ls -lf -dag -sl -s`;
if (size($getCamName) == 0)
warning “Please select a camera”;
else if(`objectType -isType “camera” $getCamShap`)
//Give our newly created camera a name
string $getCamNam[] = `ls -sl`;
string $newCamera[] = `camera -n ($getCamNam[0] + (“Child”))`;
//Snap our new camera to our current camera
float $pos[] = `xform -q -ws -rp $getCamNam[0]`;
float $rot[] = `xform -q -ws -ro $getCamNam[0]`;
move -a -ws -rpr $pos[0] $pos[1] $pos[2] $newCamera[0];
rotate -ws $rot[0] $rot[1] $rot[2] $newCamera[0];
//share the attirbute love
connectAttr -f ($getCamNam[0] + “.focalLength”) ($newCamera[0] + “.focalLength”);
connectAttr -f ($getCamNam[0] + “.focusDistance”) ($newCamera[0] + “.focusDistance”);
connectAttr -f ($getCamNam[0] + “.horizontalFilmAperture”) ($newCamera[0] + “.horizontalFilmAperture”);
connectAttr -f ($getCamNam[0] + “.verticalFilmAperture”) ($newCamera[0] + “.verticalFilmAperture”);
connectAttr -f ($getCamNam[0] + “.centerOfInterest”) ($newCamera[0] + “.centerOfInterest”);
connectAttr -f ($getCamNam[0] + “.lensSqueezeRatio”) ($newCamera[0] + “.lensSqueezeRatio”);
connectAttr -f ($getCamNam[0] + “.fStop”) ($newCamera[0] + “.fStop”);
connectAttr -f ($getCamNam[0] + “.shutterAngle”) ($newCamera[0] + “.shutterAngle”);
//parent so it follows
parent $newCamera[0] $getCamNam[0];
warning “Please select a camera to duplicate”;

Icon: camButton

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Powered by

Up ↑

%d bloggers like this: