Oculus Rift

From Unity3D

Jump to: navigation, search

Note: The following demo is provided by the makers of the Oculus VR headset and Unity. It is available to all developers through the oculus rift website. Kindly register (free) for the complete SDK. (The V2.0 starter code is a modified version of the original oculus wrapper.)

This is also a brief best practices for the oculus rift.


What is the Oculus rift?

See what is Oculus Rift on Wikipedia.

Getting Started

  1. You do not need the SDK to run Unity and Oculus together. Just download the project listed at the end of the project.
  2. Open a new unity project. Go to Assets -> Import Package -> Custom Package and choose the OculusUnityIntegration Package located in OculusUnityIntegration.
  3. When you import the below package into a new project, you will find a folder called OVR.
  4. In OVR, there is a prefabs folder. Drag the OVRCameraController to your scene or OVRPlayerController based on what you want to use.

(Note: The playerController is written over the character controller, you might want to write your own controller)

Important Parameters

  1. If your experience requires you to consider the player height as a factor, UsePlayerEyeHeight is the variable you should look for (in OVRCameraController.cs ). This variable picks up the height from the Oculus calibration tool.
  2. IPD , which stands for interpupillary distance, is the distance between your pupils. IPD calibration is important for nausea-free gameplay with the Oculus Rift. This parameter can be set using the same calibration tool mentioned above.
  3. The Prediction parameter in the wrapper helps predict how the user's orientation is bound to update. It din't make a world of difference in initial tests but this point will be updated based on further tests.
  4. The function CalcScale(..) in OVRDevice.cs initiates the fish lens behavior by reading distortion coefficients. Each time you start your world, these values are accessed from the Oculus. If the oculus is not connected, they get assigned values 1,0,0,0 . If we set these values to 1, 0.22, 0.24, 0 we can see the fish eye/ distorted view in unity without the need to connect the oculus.
  5. The setOrientation() function in the OVRCamera updates the camera orientation. Disabling this call will disable camera position updates. You can continue receiving gyroscope data by calling the getAcceleration() / getAngularVelocity() functions.
  6. OVRDevice.cs has the latest getAcceleration() / getAngularVelocity() functions defined in it. Its a static class so just call them as such.
  7. The camera view port widths in the wrapper are split into 0.25 , 0.25 and 0.5 . The two 0.25 are the oculus rift cameras and the 0.5 is the audience camera.

General Points to keep in mind

  1. You can use normal image effects on the Oculus rift camera but keep in mind, the 1st version of the OR dev kit already has a lot of pixelation. So adding effects like motion blur is not noticed easily.
  2. The Oculus comes with 3 lenses. A is for long sighted people or a normal lens. B is for mild shortsightedness and C for extreme shortsightedness.
  3. Important Note : The oculus sensor readings come into the right camera in unity. So parent things to your right camera instead of the left.
  4. The gyroscope data from the oculus rift goes into cameraRight gameObject. So if you want to move some objects of the scene with the rift, make them child objects of the cameraRight object.
  5. When subtracting rotations of 2 different oculus rifts, direct subtraction will not work. The rotation data of oculus does not range from 0-360 on all axis. Eg: It may shift from 90-270 on one axis and -90 to 90 on the other. So you will need to write a custom cancellation script based on what you are trying to achieve.
  6. Culling on Oculus rift + depth + layering can be done on the oculus: To achieve this, use the OVRCameraController prefab as is. Make sure you change the depth and layer values.

Instructions For Wrapper Usage

  1. The new wrapper has the split screen view. This way audience can see your game properly.
  2. Please do not change the build settings at any point.
  3. Oculus camera will run on screen 1 and normal camera will run on screen 2.
  4. Default is windowed, don't change it. The batch file mentioned below takes care removing the window.
  5. Make sure you include the OculusUnity.bat file with all your builds.
  6. While submitting, open OculusUnity.bat and rename the (file).exe to your filename.

Instructions For Running in platform room and RPIS

  1. Set your resolution to 1280x800 on the monitor and the Oculus Rift.
  2. Set the oculus as the left display and monitor as the right display.

Starter Code


Personal tools