6DoF Smartphone VR-
step-by-step

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 3D project.

With Unity 2019:

You shoud install two packages: Multiplayer HLAPI and Legacy Input Helper from Window>Package manager

Download ARCore SDK for Unity

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

Import ARcore package in Unity


  • On unity windows, go on the menu Assets> Import Package> Custom Package and import the package you dowladed at the previous step

Set the scene of your application


  • In the project tab, goes in GoogleARCore folder>Prefabs

  • Drag and drop the “ARCore Device” prefab in your scene

  • Delete the Main Camera and Directional light of your scene

  • Save the scene

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 :

  • Include and check the scene you want in your application in "Scenes In Build"

  • Switch Plateform to Android if necessary

In Player settings (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, and add Cardboard

Generate your application

  • In the popup File>Build settings


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

  • Build you application and load it on your smartphone

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.

  • Generate your application, you can visit the virtual environment.

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