dcsimg
 

Open Development Kits for Virtual Reality

Wednesday Jun 20th 2018 by Bradley L. Jones

Check out a couple of open sourced options for doing Virtual Reality development.

There are many options for doing Virtual Reality development. One of the most popular is to use one of the gaming platforms and engines, such as Unity or Unreal. Although these are viable options for doing development in the virtual or mixed reality space, they are tied to specific companies and, if you build successful solutions, they can contain high licensing fees. There are, however, a couple of development platforms that many VR developers are using that are more open or worth reviewing if you are going to build your own solutions.

OSVR/OpenVR

OSVR is the Open Source Virtual Reality hardware and software project with a focus on providing a solution for allowing headsets and controllers from all vendors to be used with any game or other VR software. The software platform is intended to provide open, cross-platform solutions for detecting, configuring, and operating VR hardware.

OpenVR is a software development kit that committed to working with OSVR. OpenVR provides an API that can be used with multiple hardware vendors. The focus of the API is to allow developers to create VR applications that will work with a variety of different VR hardware vendors as well as work even if application code is updated. When using the OpenVR API, developers call routines from their code to connect and access hardware.

The code for OpenVR is available on GitHub.

WebVR

For developers working with Web-based solutions or JavaScript, the WebVR API provides a possible alternative for Virtual Reality development. The WebVR API provides the capability to target standard VR devices, including Oculus, Daydream, Windows Mixed Reality, PlayStation, HTC, and Google's Cardboard with applications embedded within a Web browser.

The WebVR API uses WebGL and, like OSVR, works to target multiple VR hardware devices by having you query the devices to verify what the devices are capable of doing. To use WebVR, the user must have a compatible Web browser. It is important to note that certain headsets work best with different browsers. Table 1 shows the best browser to use at the time this article was written:

VR Device Best Browser(s)
Daydream Chrome (or Daydream-ready Android devices)
Gear VR Oculus Browser, Samsung Internet
Google Cardboard Chrome (on Android devices)
HTC Vive Firefox, Servo, Supermedium on Windows, Firefox Nightly on macOS
Oculus Go Oculus Browser
Oculus Rift Firefox, Supermedium
Windows Mixed Reality Microsoft Edge, Firefox (with StreamVR), Supermedium (with SteamVR)

Table 1: Best Browsers for WebVR

Using WebVR

The WebVR API provides code to build VR solutions for the Web. Before dumping a user into a WebVR solution, your first step should be to confirm they are using a browser that is supported. This can be done with basic WebVR functionality gained through getVRDisplays:

      if(navigator.getVRDisplays) {

If navigator.getVRDisplays is true, WebVR is supported. If WebVR is supported, you use WebVR to see if a VR display is attached with a bit more code:

navigator.getVRDisplays().then(function(displays)
{
   if(displays.length > 0)
   {
      // VR display is available…
   }
});

Displays will contain entries for any VR displays attached. By checking to see if this is greater than zero, you can determine if a display is attached. Listing 1 contains the preceding code in a manner that can be run on your local browser.

<html>
   <head>
    <script type="text/javascript"&gt
      window.onload = function() {
         // Check to see if WebVR is supported
         if(navigator.getVRDisplays)
         {
            document.getElementById("ms").innerHTML = "WebVR
               Support";
            // See if displays are attached
            navigator.getVRDisplays().then(function(displays)
            {
               // If a display is available, you can do VR
               // stuff....
               if(displays.length > 0)
               {
                  document.getElementById("md").innerHTML =
                     "VR Display Found";
                  // vrDisplay = displays[0];
                  // You are ready to go!
               }
               else
               {
                  document.getElementById("md").innerHTML =
                     "VR Display NOT Found";
               }
            });
         }
         else
         {
            document.getElementById("ms").innerHTML = "WebVR
               Not Supported";
         }
      }
   </script>
</head>

<body>
   <p>Checking to see if WebVR is supported and if a
      VR Display is available.....</p>
   <H3 id='ms'>a</H3>
   <H3 id='md'>b</H3>
</body>
</html>

Listing 1: WebVR detection for support and a VR display

Figure 1 shows the result when Listing 1 is run within Microsoft Edge on Windows 10 with a Lenovo VR HMD attached.

WebVR check in Microsoft Edge with a Lenovo device
Figure 1: WebVR check in Microsoft Edge with a Lenovo device

When this is run in Firefox on Windows 10 with the same Lenovo VR HMD attached, the result is a bit different, as shown in Figure 2. Table 1, shown earlier, indicated compatibility. You also can find a more specific list of routines within WebVR that are supported in various browsers on the Mozilla site.

WebVR check in Firefox on Windows 10
Figure 2: WebVR check in Firefox on Windows 10

Once you've determined that WebVR is supported and that there is a display attached, you can present your VR content. WebVR includes routine to redirect to the VR display as well as help you present your content.

Other VR Libraries

Only a couple of virtual reality development libraries were covered in this article; however, there are many more available. The ones covered here are more open and thus help to keep you from being locked into a propriety solution. An additional benefit of using these libraries is the capability to separate your code a bit more from the hardware. If you have suggestions for other VR development libraries that are worth checking out that don't include licensing fees or lock you into proprietary solutions, post a comment!

Home
Mobile Site | Full Site