Friday, February 12, 2016

Oculus Rift DK2s kind of (secretly) do work on laptops (sometimes) and you can make VR stuff in Unity (maybe)

This is a rant + technical guide about how to get an Oculus Rift DK2 to work with Unity 5 so that you can make stuff with it. Maybe.

I'm teaching two virtual reality classes this semester, and I was dreading having to tell all my students that Oculus (in all their wisdom) has a public policy of no longer supporting Mac OSX, or any laptop, for the foreseeable future. Even now, when I tell my colleagues about this, they react with incredulous shock. With this single move, Oculus basically alienated the entire creative coding / technologist community, and basically 99% of the design / programming community in New York City.

The core of the issue is in how Oculus wants to synchronize (a) the image in the VR HMD (head-mounted display, or headset) with (b) the very subtle motions your head makes. If these two sensations aren't synchronized, then people usually suffer "simulator sickness." So, the VR industry generally wants to make sure these two things are synchronized as closely as possible, to make sure people don't vomit when using this glorious new technological medium.

In order to synchronize those things as fast as possible (90 frames per second is the minimum, 120 fps is the ideal) the HMD needs "direct access" to your graphics card.

Most laptops are engineered purposely to cut-off direct access like that, mostly because they have two different graphics processors -- one weak energy-efficient GPU, and one higher performance power-hungry GPU. For day-to-day non-VR use, the weak one is more than good enough, so that one is in charge.

From a VR developer perspective, we were early adopters and happily making Oculus prototypes for years, and our "weak inadequate laptops" were good enough. Then around runtime 0.5, Oculus discontinued OSX support and began insisting that all laptops were just inherently inferior and didn't deserve any attention. From our perspective, Oculus basically took away something that seemed to be functioning fine, for basically no good reason. It's really really really annoying.

If you search "oculus laptop", it's mostly going to be forum posts from the Oculus community manager telling people that laptops aren't supported... so I was pleasantly surprised when I was prepping to teach these VR classes and it turns out runtime 0.8 actually does work on my Windows laptop! My suspicion is that the GPU vendors Nvidia and AMD both updated their drivers to give Oculus what they wanted... well, kind of.



First, the bad news about developing for Oculus VR on your laptop:
  • I'm guessing it is using your integrated GPU, bypassing your discrete GPU entirely. That's the workaround the drivers provide.
  • That means it's pretty low performance. Your framerate will usually sit in the 30s-60s at best. Fillrate is a huge problem. It is much worse performance than in runtime 0.4.. BUT AT LEAST IT WORKS!
  • It's hacky and it's mostly for developers who want to work in virtual reality. This is not for general audience gamers or customers. Most games aren't very playable in this setup. If you are a developer who has to give a demo, you'll want to lug a desktop PC to the show.
  • Unity 5 has made a point of supporting the old 0.5 runtime for OSX; as far as I know, Unreal Engine 4 only supports 0.7+ runtime, which is not available for OSX.
  • In my experience, the OSX workflow is surprisingly stable and reliable. Most problems are usually with Windows laptops.
DISCLAIMER: You do this stuff at your own risk. When doing this on Windows, make sure you backup your files and enable System Restore. Some of my students have bricked their computers while trying to get it to work, because it does some funky stuff with your GPU settings. Be careful.


    VR INSTALLATION FOR WINDOWS (runtime 0.8)
    1. If you have a Geforce GPU, install the latest nvidia GPU drivers https://developer.nvidia.com/gameworks-vr-driver-support ... If you have a Radeon GPU, install the latest AMD GPU drivers http://support.amd.com/en-us/kb-articles/Pages/latest-catalyst-windows-beta.aspx
    2. Restart computer.
    3. Install Oculus Runtime 0.8 (uninstall and reinstall if you already installed it before) https://developer.oculus.com/downloads/ 
    4. Restart computer.
    5. Proceed to "VR TEST PROCESS" section below to make sure it's working
    VR INSTALLATION FOR MAC OSX (runtime 0.5)
    1. Download and install Oculus Runtime 0.5 for Mac https://developer.oculus.com/downloads/
    2. Open the Oculus Config Utility (shortcut is on your OSX desktop), plug in your DK2 USB and HDMI, and verify that it is being detected.
    3. Go to OSX System Preferences > Display, enable "Mirror Display"
    4. Click "Gather Windows", then in the "Rift DK2" window go to Arrangement tab and set it to rotate 90 degrees.
    5. Do the full "VR TEST PROCESS" section below to verify the VR display is correct.
    VR TEST PROCESS 
    1. plug in the DK2 USB and HDMI (you don't need the camera yet)
    2. open Oculus Configuration Utility, make sure it detects the DK2
    3. if it detects DK2, create a user profile (press "+" at bottom of the window)
    4. when you have a user profile, you can now click "Demo Scene" button in the lower-left.
    5. put on the DK2 and make sure it's working.
    6. if you made it this far, you are now ready to do VR stuff in Unity, have fun http://docs.unity3d.com/Manual/VROverview.html


    MAC OSX TROUBLESHOOTING:
    • If you can't find your Oculus Config Utility, check your desktop.
    • If only one eye is working, make sure you rotate the display in the OSX System Preferences. See "VR INSTALLATION FOR MAC OSX" section above.
    • In Unity, the Health and Safety warning does not disappear when playing. You can disable this warning entirely:
      1) in MAC OSX terminal, type:
         launchctl setenv Oculus_LibOVR_HSWToggleEnabled 1

      2) then in Oculus Config Utility, click "Advanced" button and disable the Health Safety Warning checkbox
      3) do NOT close the Utility window, or the setting will reset! Instead, minimize it.
    WINDOWS TROUBLESHOOTING
    • installation order matters; make sure you installed the new drivers BEFORE installing the Oculus runtime
    • if you have any "DisplayLink" drivers installed, uninstall them
    • if you have any Nvidia 3D / surround settings enabled, disable it
    • try plugging the DK2 USB into different USB ports on your computer
    • do not unplug / replug the DK2 too fast, it might blue screen you
    • restart your computer one last time
    • if you still can't get it working with these simple workarounds, my advice is don't try anything else, it probably won't work and you'll just end up bricking your computer -- instead, give up on the DK2, and use Google Cardboard, Samsung Gear VR, or the HTC Vive.


    One last note: I AM NOT OCULUS TECH SUPPORT.

    Comments will NOT be monitored. Good luck!