MtoA Arnold for Maya DOF Focus Assist Tool

Hey! I’m an old school CG artist from the days of CPU rendering and depth pass and zDefocus, and only recently got over the psychological barrier of doing in-camera DOF. I have one conclusion – it’s liberating. Of course, GPU render engines like RedShift is the real deal for these kind of workflow. But for now, for those who want to give it shot at using Arnold for in-camera DOF, I wrote a little script to quickly set up a focus assist locator which you can position as you wish. All you’ll need to do is to select the camera and run the script! Hope it helps and let me know if you’ve some ideas to improve this!

//Author: Ronald Fong
//Date: 09 June 2018
//Usage: Just select your render camera and run the script. Enjoy!

global proc rf_aiDof() {
    string $cam[] = `ls -sl`;
    if (!objExists($cam[0])) {
        print "Ooops! Please select a camera! \n";
        }
    else {
        string $camShape[] = `listRelatives -s $cam[0]`;
        float $camPos[] = `getAttr ($cam[0] + ".translate")`;
        string $locs = `distanceDimension -sp 1 1 1 -ep $camPos[0] $camPos[1] $camPos[2]`;
        connectAttr -f ($locs + ".distance") ($camShape[0] + ".aiFocusDistance");
        setAttr ($camShape[0] + ".aiEnableDOF") 1;
        setAttr ($camShape[0] + ".aiApertureSize") 1;
        setAttr ($camShape[0] + ".aiApertureBlades") 5;
        string $creation[] = `ls -sl`;
        string $camLoc[] = `listRelatives -parent $creation[0]`;
        parent `listRelatives -parent $creation[0]` $cam[0];
        parent $creation[1] $cam[0];
        select -cl;
        print "Success! Position the focus locator as you please! \n";
    }
}

rf_aiDof();
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *