Virtual reality: connecting Unity to the CAVE

Virtual reality: connecting Unity to the CAVE

Imagine being given the opportunity to experience a life-like virtual environment together with your peers just by using technology. Imagine seeing things you have not pictured possible, like visiting an alien planet, exploring the deepest parts of the ocean or even using it for teaching young children.

As the technology for virtual and augmented reality is increasing and maturing over time, many new technologies are on the rise. One of them is the CAVE. In our latest project we were given the opportunity to use the CAVE and explore the possibilities with it for our project.

What is the CAVE?

The name itself is quite amusing as it is a recursive acronym which stands for CAVE Automatic Virtual Environment. It basically is made up of a cube-shaped room in which the walls act as the screens to project scenes onto, creating a virtual reality environment.

One or more people can stand anywhere within the CAVE and are able to see what everyone else in the room sees. The experience is so realistic, it is scary. The CAVE was developed for the purpose of overcoming some of the limitations which HMD (head-mounted devices) such as the Oculus, Samsung Gear VR have. A HMD is limited to provide the experience to only one person at a time, whereas a CAVE is at least 9m2 big, enabling for more than one person to experience.

As mentioned before the CAVE is a cube-shaped room where each wall of the cube is used as a screen. In most CAVEs the front, left and right walls are used to project onto, but sometimes the back and floor are also used. For each screen there are one or more designated projectors.

One important thing to understand is that all camera views are running in synchronization with each other, it all works as one. If something were to occur or change in one camera-view, the other camera-views are aware of this change and act to it accordingly. Say if a car moves from the front screen to the right, the right screen is aware of this occurrence and acts accordingly by displaying the car moving into the right camera-view.

In the image above it can be seen that the front camera-view and right camera-view are in synchronization. The wall and the floor are extended between the two views as you can see.

Our approach

There are multiple programs to show a virtual world in a CAVE, however we chose to use Unity. Normally one might think that Unity runs one game instance, and displays four different camera-views from that one instance. Well, due to how the game engine is built, this would be too difficult of a modification to core functionality.

Instead, Unity came up with a pretty clever solution. Instead of running one instance, they thought they would run four synchronized instances. To make this work however, they had to make some adaptations, to keep the four instances synchronized.

  • They automatically send the random seeds and input signals from the master instance to the slaves. This means that for example, character movement or random enemies spawning will be the same on all views. This already synchronizes most things within a Unity scene. In most cases, though, you will have one view displaying a view that is harder to render than the others, which would mean that this instance will have a lower frame-rate and will fall behind compared to the others.
  • To solve this, Unity developers made the master wait for all the slaves to have their frame ready, and then every instance would display it simultaneously. This means though, that the slowest frame-rate is the leading one, which can have bad consequences when running graphically challenging Unity programs.

  • Also, we had to set up the CAVE configuration in the editor, which is as much as assigning a number to each camera direction and pass this number in the launch arguments of the slave instances running on the corresponding workstations.

By simply setting up the Cluster Rendering part of Unity, we have already succeeded in displaying our Unity project on the walls of the CAVE. The difficult thing, however, is that this Cluster Rendering is still in closed beta, and we had some struggles being allowed to participate in the beta. Cluster Rendering being in beta has, however, not had any negative consequences on the stability of the feature.