6DoF Smartphone VR-
All the steps

Introduction

What is 6Dof?

6DoF stands for "Six Degrees of Freedom". With Google Cardboard, or most of smartphone VR applications, you can just turn the head up and down, left and right, or tilt your head around the axe of your nose: it changes the visual and audio feedback. Here, we have three degrees of freedom. Most of the time, you cannot walk front and backward, left and right, or up and down (three other degrees of freedom). The idea of this tutorial is to create an application with six degrees of freedom: the three axes of rotation (head orientation), and the three axes of translation (moving) in a smartphone VR application type Cardboard.

How to do 6DoF VR with a smartphone?

  • To create a VR smartphone application with 6 degree of freedom, you can enable 6Dof in a small area with Google Daydream: https://developers.google.com/vr/develop/unity/3dof-to-6dof

  • However, if you want to use 6DoF within an virtually unlimited space, or with Google Cardboard, you can use this hacking technique: combine it with ARCore tracking. We describe how to do that in this tutorial. You can use this as a starting point as well with your own rendering: 1) apply your rendering to the ARCore Camera OR 2) re-use the ARCore camera transform (position and rotation) for your own custom camera.

Why?

This technique is incredibly convenient to do research on VR remolty. You just need a compatible smartphone and a smartphone VR headset for the stereoscopic view ( /!\ to work with this technique, you need to ensure the smartphone camera is not hidden).

Requirements


Other:

Official quick starting guide for ARCore: https://developers.google.com/ar/develop/unity/quickstart-android

Table of contents

Starting the Project

Create a new project

Lauch Unity and create a new project.

Set this project as a 3D project, and enter the name of the project in your computer.

With Unity 2019:

You shoud install two packages: Multiplayer HLAPI and XR Legacy Input Helper

(only Unity 2019)

  • Click on the following menu: Window>Package manager

(only Unity 2019)

  • On the Packages pop-up, scroll down on the left menu to select “Multiplayer HLAPI” and clic on “Install”


(only Unity 2019)

  • The installation starts and ends (indicated by the button “Up to date” and “Remove” at the bottom right of the pop-up.


(only Unity 2019)

Follow the same procedure for "XR Legacy Input Helper" package.

  • Scroll down on the left menu to select “XR Legacy Input Helper” and clic on “Install”

  • The installation starts and ends (indicated by the button “Up to date” and “Remove” at the bottom right of the pop-up.


  • Close the pop-up “Packages” by clicking on the cross at the top right corner



Download ARCore SDK for Unity

  • Scroll down and click on the file unitypackage called arcore-unity-sdk.

  • Here I downloaded the arcore-unity-sdk-1.18.0.unitypackage

  • Download the file and save the file on your computer

Import ARcore package in Unity


  • On unity windows, go on the menu Assets> Import Package> Custom Package

  • On the pop-up window, select the file unitypackage arcore-unity-sdk you downloaded at the previous step (I downloaded the arcore-unity-sdk-1.18.0.unitypackage ) and clic on “Open” at the bottom right

  • Wait for the package preparation

  • On the pop-up “Import Unity Package”, import all the content of the package and wait the end of the importation of the package .

Set the scene of your application


  • In the project tab in unity, goes in GoogleARCore folder, and select the folder “Prefabs”

  • Drag and drop the “ARCore Device” prefab in the Hierarchy table.

  • Now this prefab is in your scene

  • Delete in hierarchy tab the prefab Main Camera and Directional light by clicking on it then using “Delete” key of your keyboard

  • Save the scene (Menu File>Save), enter a name (I entered 6Dof) then clic on save

If you deploy (with the triangle on the right of the name) the prefab “ARCore Device” on your scene, there is a First Person Camera. The position of this camera (called as well transform.position) is the computed position of the smartphone on the space. We will use that to compute the position of the user smartphone.

Configure for use with smartphone with ARCore and stereoscopic view

  • Go in File > Build Settings


In the pop-up Build Settings :

  • (top) Click on "Add Open Scenes" and verify that the scene you want to include in your application is in "Scenes In Build" and checked

  • Click on Android (left menu) then click on Switch Plateform (bottom right). The process may take some minutes

  • (bottom left) click on Player settings

  • On this new popup, switch to android tab

  • In rendering: be sure to UNcheck Auto Graphics API.

  • Remove Vulkan *if* is listed under Graphics APIs


  • Modify the name package, or it will not work on an android smartphone.

You need a different name each time you want to create a new application

  • On minimum API level, select Android 7.0 Nougat or higher

  • In the category “XR Settings”, check the box “ARCore Supported”

  • Check “Virtual Reality supported" as well

  • Click on the “+” and add “Cardboard”

  • Close the pop-up

Generate your application

  • In the popup File>Build settings


  • Verified you have switch to Android and that your scene is selected

  • Click on "Build and Run" to generate the apk file and install it directly on the smartphone linked with usb to your computer.

Launch your app, and use it with a smartphone VR headset that does not hide the back camera of your smartphone.


Navigate in a Virtual Environment

  • Now, you can add your scene and navigate on it, for instance a cube and a sphere

  • Another option:yYou can import an existing scene, for instance “Furnished Cabine” from the Assets Store.

  • When you generate your application (be sure to include and select your scene in “Scene In Build”), you can visit the virtual environment.


Thank you for following this tutorial, please reference this page if you use it ;D