UE4 VR Tutorial: How to Deploy UE4 to Oculus Go
Setup and Deploy a UE4 project to the Oculus Go.
In this tutorial, we’ll walk through all of the steps necessary to setup and deploy a simple stereoscopic UE4 project to the Oculus Go. The goal of this video is to help developers quickly jump into the UE4 to Oculus Go pipeline with a working example which they can then tweak to suit their specific needs.
Hello, this is Ian from Elara and this tutorial will focus on deploying to the Oculus Go VR headset from UE4. I’ll move quickly, so pause early and often. For this tutorial you’ll need an Oculus Go, a Windows 64-bit computer, a private Wi-Fi network, and a mobile device capable of installing the companion Oculus App.
To start you’ll need a recent version of UE4. I’ll dive into the Epic Games Launcher and download 4.19.
Oculus Go is an Android device, so navigate to your engine’s Extras Directory and run the Android Works installer to install all of the prerequisites.
Keep the default settings and add API 21. This version is the minimum version that Oculus accepts on the online store. Android Works also installs the Android Debug Bridge, ADB for short, which allows us to deploy to the Go via USB.
Unselect NSight Tegra if prompted.
You’ll need to accept the Terms and Conditions in order to continue.
Once the download is complete you’ll need to restart your computer. In the meantime, grab the mobile device you intend to pair with the Oculus Go. Install the Oculus App from your App store and follow the initial device setup if you haven’t already. Then enable developer mode in the “More Settings” panel of your paired Go headset.
Connect your Go to your PC via the USB cable. And open a command prompt window. Type “adb device” and hit ENTER. If this is your first time running adb, your headset will probably show as unrecognized. Solve this by holding the headset up to your face while it is still USB connected. A window should appear, prompting you to Allow USB debugging, check the checkbox and hit OK. Then run “adb devices” on your computer once more. The headset will now be recognized.
Now we’ll set up a simple UE4 project to deploy to the Go.
Start by saving the map and opening your project settings.
We have quite a few settings to tweak in order to deploy to the Go. Start off by giving your project a name and Enabling “Start in VR”.
We’ll want our project to default to the Main map, so update the default maps in the Maps and Modes section.
The Go has no touch screen, so remove the Default Touch Interface in the Input section.
In the Rendering section, enable Multi-sample Anti-Aliasing, Forward shading, and Instanced Stereo. Instanced Stereo will improve render efficiency, and it will allow us to render a stereoscopic panorama material.
In the Android Section, Press the “Configure Now” button, then Accept the SDK License if you haven’t already. Take a moment to replace “YourCompany” with a more appropriate name. Then Update the Minimum SDK Version and Target SDK Version to 21. This corresponds to Android API 21 that we installed with Android Works earlier.
Install Location should be Internal Only.
Next, Enable Full Screen Immersive on KitKat and Above Devices, and swap Support OpenGL to ES3.1. Leaving it at ES2 will allow you to build but you’ll experience a lot of errors when compiling shaders.
Last of all, Configure the AndroidMainfest for deployment to GearVR. That’s it for Project Settings. Restart your project to apply changes and we’ll move on to setting up a simple stereoscopic scene.
We won’t need much for our example. Delete everything from the map except for the Player Start, and add a Sphere static mesh actor with a scale of 400.
Now we’ll prepare the material for the sphere.
In the Material’s detail panels, enable two sided and set Shading Model to Unlit. We’ll be viewing it from the inside and only need an emissive channel.
Plug a Texture Sample Node into the Emissive Color Channel, if you don’t have a stereo 360 image of your own, you’ll be able to download one from the links in the description of this tutorial. The top portion of the image will server as our Left Eye image, and the bottom was our right eye.
We’ll map the UVs of the Left eye first. Do this by getting the Texture Coordinates node and setting VTiling to 0.5 in the new nodes detail panel.
For the right eye, use an Add node after the existing coordinate with a Constant 2 Vector of (0,0.5).
We can Choose between these two UV options with a Lerp Node, using a 0 or 1 Alpha to display the left or right eye. Here’s where the Instanced Stereo project setting comes into play: Add a Custom node, with the CMOT Float 1 Output Type. In the Code section type return ResolvedView.StereoPassIndex;
The Left eye pass returns black, and the right eye pass returns white, perfect for determining our UVs.
The Texture appears inverted inside the sphere, to fix this I’ll negate its scale on the X axis.
The project is complete! With your Oculus Go plugged in, and adb active, you should see the Go as an android device in the Launch dropdown. Click it to deploy to your Go. Once it shows that it is running on your device, unplug the Go and take a look!
The distortion you see is due to the camera’s refresh rate. In the headset, it should be smooth with a high framerate.
Elara has produced a tutorial for modeling the Oculus Go hand controller so be sure to check that out and click below to download your free model of the UE4 project scene file and use it as your starting point.
Continue to check back here for more tutorials, and give us a shout if you’re interested in learning more about Elara!