Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice
  2. Read here for Unity's latest plans on OpenXR.
    Dismiss Notice

Multi-platform Handheld AR

Discussion in 'AR' started by jimmya, Jun 15, 2018.

  1. whogas

    whogas

    Joined:
    Oct 18, 2013
    Posts:
    46
    I am planning on using this on an upcoming project since it's in better shape than what I was throwing together to do similar things. My tests so far with it have been pretty solid. The only odd thing I've run into is that with the new post-processing layer activated, the tracking loses accuracy and wants to stick to the camera to a significant degree. I have verified this on iOS and Android. This isn't a deal-breaker, but I was hoping to apply a little post-processing too. Just thought I'd mention it as something I'd come across.

    Thanks for putting this together!
     
  2. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Thanks, I actually fixed that issue by targeting Android API level 26.
     
  3. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    604
    Probably an autocorrect fail. I meant "the ARSession component".
     
  4. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    604
    Yes, see https://docs.unity3d.com/Packages/com.unity.xr.arcore@1.0/manual/index.html#build-settings . The default is "required" which requires Android 7.0, but if you set it to optional then you can choose the minimum API level supported by Unity.
     
  5. Fingerway

    Fingerway

    Joined:
    Oct 28, 2015
    Posts:
    7
    Hi timmunity!
    can you confirm if the AR-Kit version of Foundation allow object's shadow when you instantiate it on a plane??
    or do I still have to keep using the apple AR-Kit to reflect shadows in iOS?

    thanks in advance!
     
    Last edited: Jul 12, 2018
  6. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    604
    ARFoundation doesn't do anything specific with shadows; they should work just like any other shadow caster in Unity. ARPlanes aren't special -- they are just regular Unity GameObjects with the usual suspects like MeshFilter, MeshRenderer, and MeshCollider. Each ARPlane is instantiated from a prefab which you have full control over, so you can customize it.

    Are you seeing any particular issues with shadows?
     
    rob_ice likes this.
  7. Fingerway

    Fingerway

    Joined:
    Oct 28, 2015
    Posts:
    7
    Hi Timmunity! thanks for your fast answer.
    I can put shadows on the plane, following your suggests,
    but now I see that my gameobject instantiated over the plane is very unstable (I attach a video to show you how my building is moving by himself), by the way, I make a single touch on the screen to instantiate my building.

    I'm working on Unity 2018.1.3f1 , Xcode 9.4 and iOS 11.4.1 (iPhone 6s)

    how can I resolve this ??

    thanks!
     
  8. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    604
    How are you instantiating the building asset? What is it parented to?
     
  9. Fingerway

    Fingerway

    Joined:
    Oct 28, 2015
    Posts:
    7
    I'm using your "PlaceOnPlane.cs" script, except that instead of using the "AR Placed Cube" I replaced it with my "building" prefab.
    Must my building have rigidbodies or colliders? only have mesh renders, could it be because of this?
     
  10. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    604
    That just puts the building at the scene root. The drift may be coming from poor tracking. Have you tried other environments?
     
  11. Fingerway

    Fingerway

    Joined:
    Oct 28, 2015
    Posts:
    7
    Today, I tried it in a more enlightened environment and it works very well, evidently the problem was poor tracking.
    There is nothing left to say to the user: "use well-lit environments"

    thank you very much Timm!
     
    WolfBeardedLion likes this.
  12. whogas

    whogas

    Joined:
    Oct 18, 2013
    Posts:
    46
    Is there a built-in way to interact with world-space UI elements? This works without doing anything special in just ARKit, but doesn't seem to when using AR Foundation. I am about to set up a check for raycasts that should work, but didn't know if I was missing something.

    Thanks!

    P.S. Work so far with this package has been pretty smooth and intuitive. Great work!
     
  13. YohanB

    YohanB

    Joined:
    Jun 9, 2015
    Posts:
    10
    Hello everyone. I see that there is a visualizer for both the particle and mesh for the point cloud, however I have not been able to make the mesh one work as of yet. Is the idea to create a prefab for the point cloud manager including a mesh renderer, filter, and the ARPointCloudMeshVisualizer? Is there perhaps some instance where the mesh cannot be created from the features or unsupported devices (I have Pixel and Iphone 7)? Additionally is there a reference on how the lighting parameters from the light estimation can be used in Unity scene? (perhaps specific to ARkit/ARcore)
     
  14. sam598

    sam598

    Joined:
    Sep 21, 2014
    Posts:
    59
  15. YohanB

    YohanB

    Joined:
    Jun 9, 2015
    Posts:
    10
    Hey Sam, thanks for the working script, yeah I saw that from ARkit Unity plugin before. Question in case you know: Does the light has to be an ambient light? and does this work on both implementation (Arkit and Arcore)?
     
  16. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    604
    Make sure your MeshRenderer has a material assigned. If you're using something like Default-Line, the points will be there, but they are extremely tiny and easy to miss. You probably want to use a custom shader that draws the points a bit larger. You can even use Google's point cloud material and shader.
     
  17. FG_Fronnie

    FG_Fronnie

    Joined:
    Nov 28, 2016
    Posts:
    1
    Hello Timm,
    Right now, with this version of AR Foundation, are we able to make the same AR Tank multiplayer game as you made with arcore and arkit ? I mean are we able to make any AR Multiplayer game with AR Foundation right now ?
    Thank you.
     
  18. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    604
    Yes. The multiplayer tank demo only required 6dof world tracking and plane detection, so you could recreate the tank demo in ARFoundation.

    If you're asking about the relatively new sharing features like ARCore's Cloud Anchors or ARKit's ARWorldMap, ARFoundation does not yet support those, but they are both on the roadmap.
     
    rob_ice likes this.
  19. Bitfabrikken

    Bitfabrikken

    Joined:
    Mar 24, 2013
    Posts:
    34
    Is there an official git repo for AR Foundation? It seems odd to create issues and report bugs on the arfoundation-example repo.
     
  20. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    604
    Not currently, no. We may open it up in the future, but for now, logging issues on the samples repo is fine.
     
  21. sroq

    sroq

    Joined:
    Jun 28, 2015
    Posts:
    13
    Hi Fingerway, probably that is a silly question, but how did you switch off the plane visualisation?
    Thanks



     
  22. whogas

    whogas

    Joined:
    Oct 18, 2013
    Posts:
    46
    Ran across an issue and wanted to post here in case anyone else does. I wasn't able to run an app on devices running Android 8, but it worked fine on devices running Android 7. Actually, the app worked fine until it got to the point when it needed to ask for camera permissions.

    To fix this, I had to create a custom android manifest and set tango to false. I am guessing Android 7 still accepts tango use, I'm not really sure. This seems to work, though.

    <meta-data android:name="unity.tango-enable" android:value="false" />

    I am using Unity 2018.2 if that matters. I am guessing Unity should stop setting this to true when it builds the manifest?
     
    rxmarccall and rob_ice like this.
  23. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    604
    Disable plane updates by disabling the ARPlaneManager. Then you can disable the visualization of each plane by iterating over each of the ARPlanes you get from ARPlaneManager.GetAllPlanes and disabling their GameObjects.
     
    sroq likes this.
  24. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    604
    Are you running with "ARCore Supported" checked? I don't think the "tango-enable" manifest entry should be present unless it is, and that is for Google's ARCore Unity SDK, not the ARCore XR Plugin for ARFoundation. In short, don't check that checkbox if you're using the ARCore XR Plugin package.
     
  25. zakmackraken

    zakmackraken

    Joined:
    Jun 16, 2017
    Posts:
    9
    Hi,

    I'm porting a Unity ARKit based project to AR Foundation and the Android build is crashing hard. I think it's when its about to turn on the camera background video. This is on a Samsung S8+. The iPhone build is running fine.

    I'm stumped.

    XR Settings/AR Supported is UNCHECKED per advice in this thread.

    Any idea whats going on?

    Thanks

    I/native: session_create_implementation.cc:186 ArSession_createImplementation returning OK.
    I/ArPresto: ArPresto::Session created.
    E/native: session_c_api.cc:1100 ArAugmentedImageDatabase_deserialize: database_raw_bytes was passed NULL.
    E/ArPresto: ArPresto::SetConfiguration failed to deserialize Augmented Image database with status -1.
    I/native: session.cc:417 Entering Session::Resume.
    V/third_party/redwood/base/jni_common/jni_helper.cc: JniHelper: about to attach thread. (Called from line 44.)
    JniHelper: thread already attached. (Called from line 44.)
    ~JniHelper: did not need to detach thread. (Called from line 44.)
    I/native: android_camera.cc:1083 Initializing camera manager.
    D/VendorTagDescriptor: addVendorDescriptor: vendor tag id 3854507339 added
    I/native: android_camera.cc:1099 Camera manager initialized successfully with 2 cameras.
    android_sensors.cc:94 Starting thread.
    V/Surface: sf_framedrop debug : 0x4f4c, game : false, logging : 0
    E/NdkImageReader: AImageReader_getWindow
    I/native: android_sensors.cc:140 Gyro min delay 2ms requesting 5ms
    V/Surface: sf_framedrop debug : 0x4f4c, game : false, logging : 0
    I/native: android_sensors.cc:157 Accel min delay 2ms requesting 5ms
    I/native: cameras.cc:715 Camera changed state from 0 to 1: Camera device opened succesfully.
    I/native: session.cc:494 Session::Resume returning OK.
    I/native: cameras.cc:715 Camera changed state from 1 to 2: Capture session starting...
    I/ArPresto: ArPresto::Moving from ArPrestoStatus 102 to 101.
    I/native: cameras.cc:715 Camera changed state from 2 to 3: Capture session started streaming.
    E/CRASH: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr b206b2ac
    *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    Build fingerprint: 'samsung/dream2ltexx/dream2lte:8.0.0/R16NW/G955FXXU2CRF7:user/release-keys'
    Revision: '10'
    pid: 14110, tid: 14156, name: UnityMain >>> com.zak.viewer2 <<<
    r0 b206b280 r1 ca06b280 r2 00000000 r3 000005a0
    r4 c3316914 r5 00000b90 r6 00000000 r7 bb471cc8
    r8 e0b3f210 r9 000005a0 sl 3f800000 fp 00000001
    ip 00000b90 sp c83757e8 lr c97f8548 pc c908ab08 cpsr ec2a8c90
    backtrace:
    I/native: timebase_helpers.cc:167 Timebase offset intialized to 0
    I/native: arcore_feature_extractor_wrapper.cc:29 Extracting features using ArcoreFeatureExtractorWrapper.
    arcore_feature_extractor_wrapper.cc:48 Narrow camera model.
    I/native: distribute.cc:92 No keypoints to prune.
    W/native: gyro_helper.cc:59 Gyro samples do not cover << [ 0 ; 15885.2482859409993 ] sec. Use identity R. Gyro samples cover [ 15885.1101502150013 ; 15885.3562550970018 ] sec.
    W/native: feature_processing.cc:152 Skipping first feature measurement because we don't have a previous to diff against.
    I/native: vio_initializer.cc:635 Not accepting frame as first BA keyframe.
    I/native: distribute.cc:92 No keypoints to prune.
    I/native: vio_initializer.cc:635 Not accepting frame as first BA keyframe.
    E/CRASH: #00 pc 00b89b08 /data/app/com.zak.viewer2-4KD5YwbBwJUkRUScn8dzYg==/lib/arm/libunity.so (IsCompressedFormat(GraphicsFormat)+16)
    #01 pc 012f7544 /data/app/com.zak.viewer2-4KD5YwbBwJUkRUScn8dzYg==/lib/arm/libunity.so (ApiGLES::CreateTexture(unsigned int, unsigned int, GraphicsFormat, int, int, int, int, int)+504)
    #02 pc 00ac3a08 /data/app/com.zak.viewer2-4KD5YwbBwJUkRUScn8dzYg==/lib/arm/libunity.so (gles::InitRenderSurfaceGLES(ApiGLES*, RenderSurfaceGLES&, TextureColorSpace)+664)
    #03 pc 00aa72f0 /data/app/com.zak.viewer2-4KD5YwbBwJUkRUScn8dzYg==/lib/arm/libunity.so (GfxDeviceGLES::CreateColorRenderSurfacePlatform(RenderSurfaceBase*, RenderTextureFormat)+212)
    #04 pc 00a656d0 /data/app/com.zak.viewer2-4KD5YwbBwJUkRUScn8dzYg==/lib/arm/libunity.so (GfxDevice::CreateRenderColorSurface(TextureID, int, int, int, int, TextureDimension, RenderTextureFormat, SurfaceCreateFlags)+144)
    #05 pc 00bd5698 /data/app/com.zak.viewer2-4KD5YwbBwJUkRUScn8dzYg==/lib/arm/libunity.so (RenderTexture::Create(ObjectHandle<RenderSurface_Tag, RenderSurfaceBase*> const&, ObjectHandle<RenderSurface_Tag, RenderSurfaceBase*> const&, RenderTexture::CreateFlags)+1268)
    #06 pc 00bce4bc /data/app/com.zak.viewer2-4KD5YwbBwJUkRUScn8dzYg==/lib/arm/libunity.so (RenderBufferManager::Textures::GetTempBuffer(RenderTextureDesc)+872)
    #07 pc 00be96c8 /data/app/com.zak.viewer2-4KD5YwbBwJUkRUScn8dzYg==/lib/arm/libunity.so (StereoRenderTexture::AllocateTemp(RenderTextureDesc&)+280)
    #08 pc 0077d6c8 /data/app/com.zak.viewer2-4KD5YwbBwJUkRUScn8dzYg==/lib/arm/libunity.so (CameraStackRenderingState::GetTargetTexture()+248)
    #09 pc 0077a43c /data/app/com.zak.viewer2-4KD5YwbBwJUkRUScn8dzYg==/lib/arm/libunity.so (Camera::CustomRender(CullResults&, ShaderPassContext&, CameraRenderingParams const*, Camera::RenderFlag, Camera::performRenderFunction*, void (*)())+1616)
    #10 pc 0077bacc /data/app/com.zak.viewer2-4KD5YwbBwJUkRUScn8dzYg==/lib/arm/libunity.so (Camera::Render(CullResults&, ShaderPassContext&, Camera::RenderFlag, void (*)())+136)
    #11 pc 007d7e14 /data/app/com.zak.viewer2-4KD5YwbBwJUkRUScn8dzYg==/lib/arm/libunity.so (RenderManager::RenderCameras(int, void (*)())+652)
    #12 pc 00d9846c /data/app/com.zak.viewer2-4KD5YwbBwJUkRUScn8dzYg==/lib/arm/libunity.so (PlayerRender(bool)+380)
    #13 pc 00d99b9c /data/app/com.zak.viewer2-4KD5YwbBwJUkRUScn8dzYg==/lib/arm/libunity.so (InitPlayerLoopCallbacks()::postLateUpdateFinishFrameRenderingRegistrator::Forward()+72)
    #14 pc 00d9b0a4 /data/app/com.zak.viewer2-4KD5YwbBwJUkRUScn8dzYg==/lib/arm/libunity.so (ExecutePlayerLoop(NativePlayerLoopSystem*)+96)
    #15 pc 00d9b0f4 /data/app/com.zak.viewer2-4KD5YwbBwJUkRUScn8dzYg==/lib/arm/libunity.so (ExecutePlayerLoop(NativePlayerLoopSystem*)+176)
    #16 pc 00d9b29c /data/app/com.zak.viewer2-4KD5YwbBwJUkRUScn8dzYg==/lib/arm/libunity.so (PlayerLoop()+284)
    E/CRASH: #17 pc 0061b1f0 /data/app/com.zak.viewer2-4KD5YwbBwJUkRUScn8dzYg==/lib/arm/libunity.so (UnityPlayerLoop()+572)
    #18 pc 0061e934 /data/app/com.zak.viewer2-4KD5YwbBwJUkRUScn8dzYg==/lib/arm/libunity.so (nativeRender(_JNIEnv*, _jobject*)+52)
    #19 pc 000064e3 /data/app/com.zak.viewer2-4KD5YwbBwJUkRUScn8dzYg==/oat/arm/base.odex (oatexec+4294878435)
     
  26. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    604
    The callstack doesn't look like something related to `ARFoundation`. Are there any other components on the camera or that affect the camera being used by the ARCameraBackground?
     
  27. zakmackraken

    zakmackraken

    Joined:
    Jun 16, 2017
    Posts:
    9
    Thanks Tim, Camera setup is attached.
     

    Attached Files:

  28. whogas

    whogas

    Joined:
    Oct 18, 2013
    Posts:
    46
    Sure enough, I was. That is a bit confusing, but thanks for clearing it up!
     
  29. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    604
    The crash happens while trying to create a texture; have you tried disabling the Post Processing Behaviour? Does that make any difference?
     
  30. whogas

    whogas

    Joined:
    Oct 18, 2013
    Posts:
    46
    Is there a built-in way to darken (or otherwise adjust) the camera feed's image? I have done this before with ARKit by modifying the rendering shader, but didn't know if there was an easier way with AR Foundation before I do something similar again with an override material on the AR Camera Background.
     
  31. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    604
    To do that without modifying the shader, you'd need to recreate and customize most of the ARCameraBackground and ARBackgroundRenderer (which is built-in). Using a custom material sounds like the easier path.
     
    whogas likes this.
  32. whogas

    whogas

    Joined:
    Oct 18, 2013
    Posts:
    46
    Is there a location where we can see a roadmap or something similar for updates to the AR Foundation? I was wondering about when ARKit 2.0 features might be rolled in.
     
  33. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    604
    Our plan is to have full feature parity with ARKit 2.0 and ARCore 1.3 by the end of the year.
     
    rob_ice, Saicopate and whogas like this.
  34. Ghus86

    Ghus86

    Joined:
    Oct 24, 2013
    Posts:
    15
    Hi

    I have search but didn't find it , is there a way of only detecting the horizontal plane ?

    Thanks in advance
     
  35. JelmerV

    JelmerV

    Joined:
    Nov 29, 2012
    Posts:
    238
    EDIT: Solved: Had to use Mono instead of IL2CCP.

    I switched from iOS to Android and now the background remains black and there’s no request to access the camera.
    ARCore package is added
    The app requested that ARCore be downloaded on the phone
    But after installation it’s not working.

    This is my setup, running with IL2CPP on a Samsung S8.
    Screen Shot 2018-10-28 at 21.00.07.png
     
    Last edited: Oct 29, 2018
  36. pankao

    pankao

    Joined:
    Feb 18, 2013
    Posts:
    8
    I dont think there is a way to restrict the plane manager to detect only planes of specific orientation/alignment.
    But you can always subscibe for ARPlaneManager, XRPlaneSubsystem or ARSubsystemManager's OnPlaneAdded events in order to be able to determine what kind op plane was currently detected. When the added plane's alignment is what you want, you can procces it further - otherwise skip. Is that feasible for you?
     
  37. pankao

    pankao

    Joined:
    Feb 18, 2013
    Posts:
    8
    Hi everybody!
    Firstly, I want to thank for the extensive work of the ARFoundation dev team and community, great stuff happening;)
    To get to my point - I just wonder if there is a way to explicitly remove trackables, particularly planes and pointclouds, from current AR session / related managers. I need to manually clean up the session as there is obviously an issue with repeatedly resetting the session using the ASSession.Reset() or by destroying and recreating it. I seems to work just once or twice but any consequent attempts result in app han / crash. So i was thinking i would just remove all the trackables manually but when I do so by just destroying their respective GOs, the session obviously still keeps record of the former trackables and complains when it tries to add a new trackable with already existing ID (selected key exists in Dictionary blablabla..).
    The only trackable type I am able to remove properly is ARReferencePoint, as ARReferencePointManager / XRReferencePointSubsystem exposes public method to do that.
     
    Last edited: Oct 31, 2018
  38. Mooshoo-Labs

    Mooshoo-Labs

    Joined:
    Aug 21, 2014
    Posts:
    19
    Hi,

    I'm having the exact same issue as Fingerway, with my instantiated gameobject drifting. This is happening often, in all conditions. Right after instantiating my gameobject, I disable my ARPlaneManager and ARCloudManager, as well as the renderers on my existing planes. Is there a way of stopping from generating new planes while still tracking properly? When my AR managers are enabled, I do not see the surfaces drifting away.

    Thanks,
    Chai
     
  39. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
    Mooshoo-Labs likes this.
  40. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    Wait a minute. Does AR foundation only work with Mono? I need IL2CCP. Any word from Unity on this?
     
  41. Srokaaa

    Srokaaa

    Joined:
    Sep 18, 2018
    Posts:
    160
  42. tammudo

    tammudo

    Joined:
    Oct 2, 2017
    Posts:
    4
    Did this method "GetAllPlanes" change recently? I keep getting this message: 'ARPlaneManager' does not contain a definition for 'GetAllPlanes' and no accessible extension method 'GetAllPlanes' accepting a first argument of type 'ARPlaneManager' could be found
     
unityunity