Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Unity 2018.3 is now released.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Disabling Auto Focus

Discussion in 'Handheld AR' started by danjspoor, Nov 8, 2018.

  1. danjspoor

    danjspoor

    Joined:
    Mar 22, 2018
    Posts:
    2
    @tdmowrer Is there way to disable the camera auto focus with AR foundation? When testing on an iPhone 8, anytime I move the camera slightly, the AR objects appear to move in and out slightly, which gets annoying after a while... especially when trying to do a smooth video recording.

    I tested the example scene in ARKit Plugin to conclude that it also happens when auto focus is turned ON, but does not happen when it's turned OFF. I don't see a similar option to turn this off in AR Foundation. Is there any plan to add this option? Is this possibly unique to my device or is there another solution that would allow auto focus to stay enabled without the unwanted effect?

    If you want a sample video to see this, please let me know.

    Thanks!
     
  2. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    352
    No, there is no way to set the focus mode, and ARKit enables it by default. We'll be adding this soon, though.
     
    danjspoor likes this.
  3. danjspoor

    danjspoor

    Joined:
    Mar 22, 2018
    Posts:
    2
    Ah ok. Thanks. Glad to hear it'll be added soon.
     
  4. ElinH

    ElinH

    Joined:
    Aug 29, 2017
    Posts:
    8
    Any update on this?
     
  5. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    352
    Yep, support for this was added in preview 21 in December. See the changelog for details.
     
  6. ElinH

    ElinH

    Joined:
    Aug 29, 2017
    Posts:
    8
    Oh that's awesome.
    But I can't find any documentation how to disable the auto focus.
    Can you give me a example code snippet?
     
  7. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    352
    There is a public property on the ARCameraOptions that you can set via script code. This example disables auto focus:

    Code (csharp):
    1. GetComponent<UnityEngine.XR.ARFoundation.ARCameraOptions>().focusMode = UnityEngine.XR.ARExtensions.CameraFocusMode.Fixed;
     
    Blarp likes this.
  8. Blarp

    Blarp

    Joined:
    May 13, 2014
    Posts:
    88
    arfoundation and LWR seems to have a very grainy camera feed. I was thinking it was because i didnt have the cameraoptions script attached to anything.

    When I add, the camera feed goes black. Most likely due to the LWR support using a special ar camera background texture to make this possible and autofocus not playing nice with it.