Optimization

Running VR environments is a relatively demanding task. The VR hardware has two display screens that show slightly different views of the environment. Those two display screens need to be updated at about 90Hz, with more modern headsets refreshing even faster at 140Hz. The images rendered on each of the displays are created by the game engine which usually includes lighting calculations for each 3D face in the environment, along with physics calculations like collisions and gravity effects. In addition, all of the scripts that were created for interactions along with in the case of STEM labs the physics simulation for the experiment. If any of these tasks take too long, then the images cannot be updated and this results in a drop in the frames-per-second and causes stuttering in the virtual environment. Lag and stuttering in the virtual environment is especially bad and can lead to disorientation and a feeling of sea-sickness.

Optimization is focused on achieving the frame rate desired on the hardware of choice. If every possible user had the latest start-of-the-art computer, graphics card and virtual reality equipment, then optimization, while still important, would not be as critical. However, with the variety of VR hardware available it is critical to optimize all aspects of the virtual environment.

So what can you do to improve the VR environment's performance. The list below just gives a few starting suggestions.

  • The first step is to use the game engine's profiler. Every game engine has the capability to profile the performance of the environment and report how much time is spent on each aspect of the project. Then you can find what aspect of your project is taking the most time each frame and work on improving that performance first.
  • Number of faces in the scene: Every face in the field of view takes a bit of computational power to evaluate. By reducing the number of faces, you can spend some of the computational power on other tasks
  • Type of lighting: lighting is an important aspect of the environment. Real-time lighting is a type of lighting where object shadows, incident light, color due to light changes etc. are changed in real time (as the user moves around the environment) Calculating all of the lighting effects every frame once again takes computational power for each face. The alternative is to calculate lighting effects one time and then never make changes based on the lighting, this is called baked lighting.
  • Draw calls: All of the information about the face, what texture is applied, which shader is being used, any special effects like transparency is rolled into one concept called a draw call. Reducing the number of draw calls will significantly increase the frame rate of the project. Digging into the how to optimize draw calls would take a few more pages, but one quick way is to use texture packing to reduce the number of unique textures used in the project.

Frame Rate

A single frame is one loop through the code that makes up the VR environment, by optimizing the code, you can get faster frame rates, or frames-per-second.

Faces

The triangles that make up a 3D model, see 3D Modeling for more information.

Baked Lighting

The lighting effects are calculated once and then applied to the environment and never change. This reduces the computational load while the environment is being used since the lighting does not need to be recalculated.