Search Unity

AR Foundation - Manually create a plane

Discussion in 'AR' started by mb13admin, Sep 30, 2019.

  1. mb13admin

    mb13admin

    Joined:
    May 28, 2017
    Posts:
    22
    Hi all, my team is currently working with ARF 3.0.0preview2.
    Our project is to detect an image then draw an AR model above that detected image, but we want to extend it more by using plane detection along with image tracking.

    For example, if the device loses track of the image, it still draws the model above a detected plane immediately.
    We have successfully merged those 2 features into one scene and it works really well on iOS. However, on Android, the plane detection is much slower.

    We are trying to find a way to create a 'fake' AR plane at where the augmented image is detected to trick the device to think that image is also a plane. By doing that, we won't have to worry about losing track of the image.

    In conclusion, can I manually create an AR plane and add it into ARPlaneManager?

    Thank you.
     
  2. danUnity

    danUnity

    Joined:
    Apr 28, 2015
    Posts:
    229
    I'm asking myself the same question! Did you ever figured it out?
     
  3. FrankvHoof

    FrankvHoof

    Joined:
    Nov 3, 2014
    Posts:
    258
    @danUnity Unity still doesn't have a great way to debug AR Foundation.
    Your best bet right now is Kyrylo Kuzyk's AR Foundation Remote https://assetstore.unity.com/packages/tools/utilities/ar-foundation-editor-remote-168773

    I'm also personally working on a way to debug within the editor itself (No device needed).
    The project is currently in (closed) bèta, but I'm hoping to announce a release for it in the next few weeks.

    If you're just looking to manually create a tracked pose, use ARAnchors instead
    https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@3.0/manual/anchor-manager.html
     
    KyryloKuzyk likes this.
  4. tree_arb

    tree_arb

    Joined:
    Dec 30, 2019
    Posts:
    323
    Using Android (hobby level) i sort of came to the same conclusion. If a wall has no points to get a plane, you pretty much have to put something there.

    So bring a cardboard poster or something somewhere, detect that wall, then you can add an invisible regular plane to it and interact with that. doesn't need to be an AR plane or anything special. And doesn't have to be image recognition, just a thing you know to pickup the plane well. Detect wall, Add fake plane, disable plane detection, remove physical temp picture, do interaction.

    Not ideal but thats what i came up with for a hobby project. So this requires user initialization.

    Until lidar is everywhere i think we're just a but limited. My android cant even pick up vinyl siding as a plane by itself
     
  5. danUnity

    danUnity

    Joined:
    Apr 28, 2015
    Posts:
    229
    @FrankvHoof Ah well the reason I'm asking is not to debug in the editor but to create an AR plane based on the planes found by the AR Plane Manager. The reason is because I want a giant floor always available during the experience even when the user haven't even started to scan the room. When the user starts scanning the room, I would adjust the height of that giant plane up and down to match the real floor!

    Right now I'm using creating ARanchors on the ARplanes that are found and then I'm adding my objects underneath those anchors. The ARplanes have a shadow material but even that doesn't work since the shadow gets cutoff or duplicated on multiple ARplanes as the user starts to scan the room.
     
  6. FrankvHoof

    FrankvHoof

    Joined:
    Nov 3, 2014
    Posts:
    258
    "to create an AR plane based on the planes found by the AR Plane Manager"
    Those are created by the AR Plane Manager.
    Did you mean you just want to add a Plane (I.e. Instantiate a GameObject)?
    "The ARplanes have a shadow material but even that doesn't work since the shadow gets cutoff or duplicated on multiple ARplanes as the user starts to scan the room."
    Is the shadow being added by yourself? This sounds like an Intstancing-issue
     
  7. tree_arb

    tree_arb

    Joined:
    Dec 30, 2019
    Posts:
    323
    I originally replied specific to walls which are a bit trickier, but I do exactly what you describe for infinite floor.

    App starts w a 3d model or fill on the plane detection. Once the user scans enough or accepts the placement, i put a prefab invisible plane with shadow shader in that location. All game/physics are pretty much just normal use now on the normal plane. And scanning / ar plane detection is turned off.

    I can post the shadow shader if you want. I think i got it from an old AR example somewhere.
     
  8. danUnity

    danUnity

    Joined:
    Apr 28, 2015
    Posts:
    229
    I'm aware that the ARPlane Manager is the one in charge of the ARplanes and that it adds, removes, and modifies it's ARplanes.

    The shadow issue arises since the ARPlane Manager generates planes on the fly at different heights sometimes or that the planes are not taking the entire space so the shadow just stops in the middle of the room. Unless you have scanned your room a lot, you'll get issues with the shadows.

    The issue is a little bit more tricky than just instantiating a large plane since now that dummy plane lives outside of the ARFoundation environment:

    -Which means that we can't use the ARRaycastManager for example since that only works on Trackables. We can use a regular Raycast in that case but that's just masking the next problem.

    -We now can't attach ARanchors to that dummy plane. (https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.1/manual/anchor-manager.html)

    I'm sure there are other issues that arise from instantiating a dummy plane like that.

    Having an infinite plane like that is definitely super important since I don't want to wait for the user to scan the room before allowing them to use my app.

    The ARPlane Manager should have a function to add an existing component ARPlane to it's list and everything would work.