Virtual reality glasses on Linux

Second Sight

Author(s):

For decades, gamers and geeks have dreamed of virtual reality. Thanks to the Oculus Rift, this dream could become a reality for Linux users and developers as well – even though the whole thing is sponsored by Facebook.

The producers of the Futurama cartoon (who also produce The Simpsons) must have sensed this: When protagonist Fry tries the Internet in the year 3000, he ends up in a virtual 3D world – the future Internet. Before he can succumb to its fascination, however, a horde of noisy banners pounces on him: "My God, it's full of ads!" is his horrified cry [1].

Many fans could see the future of virtual reality this way since the acquisition of Oculus VR [2] for US$  2 billion by Facebook. Oculus is the company behind the Oculus Rift (Figure 1), the prototype of a VR "glass" that catapults the old science fiction vision of VR into the present day.

Figure 1: The current Oculus Rift from Developer Kit 1 together with controller box.

Strangely, the acquisition of this hot piece of hardware by Facebook has significantly cooled the enthusiasm of many fans. Minecraft developer Markus Persson made a prominent announcement canceling his cooperation with Oculus VR after the deal. Additionally, the company's employees were exposed to a storm of outrage – ironically, often in the form of Facebook comments, which occasionally took a more serious turn, including death threats.

After the Storm

Now that the storm has subsided somewhat, the extent of the damage seems more manageable. According to Palmer Luckey, CEO of Oculus VR, users will not need a Facebook account to use the Rift in future. Oculus could have sold the company to other big players; however, the general message was that the latter were just not interested in the vision the company shared with Facebook's Mark Zuckerberg. Thanks to the Facebook funding and the technical vision, VR could now be realized for the first time.

Thus, many developers want to continue working with the data glasses. In fact, if you are really interested in a virtual reality future, you currently have very little choice but to resort to the Oculus Rift. Other major manufacturers are working on data glasses, but it can take a while for models to appear, not to mention Linux support (see the "VR Competition" box).

VR Competition

The most frequently mentioned competitor in terms of data glasses is Sony with its Project Morpheus [4]. After the Facebook shock, the company hopes to soak up defectors from the Oculus camp, but you cannot officially buy prototypes of the Morpheus. Critics fear that the glasses might support PlayStation 4; Sony is also not exactly known for openness. The prototype presented at the Game Developers Conference 2014 was likened to the Oculus Rift [5] by German computer magazine Ct.

Microsoft has even less to show, but rumor has it that Redmond is also working on data glasses. If so, they have never been presented publicly. Linux support would be even more of a surprise there, despite the change of management, and rumor also has it that the data glasses only work with the Xbox.

The most interesting Oculus alternative for Linux developers would probably be the data glasses by Valve. The game distributor and manufacturer already offers some games with a VR mode for the Rift, but is also working on its own VR hardware. The makers of the Steam platform presented the hardware at the Steam Dev Days, albeit in a back room. It was the "world's best VR tech demo," says Oculus boss Palmer Luckey. Valve has ported hundreds of games to Linux with Steam OS running on Linux underpinnings – and there are numerous games with VR support. The glasses thus should electrify Linux developers.

Here's the catch, though: What Valve really intends to do is currently unclear. On one hand, the Steam developers have contributed greatly to the internal Crystal Cove prototypes of Oculus Rift, on which the DK2 is partly based. On the other hand, three of Valves VR developers recently moved to Oculus VR – whether this occurred with or without the blessing of management is unknown.

Finally, a number of smaller players have also attracted some attention in the wake of Facebook's acquisition. The Cortex glasses by Sulon [6] attempt to merge augmented reality with virtual reality by complementing your living room with virtual objects. Devices are due for release in late 2014 and cost around US$  500.

And, don't forget True Player Gear [7]. The hardware data is similar to that of the DK2 by Oculus VR: The glasses include an OLED display and two 1080p cameras, and the field of view is 90 degrees, which would be akin to the Rift. Additionally, some large gaming engines support the VR glasses. Unlike the devices from Sony and Microsoft, the True Player Gear is designed to work with Apple computers and Windows PCs as well as with game consoles (PlayStation and Xbox). In the summer of 2014, the team will be looking to launch a Kickstarter to raise funds, and a device will be on display at E3 in Los Angeles in July.

Until recently, anyone who signed up as a developer for the Rift could order the Developer Kit 1 (DK1), and some devices are still up for grabs on eBay. You can now order the DK2, though, which will be released in July and which fixes many of the problems with the DK1.

More importantly for Linux developers, however, the SDK runs on Linux, as do some of the demos. It is not under an open source license, but the source code is available. If you believe Luckey [3], the company will not ask for any money from SDK users, which means they can publish the games they produce with it without asking for permission.

Unwrapped

A week passed between when I ordered the VR glasses (DK1) and when the goods shipped from the UK. All told, the device set me back around EUR 300 (about US$  400 or UK£ 250). The supplied plastic case included three pairs of lenses labeled A, B, and C. The widest lenses (A) are designed for far-sighted and normal-sighted users, the middle size (B) is for moderately nearsighted users, and the C lenses are for highly myopic users only. Users who wear glasses can theoretically leave them on: The front of the Rift can be moved slightly forward to avoid contact between glasses and lenses. In practice, however, this might not always work out with the DK1.

The VR glasses are hardwired to a small controller box by a 6-foot (~1.8m) cable and features different connectors. One is for the power supply, and two others (USB 2.0 and HDMI 1.3+) connect to a computer, which thus needs a reasonably up-to-date graphics adapter for the demos to run at the recommended 60 FPS. I used an HP laptop with an ATI/AMD graphics card (HD 6500M) in our lab. There is also a DVI output, together with a DVI/HDMI adapter. On the controller itself, you can enable the Rift by pushing a button; VR users can also adjust the brightness and the contrast.

Inner Values

When you put on the Rift, you look into a 7-inch 60Hz LED display with a 1280x800 resolution (5:4 aspect ratio), which means 640x800 pixels for each eye. This is not much, so you can expect a pixelated display. The field of view is 110 degrees diagonally, and 90 degrees horizontally, which gives users a sense of immersion. Users are completely shut away in virtual space and cannot see the outside world, which is different from augmented reality or VR solutions with a smaller field of vision.

Although a human's horizontal, binocular field of vision is 170 degrees, you can't actually detect patterns at the edges of this field. Head tracking, which follows the user's head movements at a sampling frequency of 1000Hz, supports the feeling of immersion. The DK1 has three degrees of freedom (DoFs): You can move your head up and down (pitch), turn to the right and left (yaw), and tilt your head to the right and left (roll). The interpupillary distance (IPD) is fixed at 64mm, but this can be changed in software via stereoscopic projection.

DK2 on the Way

Virtual reality fans seek to achieve presence, which means the user perceives the virtual world as real: The brain accepts the illusion as a second reality because it does not notice any visual errors and anomalies. The second development kit (DK2) already comes closer to this goal, because the developers have optimized the hardware of the first kit.

At a resolution of 960x1080 pixels per eye, the picture is now much sharper and the risk of pixelation much lower; the production version is likely to offer even higher resolution. At the same time, the OLED display achieves refresh rates of between 60 and 75Hz with switching times of only 2 or 3 milliseconds, thus preventing motion blur and judder. Additionally, the DK2 comes with an additional external device that determines the absolute position of the user in space. This means that head movements to the front, back, right, left, up, and down are interpreted, giving the Oculus Rift six degrees of freedom.

This innovation, together with the faster screen response times, solves one major problem of the first kits: motion sickness. In fact, some users felt sick when they tried to use the Rift. This situation is now much better and possibly a closed case. Another improvement that developers are likely to welcome is the absence of the previous desktop cable clutter: A 3-meter-long cable that terminates in a USB and an HDMI connector supplies the glasses with power and data. The controller is eliminated, and the cable is detachable. Whereas the DK1 cost US$  300, the new version costs US$  350.

Hello, Linux

In our lab, I tried out the Oculus Rift on a pre-release version of Lubuntu 14.04 to keep the desktop overhead as low as possible. To start, the system needed the proprietary drivers for NVidia or ATI video cards; the Rift did not work with the free drivers. Although the Rift should actually run with Intel cards like the HD 4000 according to the official information [8], the makers recommend graphics cards that allow a frame rate of 60FPS.

After installing the driver and rebooting, you can connect the hardware, turn on the VR goggles via the controller, and configure the displays. The DK1 expects a resolution of 1280x800 pixels, but the test laptop's screen used 1366x768 pixels. Lubuntu 14.04 automatically and unchangeably configured the Rift display as the first display and did not assign a separate resolution for the laptop display. Other Linux systems might do a better job of this, but it was not a major problem.

To get started with the Oculus, you also need the SDK, which means having a free account for the developer zone [9]. You will find several scripts for Linux in the SDK that you need to run one after another. After unpacking the SDK archive, go to the OculusSDK folder and run the commands in Listing 1.

Listing 1

Getting Started with the Rift

 

The script uses chmod to get rid of any access problems; in the next step, the configuration script installs a number of packages that the Rift requires on Linux systems. In the last two lines, the installer relinks an existing udev library if the Oculus World Demo complains about a missing udev library at startup. At this point, you could run the demo, but without head tracking.

To enable and customize the Rift to match the personal needs of the individual user, you need to run the ./OculusConfigurationUtility script as shown in Figure 2. If you see a "No USB detected" message at the top of the window, it could help to unplug the Rift's USB cable briefly and then plug it back in. You can then create a profile, set the type of eye glasses used, and press the Calibrate button to calibrate the VR glasses. To do so, rotate the unit at head height through all three degrees of freedom until the window on the screen shows a green stripe (Figure 3). You then store the settings. Rift users can enter the IPD manually or select Launch Interactive Utility to launch an interactive tool that supports this.

Figure 2: The configuration tool for the Oculus Rift helps measure the field of view and calibrate head tracking.
Figure 3: During calibration, the user needs to rotate the VR glasses several times through the three axes.

The Measure IPD button launches a test to adjust the Rift to the user's field of view (FoV). To do this, you need to close one eye and follow a vertical green line, which you push to the far left or far right by clicking on the two arrows. You then repeat the process for your other eye; Accept stores the settings (Figure 4). The next time you start, however, you have to repeat this performance; the configuration script is still fraught with teething troubles (see the "Configured to Death" box).

Figure 4: You can use the Settings Viewer to check whether the settings are right for your eyes.

Configured to Death

The configuration tool does not yet work perfectly, and it is also used for several other purposes. Besides the SDK, the Unity demo from the Oculus website [9] includes the tool. If you want to test Steam with the VR option, you will find the same tool under the name Steam VR. It does not store profiles and may even fail to detect the Rift, until you unplug and replug. These issues need to be rectified.

Oculus in the House

The ./OculusWorldDemo then starts the Toscana demo, which takes you to a rather sparsely furnished villa with a sea view (Figure 5). You can look around with the help of head movements and move your (invisible) Avatar, using the arrow keys. Pressing the Space bar takes you to an in-demo mode that displays some values (FPS, FoV, IPD) and keyboard shortcuts that let you change the parameters of the game. The demo does not include sound.

Figure 5: Luxury, even if only virtual: The Toscana demo is usually the user's first encounter with virtual reality.

An overview of the available demos, including those for Linux, is available online [10]. Demos and games worth exploring include Titans of Space, Technolust, The City, The Room, and Lorryrider (Figure 6); the latter needs an advanced graphics card; otherwise, judder tends to spoil the effect. In some demos, I first had to press the F11 key to correct the perspective.

Figure 6: In Lorryrider, the Rift user takes a ride on a car through a mine; you need a good graphics card for this.

Developing for the Rift

If you want to develop software for the Rift, the related manual contains all the information you need about the included SDK. The Oculus Rift in Action book [11] by Bradley Austin Davis, Karen Bryla, and Alex Benton is described by the authors as a work in progress. It deals with programming for the Rift, and it points users to a GitHub repository with freely available examples for application developers [12]. Listing 2 shows how the software, which integrates a customized version of the Oculus Rift SDK, can be built on Ubuntu 14.04.

Listing 2

Oculus SDK for Linux

 

After installing some header files in the first step, you download the code from the GitHub repository and retrieve the init and update submodules. You then create a build directory, change into this, then run cmake to generate a Unix-style Makefile, which you then run as the last step.

If the compile process fails, you may need to go back and add more development packages, according to the error messages. If the process is successful, the executable sample files end up in the build/output directory.

Motor Controlled

You can quickly accumulate a huge amount of code in 3D programming; thus, it makes sense  – and not only for game developers  – to use 3D graphical editors that rely on an underlying game engine. The Unity engine is very popular and well supported in this respect. Oculus VR includes files that help Unity output Rift-optimized demos; the SDK also exports files for Linux.

On the website, you will also find a manual for Unity integration [13] and a Unity variant of the Toscana demo [9]. The downside: The Unity editor needs to be installed, and it still doesn't run natively on Linux. Additionally, the graphics in games created with Unity are not generally considered state-of-the-art  – even if they are perfectly okay for many of today's indie games.

Less well integrated, but just as interesting, is Valve's Source SDK 2013, which supports the Oculus Rift [14]. Developers of commercial games need a commercial license; for all others, the engine is free to use. It is installed on your disk along with the fairly ancient Hammer editor.

For something more visually state-of-the-art, try the Unreal engine and CryENGINE. The manufacturers of both announced Linux versions for spring 2014, and the pricing model was changed. Versions 3 and 4 of the Unreal engine support the Rift, and CryENGINE has built-in Rift support (versions 3 and 4).

Among the free engines, Torque 3D [15] works with the Oculus Rift, and Panda3D [16] offers at least rudimentary support. The Blender Game Engine (BGE) also works with the VR glasses; developer Lubosz Sarnecki created a Python wrapper [17] based on the OpenHMD library and released under the Boost Software License.

Web 3.0

On the web, many projects and people focus on data glasses. Some simply render an existing image stereoscopically and show it at a certain distance; this also works for YouTube videos. The difficult part is integrating head tracking; usually the user can only change perspective with the mouse or keyboard. The vr.js [18] library also supports head tracking, but it relies on the outdated NPAPI.

In particular, the JavaScript Three.js [19] library is very popular in the 3D community. Several impressive projects are hosted on the associated website, including a demo for the Rift [20]. Last, but not least, Second Life could be making a comeback thanks to the new technology: At least, the alternative CtrlAltStudio client [21] supports the VR glasses.

Conclusions

The Oculus Rift and its relatives could see virtual reality become mass market material for the first time; consumer devices are expected in 2015. It appears likely that players in particular will be interested in the new technology. However, there is also interest in VR technology in the CAD and movie industry, as well as in medical technology. Engineers of the private space company SpaceX are already experimenting with the new technology [22]. It remains to be seen to what extent a VR Internet will eventually emerge, but virtuality would certainly be an interesting field for conferences and live streaming.

Looking at the list of existing demos and games for the Oculus Rift, Linux users seem to once more cross the finish line in third place. However, minor improvements are noticeable: The SDK works on Linux, and the major game engines now offer Linux support.

Which controllers will win the race is an open question. Clearly, however, a combination of keyboard shortcuts and VR glasses is less than perfect. The Razer Hydra seems to be popular, and it comes with a Linux SDK [23]. Additionally, work is in progress on some data gloves.

Infos

  1. Futurama excerpt: http://vimeo.com/37047687
  2. Oculus VR: http://www.oculusvr.com
  3. Oculus SDK license: http://www.reddit.com/r/oculus/comments/1dfnhw/id_like_to_hear_palmer_respond_to_this_oculus_not/c9pvvwg
  4. Sony's Project Morpheus: http://blog.us.playstation.com/2014/03/18/introducing-project-morpheus/
  5. Sony Morpheus vs. Oculus Rift: http://www.heise.de/ct/artikel/VR-Brillen-Sony-Morpheus-und-Oculus-Rift-2-im-Vergleich-2150859.html (in German)
  6. Sulon Cortex: http://sulontechnologies.com/cortex/
  7. True Player Gear: http://www.trueplayergear.com
  8. Performance recommendations: https://developer.oculusvr.com/wiki/Oculus_SDK_Performance
  9. Oculus SDK download: https://developer.oculusvr.com/?action=eula&v=8
  10. Demos and games for the Rift: http://www.riftenabled.com
  11. Oculus Rift in action: http://www.manning.com/bdavis/
  12. GitHub repository for Rift developers: https://github.com/OculusRiftInAction/OculusRiftInAction/
  13. Unity and the Oculus SDK: https://developer.oculusvr.com/?action=doc
  14. Source SDK by Valve: https://github.com/ValveSoftware/source-sdk-2013
  15. Torque 3D: https://github.com/GarageGames/Torque3D
  16. Panda3D: https://www.panda3d.org
  17. BGE support for the Oculus Rift: http://lubosz.wordpress.com/2013/06/26/oculus-rift-support-in-blender-game-engine/
  18. vr.js with head tracking: https://github.com/benvanik/vr.js/tree/master
  19. Three.js: http://threejs.org
  20. Rift demo with Three.js: http://threejs.org/examples/#webgl_effects_oculusrift
  21. CtrlAltStudio client with Rift support: https://ctrlaltstudioviewer.codeplex.com/SourceControl/latest
  22. SpaceX using the Oculus Rift: https://www.youtube.com/watch?v=xNqs_S-zEBY
  23. Razer Hydra: http://sixense.com/linuxsdkdownload