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

Resolved ARKit support for iOS via Unity-ARKit-Plugin

Discussion in 'AR' started by jimmya, Jun 5, 2017.

Thread Status:
Not open for further replies.
  1. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    As of right now you can only pause the session and re-run it. On the native code side, that is essentially how you would stop a session. But we haven't implemented that at the moment.
     
  2. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    You must call the pause method of ARSession.
     
  3. CManzione

    CManzione

    Joined:
    May 11, 2015
    Posts:
    7
    My XCode was Version 9 Beta3. Which was working just fine and was what was recommended in other posts. I updated to Version 9 Beta 5 and it all works now. thanks!!!
     
  4. Infrid

    Infrid

    Joined:
    Jan 14, 2012
    Posts:
    67
    Hey guys, perhaps this was covered in one of the pages between 1 and 24; but seeing as this is a remote tool, which runs via connection to the device, is it possible to build the unity remote on my crappy mac mini, then do the iterative development on my (kick arse powerful) pc?

    Got my fingers and toes crossed here!
     
  5. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    Try it out, I think it should work. If it doesn't, let us know and we can try to figure it out.
     
    KwahuNashoba likes this.
  6. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    The size of the car should be it's size in real life if that's the effect you are going for. ARKit and Unity use a scale of 1 unit = 1 meter. So if you are modeling your car, keep that in mind. I'm not sure what you mean by "size estimation" when you say it. ARKit doesn't do size estimation, neither does unity. Can you elaborate?
     
  7. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    I am trying to modify the MobileARShadow shader to encompass the behavior of DepthMask for the wiki. The DepthMask does not seem to be working anymore. Any suggestion for how this would be done?
     
  8. victortang

    victortang

    Joined:
    Apr 5, 2017
    Posts:
    1
    Is it possible to save a built scene and load it again at a different time with the exact placement of objects?
     
    AxelMG likes this.
  9. Bird_LYKKE

    Bird_LYKKE

    Joined:
    Jul 26, 2017
    Posts:
    15
    Sorry for my unclear question but ARcamera in unity seem to be low quality than native camera app.
     
  10. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    Yes, this is because we are told to scale the texture to fit the aspect ratio (by Apple and the ARKit team) of the device in order to get the right perspective for ARKit and the video that is rendered. Again, I can't stress enough, to please search in the forums for your questions before asking. This question has been answered many times already.
     
  11. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    Why would that have any effect on the quality? I searched this whole thread and found nothing on the topic.
     
  12. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    Here are three instances on the topic.
    #1135
    #723
    #714

    The reason it can affect quality is that sometimes the camera aspect ratio differs vastly from the device aspect ratio, so we scale the texture up significantly which can cause the quality to appear less than that of, say the video app.
     
  13. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    Then that would be true for the Camera app as well. I’ll bet Apple lowers the resolution on purpose to speed up processing.
     
  14. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    There is no reason to do it for the camera app because there are no virtual objects that need to be perspectively correct when rendered. Therefore you can render the texture at full resolution in the camera app to get a better idea of how your picture will look vs. how virtual objects look.

    In either case, you can decide to believe me or not. But the truth is that we scale up the texture in the ARKit case. I don't know what they do in the camera app since I haven't seen the source.
     
  15. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    ARKit has certain restrictions in regards to camera parameters, and resolution is one of them. It’s just the way ARKit was designed.
     
  16. LabanTwissel

    LabanTwissel

    Joined:
    Aug 17, 2017
    Posts:
    4
    Hi Christopher,
    I am building a FPS but my gun which is a child of my main camera is set behind the plane and therefore the 3d model that I have set on it. How could I fix that? Thanks in advance! IMG_2052.PNG
     
  17. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    Hey,
    Can you post a screen shot of your hierarchy? I'm having trouble understanding what you mean. The only guess I have is that maybe you are putting your gun on a layer that is rendered before the other objects in the scene, but after the video? Let me know.
    Cheers,
    Chris
     
  18. Vakyla

    Vakyla

    Joined:
    Nov 14, 2016
    Posts:
    1
    Having the same issue, does any one know how to fix this?
     
  19. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    if you read further along you will see:
    to which i replied:
     
  20. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,734
    @christophergoy

    Made some test and it works good so far.
    I am cleaning up a bit more to confirm 100% it works....

    I first had some difficult to understand the hierarchy... name wasn't really clear to me.
    Finally I came up with something that could make more sense to the user knowing there is a hierarchy for Tracking (only) and another one for Rendering (only).

    Attached a pic with my hierarchy name, below the Before // After

    = BEFORE =

    Screen Shot 2017-08-17 at 16.45.22.png

    = AFTER =

    Screen Shot 2017-08-17 at 16.42.43.png

    One more time thank you!! ^__^
     
    christophergoy likes this.
  21. John1515

    John1515

    Joined:
    Nov 29, 2012
    Posts:
    248
    I am not sure how ARKit determines the size its environment, but as it does not have a depth factor, I suppose it relies on camera focus and/or the combination of visual object tracking and its gyroscope. Though we have seen very precise results between the virtual scene size and real size here:
    I do wonder how well the virtual size and real size matches if you start your "setup" with the ground, say, 2 meters aways from the camera.
    I will however double check the size of my scene. But still wonder about how ARkit determines how big stuff is in real life.
     
  22. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    I’ll change the names in the branch, thanks for the feedback.
    Cheers,
    Chris
     
    sama-van likes this.
  23. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    ARKit’s coordinate system is the same scale as Unity’s. 1 unit = 1 meter. The computer vision algorithm assumes that the things in the camera feed are of this scale and creates planes of the appropriate size.
     
    John1515 likes this.
  24. LabanTwissel

    LabanTwissel

    Joined:
    Aug 17, 2017
    Posts:
    4
    Thanks Chris for answering, here is a screenshot of my hierarchy.
     

    Attached Files:

  25. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    I think since your gun is patented to the camera, it’s being rendered along with the video which is why it’s showing up underneath everything. Any chance you could send me your project so I can tweak it a bit?
     
  26. PdrMnts

    PdrMnts

    Joined:
    Dec 12, 2016
    Posts:
    13
    One question, If I use the "Hit Test Example" script to place objects manually, Is it mandatory to use the "Unity AR Generate Plane" script also?? Does it works better ??
     
  27. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,734
    I give up for today! T_T!//
    Getting a bunch of new errors from Xcode since I work from the Scaled-content-test...
    To tell the truth I didn't update for a week or so the unity ARKIT sources then it was just fine until now...

    Any idea? >_>

    Screen Shot 2017-08-18 at 1.54.12.png
     
  28. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    You need Xcode beta 5 or later.
     
    sama-van likes this.
  29. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    The generate planes script is mostly for debug purposes, in that it creates game objects for planes. This can also be used to have physics surfaces with colliders if you want them. That is all unity specific. But if you just use the ARKit hit test API on it's own, it will work fine with, or without the plane generator script
     
  30. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    Does the ARKit Hit Testing only hit against the generated planes or anything on the camera?
     
  31. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    If you take a look at the HitTestExample it's doing a tiered hit test where it tries to hit an existing plane, an estimated (one frame) based on feature points plane, and then feature points. Existing planes are the most accurate, estimated planes less accurate, and feature points least accurate.
     
    User340 likes this.
  32. LabanTwissel

    LabanTwissel

    Joined:
    Aug 17, 2017
    Posts:
    4
  33. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
  34. PdrMnts

    PdrMnts

    Joined:
    Dec 12, 2016
    Posts:
    13
    What is the best way to restart the generation of planes? or restart the session?
     
  35. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    Code (CSharp):
    1. GetARSessionNativeInterface().RunWithConfigAndOptions(arSessionConfig, UnityARSessionRunOption.ARSessionRunOptionResetTracking);
    You will have to clear the list of planes in the ARAnchorManager as well.
     
  36. jessevan

    jessevan

    Joined:
    Jan 3, 2017
    Posts:
    35
    I'm waiting to hear back from them regarding a related issue. After resuming a paused session, the scene no longer appears to respect compass heading. Have you experienced this?
     
  37. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    Hey,
    I'm not sure what ARKit is doing under the covers, but you could ask on the apple developer forums in order to know if this is expected behavior or not. It sounds like it might be, but you should ask them to make sure.
     
  38. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    Just talked to someone from Apple, it's considered undefined behavior to pause and then assume that the compass heading will still be respected. You might need to reset the tracking data and re-run the session
     
  39. Elliott-Mitchell

    Elliott-Mitchell

    Joined:
    Oct 8, 2015
    Posts:
    88
    Related to this thread: I was trying to offset a 3d object in space to make it look correct on the iPad Pro with the video scaling happening (it's not anchored to anything). Aesthetically speaking, the actual scale of the video makes no difference in this case. The offsetting in space method worked to an extent; the issue then became one of clipping. The 3D assets clipped out much sooner than I would have expected. Altering AR camera clipping planes didn't help.

    Wondering what to do here? I've read through a ton of posts and see no solution. FWIW, this culling effect happened to different objects at different distances from the camera. Is unity rendering video onto some sort of skybox? if so, can that skybox be made larger? Or does it have to do with the ARCameraShader?

    -Elliott
     
  40. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    I’m surprised that modifying the far clipping plane didn’t help. Are you using any occlusion shaders or geometry? How much did you modify your near/far clipping planes?
     
  41. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,734
    @christophergoy @jimmya
    Please could you keep the 1st message of this thread up to date with last requirements?
    Current should be :
    - xcode beta 9.5
    - iOS beta 11.5 ?

    I am not even sure in view of all issue and recent updates.
    Updated both mac I work with but on one mac the ar remote is not sending back to Editor anymore (Editor > remote only is working)

    EDIT :
    I confirm the last build from GIT works perfectly (and better than before) with the following setup :

    - Unity 2017.1.0f3
    - Xcode 9b5
    - iOS 11b6
     
    Last edited: Aug 21, 2017
    jimmya likes this.
  42. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    Hmm, good idea. I’ll talk to Jimmy as I can’t edit his posts. Thanks for the feedback! It’s very useful.
     
    DerekLerner likes this.
  43. zorostar

    zorostar

    Joined:
    Aug 18, 2017
    Posts:
    1
    Hello,
    Does it possible to write a ARkit-Plugin for lower unity version? Does lower unity version support the ios ARKit framework, I mean i want to implement a AR project with unity 5.3.8 and ios ARKit, Is it possible?
    Thanks.
     
  44. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    Any reason you want to use a lower version of Unity?
     
    Last edited: Aug 18, 2017
  45. arturmandas

    arturmandas

    Joined:
    Sep 29, 2012
    Posts:
    240
    We are experiencing ARkit to behave undeterministically - sometimes it works, sometimes doesn't, all with "by-the-book" setup. Any clue?
     
  46. PdrMnts

    PdrMnts

    Joined:
    Dec 12, 2016
    Posts:
    13
    One question Christopher, if I want to use only the "hit test example" script when one plane is generated, What do you recommend me? Should I use only ARHitTestResultType.ARHitTestResultTypeExistingPlane and removed ARHitTestResultType.ARHitTestResultTypeFeaturePoint in resultTypes?

    Because I noticed that until one plane is detected the position of the Object using the HITTESTEXAMPLE script is not very accurate.

    Tx
     
  47. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    If you just want to detect just against planes then remove the FeaturePoint hit type yes. ExistingPlane will detect against infinite planes (there are no bounds) and ExistingPlaneWithExtents will detect against planes that have a boundary, i.e. ARKit has tried to match the planes bounds to the surface your looking at.
     
    jimmya likes this.
  48. Carpet_Head

    Carpet_Head

    Joined:
    Nov 27, 2014
    Posts:
    256
    I tried importing this plugin but it was a huge pain. Please can you use a namespace so that it does not clash with our existing codebase? For example "ColorPicker" is not a very unique name
     
    Last edited: Aug 18, 2017
  49. MSFX

    MSFX

    Joined:
    Sep 3, 2009
    Posts:
    116
    generally found tracking to be pretty solid unless in a crowded area... what's your lighting like, low lighting will throw it off quite alot? Is your device at least min spec?
     
    jimmya likes this.
  50. MSFX

    MSFX

    Joined:
    Sep 3, 2009
    Posts:
    116
    Are we still unable to move the CameraParent object? I have a huge environment that I really would love to not have to move and recalculate (physics, navmesh etc)... why can't the plane generation / tracking be relative to a parent object rather than world space Chris / Jimmya?
     
    petey likes this.
Thread Status:
Not open for further replies.