Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question ARfoundation manual focus distance

Discussion in 'AR' started by TumbleRoll, Apr 22, 2021.

  1. TumbleRoll

    TumbleRoll

    Joined:
    Mar 11, 2021
    Posts:
    1
    When disabling auto focus is it possible to set the fixed focus distance? Trying to improve smaller image target tracking instead of waiting for autofocus to decide when to focus. Unfortunately the fixed focus at default is too far to track these image targets
     
  2. re-cheid

    re-cheid

    Joined:
    Apr 10, 2017
    Posts:
    34
    We'd also like to do that.
    Since 3D content is more stable in fixed focus we'd like to switch there after tracking a marker. On Android it works fine, the fixed focus distance resets to whatever the default is. However on iOS the current focus distance at the time of setting to fixed mode is kept, hence we have a very close focus after tracking the marker.
    A setting of that distance would be helpful.
     
  3. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,816
    No. The AR toolkits control the camera and do not expose APIs to change focus distance
     
  4. daverin_n

    daverin_n

    Joined:
    Oct 27, 2020
    Posts:
    11
    Since the this last response a lot has changed. With com.unity.xr.arkit: 5.1.0-pre.4 we now have advanced hardware control such as exposure, white-balance and focus.

    I am however confused as to how we can use the new locked camera focus API. We can now lock the focus with
    Code (CSharp):
    1. lockedCamera.focus = new ARKitFocus(lensPosition);
    This takes in a value from 0 to 1. According to the Apple docs this represents the range of possible positions of the lens; 0 being the closest, 1 being the furtherest (btw the example here is incorrect, 2 is not a valid input).

    This method of adjusting the focus is not compatible with the general way of creating DOF effects in 3D. Ideally we'd want to set a focus distance for the virtual camera, and then set the same value to the physical camera. According to the apple docs, Scenekit is able to accomplish this with `focusDistance` property.
     
  5. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,018
    Thanks for reporting the incorrect sample code @daverin_n.

    Generally our philosophy with our provider plug-ins is to transparently make our partners' platforms accessible in Unity. The Apple ARKit XR Plug-in is based on ARKit, and does not import SceneKit. For now we recommend that you give this API design feedback to Apple.
     
  6. daverin_n

    daverin_n

    Joined:
    Oct 27, 2020
    Posts:
    11
    Thanks for your reply @andyb-unity.

    I think you guys ought to question your philosophy. It doesn’t make sense to blindly implement provider functions without considering how they would work in Unity. At the extremes this philosophy leads to things such as this.

    Asking yourself “What could this method/function enable in Unity?” would be a good first step to delivering software that is of value to your customers.

    Moving past philosophy, let’s solve some problems.

    My guess is that SceneKit is using the hardware specs of the main camera device lens to make this calculation. We could probably do something similar ?
     
  7. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,018
    AR Foundation is limited by Unity's graphics API and cannot import environment probes with a non-identity rotation at this time. We have notified the Graphics team and are working on a fix, but this a major change to how reflection probes are currently architected and will take a significant amount of time and collaboration to land.

    If you develop an extension of ARKit's existing API's you are welcome to distribute this on the Asset Store.