Objective

Main objective of this Unity Oculs Rift Tutorial is to explain how to Integrate OculusRift SDK with Unity3D.

 

 

Step 1 Introduction

The Rift is a virtual reality head-mounted display, developed by Oculus. This bring amazing virtual experience to its users.

For more information refer following link:

Oculus rift offers SDKs to integrate Rift in different software like Unity, Unreal Engine. In this blog I would be concentrating on integrating Oculus Rift SDK 0.4.4 with in Unity.

We are going to discuss Oculus Rift SDK 0.4.4 using DK2 device with:

  • 960 x 1080 HD resolution per eye.
  • 75 Hz, 72 Hz, 60 Hz refresh rate.
  • 2 ms (75 Hz), 3 ms (72 Hz), full Persistence (60 Hz).
  • Gyroscope, Accelerometer, Magnetometer sensors.
  • 1000 Hz update rate.

For more information about DK2 please visit Oculus DK2
Oculus Rift SDK 0.4.4 integration with Unity is pretty straight forward. So let’s get started.

 

Step 2 Implementation

 

2.1 Requirements

  1. Unity pro 4.5 or higher version Also refer Unity SDK documentation
  2. Download Oculus SDK for Windows Runtime v0.4.4
  3. Download Unity 4 Integration Package
 

2.2 Installation And Configuration

Installation and configuration of Oculus SDK for Windows Runtime v0.4.4:

1) Install Windows Runtime.

install

windows-security

It will ask for Oculus VR, Inc Display adapters driver during installation process. Click Install. 

question

Restart you PC after installation complete.
2) Connect your DK2 device to your PC.
3) Start OculusConfigUtil from application and you see something like this.

oculus-configuration-utility

After detection of DK2 device which you have attached to your PC, Oculus Configuration Utility will automatically detect your device. 

device

Don’t worry if you don’t have any Rift Device, still you can test your game right in your Unity editor.
4) To work with Unity editor you have to use Extended Desktop to the HMD mode instade of Direct HMD Access from Apps

To-Do: Select Tools >> Rift Display Mode >> Select Extended Desktop to the HMD >> Hit Apply

rift-display-mode

 

2.3 Check correct rift resolution

Now your rift device appear as a normal monitor to Windows. So

1) Open Screen Resolution by right clicking on desktop. 

screen-resolution

Verify your screen resolution, it should be 1920 X 1080 for DK2 or 1280 X 800 if you are using DK1.

 

2.4 Set up refresh rate

Low Persistence In DK2: Low persistence reduces pixel smear and motion blur.

Learn more about Persistence of vision and How Low Persistence Reduces Motion Blur With DK2 running there is a chance to refresh rate default to 60 Hz. It needs to be 75 Hz.

To-Do: Right click on desktop and select Screen Resolution >> Click Advanced Settings >> Set 75 Hz from monitor panel.

advanced-settings

 

2.5 Setup Oculus Rift Unity SDK in Unity

1) Create new project from Unity, name the project something like OculusRiftDK2Demo.

2) Verify that you are on correct platform i.e. PC, Mac & Linux Standalone.

To-Do: Select File >> Build Settings OR press Ctrl+Shift+B on PC 

build-settings

3) Set new quality level from Edit >> Project Settings >> Quality

inspector

In above settings important value to modify is Anti-aliasing. The anti-aliasing must be increased to compensate for the stereo rendering, which reduces the elective horizontal resolution by 50%. An anti-aliasing value of 4X or higher is ideal.

4) Configure Resolution and presentation for standalone build.

To-Do: Select Edit >> Project Settings >> Player

a) Uncheck Default Is Full Screen.
b) Set Default Screen Width to 1920 and Default Screen Height to 1080.
c) In Supported Aspect Ratios keep only two options checked i.e. 16:10 & 16:9. This setting required to run demo on your DK2 as expected.

player-settings

And yes one more important thing you need to i.e. disable Use Direct3D 11 mode from Edit >> Project Settings >> Player (Other Settings) 

other-settings

To run your demo in Unity editor you need to disable Use Direct3D 11 option, otherwise black screen will appear in Unity game window when you hit play.

4) Unzip downloaded Unity 4 Integration Package

  • After unzipping you will see two Unity packages OculusUnityIntegration.Unitypackage
  • Contains Oculus Rift plugins and library OculusUnityIntegrationTuscanyDemo.Unitypackage
  • Contains Oculus Rift plugins and library and Tuscany demo.

5) Import OculusUnityIntegrationTuscanyDemo.Unitypackage

To-Do: Select Assets >> Import Package >> Custom Package >> Select OculusUnityIntegrationTuscanyDemo.Unitypackage >> Click Open

importing-package

Now open VRDemo_Tuscany.Unity scene from Assets >> Tuscany >> Scenes folder

6) Set your game view on Rift Device screen To run demo on your Rift Device you need to follow below steps otherwise you won’t see anything on your Rift Device.

a) Set Default layout from Window >> Layouts
b) Right click on Game >> Add Tab >> Game

This will bring new game window:

game-window

c) Now you need to move new game window in your Rift display.

  • Make sure your Rift Device is powered on (normally you see desktop)
  • Drag newly added Game view until you not see in your Rift Device
  • Click maximize button from game window to full screen

full-screen-view

  • Make sure Free Aspect is selected in your game window
 

2.6 Play Tuscany Demo and Build

1) Click Play button in Unity editor.
2) Build your first standalone demo

To-Do: File >> Build Settings >> Hit Build

scene-in-build

I hope Unity Oculus Integration works fine at your end while integrating OculusRift SDK with Unity3D. Let me know if you have any questions or concerns regarding OculusRift SDK or Unity3D, please put a comment here and we will get back to you ASAP. Enjoy :)

Got an Idea of Game Development? What are you still waiting for? Contact us now and see the Idea live soon. Our company has been named as one of the best Game Development Company in India.

I am Game Developer. My passion for games has made me a self-motivated individual who always strives to improve my work, is always wanting to learn more and never afraid to try new approaches and concepts in design and development. Particularly interested in multiplayer and social oriented games which encourage human interaction.

face mask Belial The Demon Headgear Pocket Staff Magic