# VRChem: A Virtual Reality Molecular Builder
## 2 Implementation
### Software Structure  
VRChem is based on the Unity 3D game engine for core functionality and rendering. The Unity engine has good computational and memory performance and visual quality for our demands, and is widely supported by VR system developers and other third parties. The scripting language used in the project was C#, which was advantageous for its.NET underpinning and thereby supports other third-party software and APIs based on the.NET framework. Unity also has a plugin system and digital storefront for extending the engine's functionality, which was used to integrate several plugin packages. Most notably, a Virtual Reality ToolKit (VRTK) plugin provides support for most HMDs with minimal additional configuration; an official plugin for the Vive HMD is used to support some features specific to the device; and a Leap Motion plugin allows access to the Leap Motion hand tracking data and enables configuration of customized gestures. Additionally, a.NET wrapper for the OpenBabel [36] chemistry toolkit is included for integrating some of OpenBabel's features into VRChem. VRChem was developed for and tested in a Windows environment with the HTC Vive VR system, but should be capable of running on other platforms and VR devices with small changes.  
A detailed description of the software structure falls outside the scope of this article, though it is open for examination in the form of open-source code. One implementation detail that warrants discussion is that we chose to handle each atom and bond as a separate Unity object. Unity objects each have a location, rotation and belong to a hierarchical object tree, and are essentially containers for Unity components that determine the functionality of the object. Unity components are properties such as 3D meshes, collision meshes for physics calculations, rendering instructions and sound emitters. Including each atom and bond as separate objects simplifies the program structure and is easier to maintain, but can lead to reduced performance when rendering large molecules. In VRChem, each atom and bond is a separate object and has a separate ball or cylinder mesh, material and instructions for rendering, increasing the draw call count. VRChem uses geometry instancing with an instanced shader and object batching to reduce the draw call count, but with large molecules, the number of draw calls is expected to rise to a level where performance is affected and the application framerate drops below a comfortable level. Therefore, VRChem might not be suitable for, e.g., displaying large biomolecules, in its current state, and exploring other rendering alternatives is likely necessary to achieve greater performance. Quadric surface rendering [43] and the billboard rendering technique used in, e.g., QuteMol [44], are prime candidates for this. However, a laptop meeting the minimum performance requirements for VR use (4 core Intel i5 7300 HQ 3.5 GHz, 8 GBDDR4 2133 MHz, Nidia GTX 1060 3 GB) running VRChem manages to render scenes with 5000 bonded atoms without performance issues. The performance is considered adequate for a program focusing mainly on building molecular models by hand.