Hi There,
This is a simple script which creates a Locator object for easy DOF adjustments (default persp camera).
You can find the better version here:
True Focus Distance Loacator
What the script does:
- Calculate the distance between the camera and the Locator via a Distance Between node
- Connect the distance value to the camera (Viewport 2.0 and Arnold)
- Create an expression to convert the persp camera Focal Length and F Stop values to the Arnold specific Aperture size value
- Enable DOF in Viewport 2.0 and for Arnold
- Scale up the Locator a bit
spaceLocator -p 0 0 0;
rename "locator1" "focus_distance_locator";
shadingNode -asUtility distanceBetween;
connectAttr -f persp.translate distanceBetween1.point1;
connectAttr -f focus_distance_locator.translate distanceBetween1.point2;
connectAttr -f distanceBetween1.distance perspShape.aiFocusDistance;
connectAttr -f distanceBetween1.distance perspShape.focusDistance;
expression -s "perspShape.aiApertureSize = perspShape.focalLength/10/perspShape.fStop/2;" -o perspShape -ae 1 -uc all ;
setAttr "perspShape.aiEnableDOF" 1;
setAttr "perspShape.depthOfField" 1;
setAttr "focus_distance_locator.scaleZ" 10;
setAttr "focus_distance_locator.scaleX" 10;
setAttr "focus_distance_locator.scaleY" 10;
Save it to a shelf:
- Copy those lines to the script editor
- Select all of it
- Drag it to a shelf with the Middle Mouse Button
- Rename it (Right Click, Edit)
Cheers, D