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

AR Foundation - Camera Zoom

Discussion in 'AR' started by johnymetalheadx, Aug 8, 2019.

  1. johnymetalheadx

    johnymetalheadx

    Joined:
    Feb 20, 2016
    Posts:
    12
    Hi,

    I'm working on a research project in my university.

    Is there a way to have camera zoomed in to max on my mobile device already when the unity application starts?

    Thanks in advance :)
     
    Last edited: Sep 17, 2019
  2. edee1337

    edee1337

    Joined:
    Apr 10, 2013
    Posts:
    34
    The simplest (and just about only) way to do zoom in ARFoundation would be to render the Camera output to a RenderTexture, set that RenderTexure to a RawImage in your UI, and then scaling that RawImage to 2x, 3x, whichever zoom level you wish to achieve. There is no API support for zoom (as you would in a normal camera app) or to access the tele lens if your device has one. Hope this helps!
     
  3. johnymetalheadx

    johnymetalheadx

    Joined:
    Feb 20, 2016
    Posts:
    12
    I have tried doing that and it worked but the zoomed in view is very blurry. Any work around for that?
     
  4. edee1337

    edee1337

    Joined:
    Apr 10, 2013
    Posts:
    34
    Try switching the AR Camera Options focus mode between Fixed and Auto to see which works best for your use case.

    Beyond that, the only other thing you can do is increase your RenderTexture resolution to match your camera output resolution (if you haven't already). For example, on older iPhones the camera output resolution is 1920 x 1080. On something like the iPhone X, I think it might be 2436 x 1125 or a little lower. You'll probably want to carefully monitor performance and memory at these higher resolutions.
     
    johnymetalheadx likes this.
  5. johnymetalheadx

    johnymetalheadx

    Joined:
    Feb 20, 2016
    Posts:
    12
    Worked perfectly when I matched the resolution of RenderTexture with the camera output resolution. Thanks man!
     
    edee1337 likes this.