Focus Distance Locator for Arnold and Viewport 2.0

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:

  1. Copy those lines to the script editor
  2. Select all of it
  3. Drag it to a shelf with the Middle Mouse Button
  4. Rename it (Right Click, Edit)

Cheers, D

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s