docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Cinemachine Auto Focus

    This CinemachineCamera extension drives the Camera's focusDistance property. It can be used to lock focus onto a specific object, or (in HDRP) to auto-detect what is in front of the camera and focus on that.

    FocusDistance is only relevant for physical cameras, and appropriate processing must be installed for it to have any visible effect.

    As of this writing, only HDRP provides out-of-the-box handling to process the Camera's focusDistance. In HDRP:

    1. Create an active Volume containing a Depth Of Field override.
    2. In the DepthOfField override, activate Focus Mode and set it to Physical Camera.
    3. In the DepthOfField override, activate Focus Distance Mode and set to Camera.

    With these settings, the focus distance set by Cinemachine Auto Focus will have a visible effect while the camera is within the Volume.

    Example Auto Vocus Volume

    Properties:

    Property: Function:
    FocusTarget The camera's focus distance will be set to the distance from camera to the selected target. The Focus Offset field will then modify that distance.
    None Focus tracking is disabled.
    LookAtTarget Focus offset is relative to the LookAt target.
    FollowTarget Focus offset is relative to the Follow target.
    CustomTarget Focus offset is relative to the Custom target set in the CustomTarget field.
    Camera Focus offset is relative to the camera. Use this setting to directly set the focus distance using FocusDepthOffset.
    ScreenCenter HDRP only: Focus will be on whatever is located in the depth buffer at the center of the screen.
    Custom Target The target to use if Focus Target is set to CustomTarget.
    Focus Depth Offset Offsets the sharpest point away in depth from the focus target location.
    Damping The value corresponds approximately to the time the focus will take to adjust to the new value.
    Auto Detection Radius HDRP-only: Radius of the AutoFocus sensor in the center of the screen, used when Focus Target is set to ScreenCenter. A value of 1 would fill the screen. It's recommended to keep this quite small. Default value is 0.02.
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)