scieee AI-readable full text Open interactive document viewer

Interacting with molecular models in virtual reality

Giralt Garcia, Oriol

Abstract

Molecular visualization software is an upcoming and growing sector than it's tracing its path thanks to the incoming technologies. Not only allows to compute time-consuming CPU and GPU programs and renders in lesser time, but also introduces more complex and complete visualization methods that allow

Full text

Interacting with molecular models in virtual reality Oriol Giralt Garcia 17/4/2019 Universitat Politècnica de Catalunya ORIOL GIRALT 1 Index 1. Context and scope of the project 4 1.1 Prelude and problem formulation 4 1.2. Introduction to the biomolecular world 5 1.3. Rendering techniques 8 1.3.1. Space-filling 8 1.3.2. Ball & Sticks 9 1.3.3. Ribbons 9 1.4. Scope and methodology 10 1.5. Stakeholders 12 1.5.1. Project developer 12 1.5.2. Director and co-director 12 1.5.3. Beneficiaries 12 2. Project planning 13 2.2. Task description 13 2.2.1. Acquire knowledge about molecular dynamics and Unity engine 13 2.2.2. Build a PDB file parser 14 2.2.3. Use of sphere Impostor and GPU rendering techniques in Unity 14 2.2.4. Implementation of the basic visualizer 15 2.2.5. Incorporation of Virtual Reality’s interaction tools 15 2.2.6. Final implementations and optimizations 16 2.3. Gantt chart & Estimated time 16 2.4. Obstacles and action plan 18 2.4.1. PDB complexity 18 2.4.2. Impostor rendering problems 18 2.4.3. Bad code implementation 18 2.4.4. Unavailability of the HTC Vive Glasses 19 3. Budget and sustainability 20 3.1 Current domain of sustainability 20 ORIOL GIRALT 2 3.2. Budget estimation 21 3.2.1. Hardware resources budget 21 3.2.2. Software resources budget 21 3.2.3. Human resources budget 22 3.2.4. Total budget 23 3.3. Sustainability analysis 23 3.3.1. Environmental impact study 24 3.3.2. Economic impact study 25 3.3.3. Social impact study 26 4. Rendering molecular geometry 28 4.1. Complexity of rendering a sphere 28 4.2. Billboard Impostor 30 4.2.1. What you see is a lie 30 4.2.2. Impostors 32 4.2.2.1. Vertex shader overview 34 4.2.2.2. Fragment shader overview 35 4.2.3. Correct guidelines 37 4.3. Other rendering techniques: GPU Instancing 44 4.3.1. Overview 44 4.3.2. Proper Instantiation 46 4.4. Techniques performance & comparison 49 4.4.1. Testing the rendering techniques 49 4.4.1.1. Medium plane performance test 51 4.4.1.2. Far plane performance test 51 4.4.1.3. Close plane performance test 52 4.4.2. Performance test conclusions 53 5. Large molecular models design 55 5.1. Rendering molecular models on Unity Engine 55 5.1.1. Data model overview 55 5.1.2. Building the PDB parser 56 5.2. Molecular bonds computing 58 5.2.1. Rule-based algorithm for bond computing 58 o Identification of bonded atoms 58 ORIOL GIRALT 3 o Over-connected correction 59 o Fixing disordered bonds 60 5.2.2. K-d tree algorithm 60 5.2.3. Runtime performance comparison 63 5.3. Silhouette rendering 64 5.3.1. Overview 64 5.3.2. World Space Silhouette rendering 65 5.3.3. Silhouette performance test 66 6. Interaction with Molecular Models 68 6.1. Introduction 68 6.1.1. Introduction to Unity framework and tools 68 6.1.1. GUI introduction 68 6.1.2. Establishing a Three-tier Architecture 69 6.1.3. Multiple SDK supporting 71 6.2. Defining our GUI 72 6.2.1. First GUI contact 72 6.2.2. GUI events description 75 6.2.2.1. Left Controller event description 75 6.2.2.2. Right Controller event description 80 6.3. Masking Technique 93 6.3.1. Dynamic clipping plane 93 6.3.2. Masking Events Description 95 7. Conclusions 96 7.1. Summary of the project 96 7.2. Future research 98 7.3. Concluding statements 100 8. Bibliography 101 ORIOL GIRALT 4 1. Context and scope of the project 1.1 Prelude and problem formulation Since immemorial times that humans have asked the question of what we are made of. The term atom comes from the Greek "atomon" which is the union of two terms; <<α>> (a) that means without and <<τομον>> (tomon) which denotes division, meaning than something is indivisible, that cannot be divided.1 The concept of atom as a basic and indivisible block that composes all the matter of the universe was postulated in ancient Greece in the 5th century BC. As well as the modern concept of molecules. Later, in the early nineteenth, the concept gained a broad scientific acceptance when a big number of discoveries in the chemistry field demonstrated that the surrounding materials really behaves as if they were composed of atoms. Thanks to these discoveries and the great technological advances that we have experienced in the recent decades, the molecular dynamics field was born. Molecular dynamics are methods of computing simulations of the physical movements of atoms and molecules, and the interactions between them. These simulations are used, among other things, in chemical physics, materials science, and the modelling of biomolecules. One of the main problems that the molecular dynamics present is that the computation of dynamic molecular simulations can be a complex and time-consuming process. The results generated by molecular dynamics techniques are usually composed of thousands of elementary steps, which can reach the number of gigabytes of data from our memory Figure 1 Democritus was an Ancient Greek pre-Socratic philosopher primarily remembered today for his formulation of an atomic theory of the universe. ORIOL GIRALT 5 for each simulation and, despite of the techniques of optimization of these methods, analysing the results can take several days.2 Providing new tools and techniques to visualize and interact with simulations provided by molecular dynamics are key to understanding a bit more the atomic and molecular world. The main objective of this project is to build a molecular visualizer in virtual reality where the user can interact with the molecule and visualize it in the most common methods of molecule representation. Another aim of this project is to implement algorithms and optimizations than will enhance the performance of its rendering, allowing to visualize in a clear and stable way each part of the molecule without compromising the system. We will also build a parser than the visualizer will use to read any protein dat49se file format (.pdb) and will parse it to C# classes. The parser will read all the information about the molecule structures as well as the atomical information and will calculate its bonds. Furthermore, we will implement an attractive, consistent and clear user interface controlled by the virtual controllers in which the user will interact with the molecule in an attractive way. The virtual reality controllers will be working fluently and no molecule part will be unable to select. The user will be able to walk through the molecule and observe all the atomically parts and bonds of the molecule in a complete peripherical view. The designed user interface will be userfriendly and easy to use, facilitating the user’s experience. There will not be any bug in the visualizer that could damage the user experience. 1.2. Introduction to the biomolecular world During this chapter we will make a brief introduction to the biomolecular field in order to acquire some basic knowledges so the reader can understand and follow the methodology that will be taken on term during this project. Firstly, we will define what a molecule is. A molecule is an electrically neutral group of two or more atoms held together by chemical bonds3. One of the most common ORIOL GIRALT 6 molecules are the proteins. A protein is a large macromolecule made by the union of amino acids through a peptide bond4. Those amino acids than make up the molecule are organic compounds that can be composed by carbon, oxygen, nitrogen, hydrogen and, in some cases, sulphur.6 We can classify the atoms of each amino acid into subgroups depending of its structure. Those groups are the group of the amines, the group of carboxyl and the group of sidechains. The sidechain is the only group that varies between amino acids and determines its several properties.5 Analogously, we can classify the amino acids according to the type of interaction. The main groups are the hydrophobic, hydrophilic, charged amino acids and the amino acids without sidechain. The hydrophobic amino acids have carbon-rich side chains, which don’t interact well with water. The hydrophilic or polar amino acids interact well with water. Charged amino acids interact with oppositely charged amino acids or other molecules.6 The major parts of the proteins can fold into unique structures allowing the free rotation of its atoms. The way a protein its fold on his natural state is known as native state. Although many proteins can fold thanks to the chemical properties of its amino acids, there are many than require help of the chaperone proteins in order to acquire his native states. The biochemists, usually refers to four different aspects of the main structure of a protein:7 · Primary structure: The primary structure of a protein is the linear sequence of amino acids as encoded by DNA. The amino acids are joined by peptide bonds, which link an amino group and a carboxyl group and a water molecule is released each time a bond is formed. The linked series of carbon, nitrogen, and oxygen atoms make up the protein backbone. Figure 2 Graphical representation of an amino acid. The bound between the oxygen atoms (red) with the hydrogen atoms (white) represents the amino group while the bound between the nitrogen (blue) and the two hydrogens represents the carboxyl group. Both are connec-ted with the sidechain y a carbon atom (grey). ORIOL GIRALT 7 · Secondary structure: The protein chains often fold into two types of secondary structures: alpha-helices, or beta-strands. An alpha-helix is a righthanded coil stabilized by hydrogen links between the amine and carboxyl groups of nearby amino acids. Those hydrogen links are called hydrogen bonds. Beta-strands are formed when hydrogen bonds stabilize two or more adjacent strands. · Tertiary structure: The tertiary structure of a protein is the threedimensional shape of the protein chain. This shape is determined by the characteristics of the amino acids making up the chain. Charged amino acids allow proteins to interact with molecules that have complementary charges. The functions of many proteins rely on their threedimensional shapes. For example, haemoglobin forms a pocket to hold heme, a small molecule with an iron atom in the center that binds oxygen. · Quaternary structure: Two or more polypeptide chains can come together to form one functional molecule with several subunits. For example, the four subunits of haemoglobin cooperate so that the complex can pick up more oxygen in the lungs and release it in the body. Figure 3 Diagram of the four levels of the protein structure. ORIOL GIRALT 8 1.3. Rendering techniques In this chapter we will discuss and review the most notorious work made on the molecule’s representation. Furthermore, we will explain the use of that models and will indicate its major shortcomings. 1.3.1. Space-filling The Space-filling, also known as a calotte model, is one of the most common methods used to visualize molecules. This model represents each atom of the molecule with a sphere. The sphere size will be determined by the element’s van der W35s radius of the atom, which radius represents the distance of closest approach for another atom8. Space-filling models can be also referred to as CPK models. The good point of the Space-filling models is that they are useful for visualizing the relative dimensions of the molecule, and the effective shape the molecule might present. On the other hand, as we said before the radius of the sphere will be defined by a half of the distance between the closest approaches of the two non-bonded atoms of a given element. This means than the chemical bonds between the atoms are going to be masked and will make difficult to see the structure of the molecule. This is the reason why such models will have a better performance if they can be used dynamically 9. Figure 4 Space filling model with conventional atom color-coding of a Toll-like Receptor (TLR4). ORIOL GIRALT 15 to render. The idea is that we're actually drawing a square, but we use the fragment shaders to make it look like something else [21]. To implement this technique, we will follow a reference of this technique implemented in OpenGL [22] and will try to apply it in Cg Language in Unity as well. We will also apply some rendering techniques such as the Phong Shading. Additionally, it would be appropriate to build a Tester scene where a boatload of impostors is rendered and implements GPU instancing in order to render the same mesh multiple times in one go [23]. The Scene will also show the graphical statistics, allowing us to get a clear knowledge of our capacities and limitations. 2.2.4. Implementation of the basic visualizer When the parser and render techniques tasks are over, we will be ready to build the visualizer. This task will consist on building a molecule visualizer that will be able to read any .pdf file from the computer and represent it Space-filling and Ball & Sticks graphical representations, as well as other molecule properties such as its residues. 2.2.5. Incorporation of Virtual Reality’s interaction tools This task consists of implementing and providing the tools than the User will use to interact with the molecule projection. The developer will have to upgrade the first version of the visualizer and make it VR ready, allowing the usage of the VR glasses and the VR controllers in order to interact with the molecules allowing him to rotate, expand, mask or visualize each atom and chain of the molecule. The visualizer will present a well implemented an easy to understand users’ interface and will allow us to interact with the three different molecular representations, each with its unique characteristics. The controllers will be fluent and will facilitate the selection of all the molecule parts and components. For this task we will require of the HTC Vive glasses resource as well as VR ready graphical card. Figure 7. An HTC Vive Headset with two wireless handheld controllers and two base stations. ORIOL GIRALT 16 2.2.6. Final implementations and optimizations The final task workload will be conditionate by the amount of remaining time than we will have. A bigger timeframe will allow to the developer to try to implement some extra techniques to the project such as ambient occlusion or other shading techniques such as toon shading. Also, some we will try to implement some final GPU rendering optimizations. Furthermore, a series of test programs will be implemented in order to debug the project from possible errors and bugs, so the current code is refined. Additionally, the profiling of the data of each project step and test will be captured in order to see the performance improvements of our project. 2.3. Gantt chart & Estimated time The Gannt chart is a graphic tool that illustrates your project schedule and the relationships between the activities and the current project status. We have used the free source software teamgantt[24] in order to make our Gantt chart: Figure 8. Screen capture of teamgantt web source software. The interface shows a calendar where each task is represented by colored bars. The width of the horizontal bars in the graph show the duration of each activity and its dependencies are marked with connected segments. ORIOL GIRALT 17 If we establish an approximated duration in hours of each task represented in our Gantt chart, we could estimate the overall duration of our project: Estimated duration (h) Background in molecular dynamics 50 Background in Unity 30 Background in Cg Language 15 Parser Setup 50 Molecule Impostor Setup 70 Molecule Projection Script 120 Molecule Halo Script 25 VR interaction tools 90 Final optimization / implementations 50 Documentation and presentation 60 Total 560 Table 1. Estimated duration in hours of the proposed tasks based on the Gantt chart. ORIOL GIRALT 18 2.4. Obstacles and action plan The methodology that we have chosen in order to realize the practice allow us to have a great planification of our time and have a good range view of our schedule. We could adapt our change any of our tasks if required and modify dynamically our schedule. However, there is the possibility than a hypothetical task lasts more than we expected, delaying the others. In this case we need an action plan in order to find an alternative solution so we can shorten the working time and we could be able to start with the upcoming task on time. In this section we are going to talk about which are the potential problems and deviations we could experience during the project realization and which is the best action plan to solve it. 2.4.1. PDB complexity Considering the great complexity than some proteins present, there is a possibility that we could not be able to parse correctly the information of the molecule. If there are only problems with the most complex proteins, we could ask for help to our director but, if not, there is the alternative plan to parse another PDB file which is coded in XML. An appropriate XML parser could convert this information for us with more ease. 2.4.2. Impostor rendering problems It could be than, for some reason, we are not able to implement the impostor technique in the unity shaders. In this case, we could build up a sphere out of a cube. The implementation of the shader could be easier. 2.4.3. Bad code implementation During the implementation of the project, we have to be care with the code optimization. A bad optimization of our resources could increase exponentially. An ORIOL GIRALT 19 exhaustive series of tests will be done in order to constantly check that our code is refined and efficient. 2.4.4. Unavailability of the HTC Vive Glasses The high demand of the Google glasses at the University could delay our project debug and test during specially during our last stages. The lack of the glasses could cause a great delay to our project schedule. In this case, we will need to try to have always some HTC Vive glasses available and a computer with a VR ready graphic card. ORIOL GIRALT 20 3. Budget and sustainability 3.1 Current domain of sustainability Before starting this section, we are going to make a brief self-analysis of the sustainability of our project. In order to achieve a complete self-analysis, we will make a survey1 which include a broad definition of sustainability that includes its three dimensions: social, environmental and economic. To understand more clearly the dimensional impacts of our project we have to look back on who are the beneficiaries of it; the biologists and investigators. The development of a new way of visualize the molecular structures that are registered by the whole community of biologists and investigators, could mean a big impact in the social and economic. Firstly, the improvements of the investigation tools would potentiate the possibility of new discoveries and inventions, providing a better acknowledgement of ourselves and the world composition and giving us new methods to develop new tools and ways to cure many different diseases that would decrease the population mortality while would improve the welfare state. Another important point to analyze is the economic impact that our project will have. The economic management knowledges provided during the lecture course of the degree, will give us the tools in order to execute a properly management of our resources and our fuds so we that we have the most optimal financial amortizations and benefits, allowing us to maximize the economic benefits. Despite the social and economic strength of our project, we must not forget the environmental impact. The fossil fuels and chemicals that are used in order to build the chipsets have a huge negative impact in our environment, putting in danger the wellbeing of living creatures of the planet. One we conclude the survey we can conclude that we should take a brief look of the contamination and impact of the modern computers and technologies on the world. ORIOL GIRALT 21 3.2. Budget estimation In this section we are going to estimate the budget cost of the project. We are going to divide the budget in different sections, depending on the type of resources we are taking into account, and we will estimate the costs of each one. Finally, we are going to estimate the final budget of the project by combining the previous budgets. If we take into account the fact than our project will last for six months approximately and we estimate a useful life for each resource, we could calculate an approximate amortization of the project. 3.2.1. Hardware resources budget The hardware resources budget is strictly composed by the hardware components than we will use for the realization of this project. The estimated useful life of each one is established to four years. After that period the hardware will mean to be obsolete. Product Useful Life Price (€) Amortization (€) HTC Vive set 4 years 699,00 € 87,38 € VR-Ready PC 4 years 877,24 € 109,65 € Hardware peripherals 4 years 75,00 € 9,35 € TOTAL 1.651,24 € 206,38 € Table 2 Hardware resources budget. 3.2.2. Software resources budget The hardware resources summarize the costs of the software we are going to need in order to develop the project. The estimated useful life of the life and the established price of each license software will be estimated to four years as well. ORIOL GIRALT 22 Product Useful Life Price (€) Amortization (€) Windows 10 home 4 years 145,00 € 18,13 € Github 4 years Free Free Visual Studio Professional 4 years 1 756,30 € 219,54 € Unity Software 4 years Free Free TeamGantt 4 years Free Free TOTAL 1.901,3 € 237,67 € Table 3 Software resources budget. 3.2.3. Human resources budget The human resources budget is composed by the group of people required to develop the project. Despite the entire project is fully developed by only one person, we will suppose than the team is composed by four main roles; the project manager, responsible only of the project planning. The software designer is going to do the task related to designing software, taking into account the user’s needs and the algorithm complexity of the program. The software programmer will be the responsible of implementing all the required implementations proposed by the software designer. Finally, the software tester will be the responsible of elaborating stupas and performance and usability during the developing and final stages of the project. The total elapsed time of human resources work will be the same than the established time in the Table 1. Table 4 Human resources budget. Time Cost per hour (h) Cost (h) Project manager 95 h 40,00 h 3.800,00 € Software designer 145 h 30,00 h 4.350,00 € Software programmer 150h 20,00 h 3.000,00 € Software tester 100 h 15,00 h 1.500,00 € TOTAL 490,00 h 12.650,00 € ORIOL GIRALT 23 3.2.4. Total budget The total budget cost will be composed by the sum of the results of the Table 2, Table 3 and Table 4. Concept Cost Hardware resources 206,38 € Software resources 237,67 € Human resources 12.650,00 € TOTAL 13.094,05 € Table 5 Total budget cost. 3.3. Sustainability analysis Nowadays, a sustainability report is a must in any technological project. There are many different ways we could proceed, but in our project, we will use the sustainability matrix, where the project production (PP), the useful life and the dangers of our FDP will be contrasted with the three sustainability dimensions: the environmental dimension, the economical dimension and the social dimension. The following figure shows the results of this analysis: PP Exploitation Risks Environmental Consumption design Ecological footprint Environmental risks 6 : 10 11 : 20 -9 : -20 Economical Project Bill Viability plan Economic risks 6 : 10 15 : 20 -3 : 20 Social Personal impact Social impact Social risks 7 : 10 18 : 20 0 : 20 Sustainability range 19 : 30 44 : 60 -12 : -60 51/90 Table 6 Sustainability matrix of the project. This matrix is based on the ideas of "The economy for the common good" by Christian Felber.[26] ORIOL GIRALT 24 3.3.1. Environmental impact study The consumption design represents the impact of the environment along the realization of the FDP providing the energetical costs as well as the number of residues generated. For the correct development of the consumption costs, we will estimate the Kw consumed in the elapsed time of our project. We should have in mind that the consumption values will be approximated and the results could vary depending on the computer hardware or the elapsed time of work during the day. Therefore, to get an estimated value of the consumption, we will say that, during the approximated 140 days that will lasts the project, the 25% of the time the hardware will be working, the 15% will be on power safe mode and the rest of the time the hardware will be turned off. Additionally, we will suppose that for each hour, our hardware consumption (composed by the computer setup and the VR setup) will be 80.6W when they are turned on, 29,4W when they are on power mode and 5,1W when they are off 2. If we suppose this value, we could make an approximated estimation of how many W h we will spend during the project: Estimated cost day(W*h) = 24h*(0.25*80.6W+ 0.15*29,4W+0.6*5.1W) = 662.88 W h Estimated cost of the project (W*h) = 140 days * 662.88 W h = 92.8 kW h The ecological footprint means the consumption impact that the FDP will have during his useful life. The estimators used to measure the footprint will be the same of the consumption design. If we take the previous results and we suppose a utility life for the hardware setup of 4 years, we will get the approximated consumption cost: Utility life cost (W*h) = 4 years * 365 days * 662.88 W h = 966,649 MW h The environmental risks are the set of eventualities that could aggravate the environmental impact. Computers and its components are made of heavy metals and dangerous chemicals. These metals and chemicals contribute to global warming and also it causes water contamination and air pollution. Furthermore, there is a lot of people than makes a living of collecting these materials and exposing themselves to ORIOL GIRALT 31 the object’s image does not entirely cover the quadrilateral. We could list the different types of billboards based on the three vectors of interest; the up vector, normal and rotation vector (perpendicular to up and normal). In our case we are interest on the axial billboards, in which the textured object does not normally face straight toward the viewer. Instead, it is allowed to rotate around the whole world-space axis and align itself to face a viewer as much as possible within this range[28]. Now that we got some acknowledgements, we can procedure to properly define what is an impostor. An impostor is a billboard that is created by rendering a complex object from the current viewpoint into an image texture, which is mapped onto the billboard. The impostor can be used for a few instances of the object or for a few frames. The impostors are useful for rendering distant and numerous objects rapidly, since a complex model is simplified to a simple image. A possible alternative could be to instead use a minimal level of detail (LOD) model. However, such simplified models often lose shape and color information. Impostors do not have this disadvantage, since the image generated can be made to approximately match the display’s resolution. Figure 10 Impostor example. At the left, an impostor is created of the object viewed from the side by the viewing frustum. The view direction is toward the center, c, of the object, and an image is rendered and used as impostor texture, shown at the right of the figure. At right, the texture is applied to a quadrilateral. The center of the impostor is equal to the center of the object, and the normal (emanating from the center) points directly toward the viewport[aad]. ORIOL GIRALT 32 Before we render the object to create the impostor image, the viewer is set to view the center of the bounding box of the object, and the impostor rectangle is chosen so that it points directly towards the viewport. The size of the impostor’s quadrilateral is the smallest rectangle containing the projected bounding box of the object. The alpha channel is cleared and set to zero, and wherever the object is rendered, alpha is set to 1.0. When the camera or the impostor is moved, the resolution of the texture may be magnified, which may break the illusion. Thus, the impostor image needs to be updated. 4.2.2. Impostors As we know, the two geometrical forms that we will need to represent the molecule and must be impersonated, are the sphere and the cylinder. For spheres and cylinder rendering, a custom vertex and fragment shaders are used in order to achieve it. In case of the spheres, four identical vertices are sent to the GPU corresponding to the center of the sphere, as well as four extra mapping coordinates that represent the corners of the sphere impostor square (-1, -1; 1, -1; -1, 1; 1, 1). The vertex shader then takes each of the four coordinates, transforms them according to the model view and orthographic matrices (to handle rotation and scaling of the model, as well as the rectangular nature of the OpenGL scene), and then displaces them relative to the viewer using the impostor space coordinates so that the square is always facing the user. Figure 11 Process of rendering a sphere impostor[29] Once the square has been generated, every fragment within that square (roughly, every pixel) needs to be colored as if it were from a lit sphere behind that point. For this, the normal of the sphere at that point is calculated as the vector (impostor space X, impostor space Y, normalized depth). The calculation and use of the depth component ORIOL GIRALT 33 are discussed later in the previous chapter. The dot product of the normal and the light direction is calculated and used to determine the strength of the illumination at that point for both ambient light and the specular highlight. The resulting color is written to the screen at that point, except for fragments that lie outside of the sphere, which are output as transparent[29] and therefore, discarted. Cylinders are a little more complicated, but the same general process applies. Four vertices are fed to the GPU (two for the starting coordinate and two for the ending coordinate), along with four impostor space coordinates and four direction vectors that point from the beginning to the end of the cylinder center. The beginning and ending points are transformed at each vertex, then by using the transformed directions the vertices at each end are displaced perpendicular to the axis of the cylinder as viewed by the user. Additionally, the vertices at one end of the cylinder are displaced along the axis to account for the curving out of the cylinder at that end[29]. This is shown in the below figure 12: Like the spheres, the normal at each fragment on the cylinder is calculated to use in determining illumination, but the calculations here aren't as simple as those for the spheres, since the illumination of the cylinder bases are not trivial. Thus, since the bases will be covered by the sphere impostors representing each molecule, we will skip this redundant process in order to simplify the as much as possible this calculus. So, in order to render a cylinder, many values are calculated in the vertex shader for points on the Figure 12 Process rendering a cylinder. See that this render example takes into account the illumination of the cylinder plane bases and our rendered cylinder impostor will not. ORIOL GIRALT 34 center axis, then adjusted in the fragment shader as a function of the distance from the axis. In order to understand the processed previously described, we need to deepen to a more technical description of the processes. Thus, we will analyze the vertex and fragment shader and will talk about the events that are taking part into the process of building a basic sphere impostor. For first version of the vertex and fragment shader, we will try to build the most basic impostor form, keeping the shaders as simple as possible. Moreover, we will talk about its lacks and problems and what we can do to solve it. 4.2.2.1. Vertex shader overview In order to keep the vertex shader as simple as possible, we will not declare any input variable. However, it will still use an input variable: gl_VertexID. This is a GLSL builtin input variable and it contains the current index of this particular vertex, starting the index with zero value and pursuing. Since we are rendering a quad, we render 4 vertices as a GL_TRIANGLE_STRIP. This means the gl_VertexID will vary from zero to three. Because we're trying to render a square with a triangle strip, the order of the vertices needs to be appropriate for this. Thus, we will need a switch case statement that determines which vertex we are rendering and which corner of the impostor we are on. Note that the current index of the vertex and the mapping coordinate of the impostor have to be equivalent to the same corner of the impostor because we will pass to the fragment in which mapping corner coordinate, we are on. Later, on the fragment shader overview we will see why we need it. After determining which vertex to render, we use the radius-based offset value of the sphere as a bias to the camera-space sphere position. The Z value of the sphere position is left alone, since it will always be correct for our square. After that, we transform the camera-space position to clip-space as normal. ORIOL GIRALT 35 4.2.2.2. Fragment shader overview A basic lightning shader equation must need the position and normal value in cameraspace, and the job of the fragment shader it’s to provide them. However, the position and normal of the billboard will not have the same values than the position of normal of the impostor. In order to compute the position and normal, first we need to find the point on the sphere that corresponds with the point on the billboard that we are currently on and, in order to do that, we need a way to tell on which part of the impostor quadrilateral we are. Using gl_FragCoord will not help, as it is relative to the entire screen and we need a value that is relative only to the impostor square. That is the purpose of the mapping variable. When this variable is at (0, 0), we are in the center of the square, which is the center of the sphere. When it is at (-1, -1), we are at the bottom left corner of the square. However, before we start computing the impostor point, we will require of a simple distance check. Since the size of the square is equal to the radius of the sphere, if the distance of the mapping variable from its (0, 0) point is greater than 1, then we know that this point is off of the sphere. If the point is not under the sphere, we will just discard it. The discard keyword is a command exclusive for fragment shaders. It tells OpenGL that the fragment is invalid and its data should not be written to the image or depth buffers. This allows us to carve out a shape in our flat quadrilateral billboard, turning it into a circle. Computing the normal is based on simple trigonometry. The normal of a sphere does not change based on the sphere's radius. Therefore, we can compute the normal in the space of the mapping, which uses a normalized sphere radius of 1. The normal of a sphere at a point is in the same direction as the direction from the sphere's center to that point on the surface. Computing the position is also easy. The position of a point on the surface of a sphere is the normal at that position scaled by the radius and offset by the center point of the sphere. ORIOL GIRALT 36 The computation process can be overwhelming in a three-dimensional space case, but it’s easier to understand if we look at the two-dimensional case. To have a 2D vector direction, we need an X and Y coordinate. On our case If we only have the X, but we know that the vector has a certain length, then we can compute the Y component of the vector based on the Pythagorean theorem: 𝑿𝟐+𝒀𝟐=𝑹𝟐 𝐘= ±√𝑹𝟐 − 𝑿𝟐 As we saw above, we just simply use and upgraded three-dimensional version. We have X and Y from mapping, and we know the length will be always 1.0. Thus, computing the Z value is easy enough. And since we are only interested in the front-side of the sphere, we know that the Z value must be positive. If we take a look at the resulted impostor on the first capture of Figure 14, we can see that our sphere looks simply, but it has a spherical form. This impostor could be useful is someone wants to render a scene with a couple of spherical impostors on the background could be pretty useful, however, what if we try to make a first plane of the impostor or we want to position it on the sides of the camera viewport? In those cases, the impostor is far from being a sphere. Apparently, its looks like the impostor is being clipped in perpendicular cuts from the scene. This makes the impostor useless for the representation of a complete molecule representation, since the size of the molecule could be such big than the atoms would be clipped from the viewport scene. Thus, we need to know why the impostor it’s only portrayed properly if it’s middle Figure 13 Two-dimensional circle point computation schema. As we can see the Radius is equal to the triangle hypotenuse while the X and Y coordinates are the cadets. ORIOL GIRALT 37 centered from a middle plane, and gets clipped gradually if we start to move the impostor to the sides of the viewport or we try to make a first plane from it. In the next chapter, we will talk about why the impostor representation is being clipped and how we can solve it as well as future inconveniences they could appear during the representation of our molecule. Furthermore, we will discuss about the correct chicanery and methods we can use to improve our impostor in order to try to get a representation of a sphere as much real as possible. 4.2.3. Correct guidelines As we know, the proper praxis and manners we employ to implement the algorithms and computations will be the key to reach our objectives as well as implementing an efficient and proper representation of a sphere. Figure 14 First impostor implementation result. The top left capture shows the impostor, camera middle centered from a medium plane. As we see the impostor has an apparently good spherical form and condition. The top right capture shows the impostor, left centered form a medium plane. The results are not as good as expected, since we are not able to see the left-edge of the sphere impostor. Finally, the bottom right capture shows the impostor, camera middle centered from a first plane. As shown, the impostor it’s far away from having a spherical form. This could be a principle than our impostor is too simple. ORIOL GIRALT 38 The first problem that we had was that the impostor was being clipped as soon as is being displaced from de middle centered of the viewport as well as it need to be in a medium or far plane, as it starts to get a quadratically form as soon we start to get a first plane of the impostor. Let’s try to analyze the purpose of our impostor algorithm implemented; we are trying to render a sphere down a flat quad. It could be than the sphere is wider than a simple quad. We did some computations to get the proper Z value of the represented sphere, and we did it in using the camera-space Z direction but, we forgot that the mapping between the impostor surface and the sphere is static; it does not change based on the viewing angle[32] and this is why our computations fail. The problem can look overwhelming, but let’s consider the two-dimensional case represented in the Figure 15. As we see, the sphere representation it’s not completely inside our camera viewing angle. Thus, when we are viewing the sphere off to the camera side centered, such as in this case, we should not be able to see the left-edge of the sphere facing perpendicular to the camera because it’s being clipped. Furthermore, we should see some of the sphere on the right that is behind the plane. Rather than start computing the exact extent of the sphere's area projected onto a square, we can take easier ways such as, for example, it would be much easier if we just Figure 15 Two-dimensional representation of our scene. The dark line through the circle represents the square we drew. The green rectangle represents the camera viewport. Finally, the dashed red line represents the camera viewing angle ORIOL GIRALT 39 make the square bigger. Thus, if we increase the square size a 50%, as we assure that each sphere point will be inside the range. Of course, we will end up rasterizing more than the strictly necessary, but it's overall will be much simpler. However, even though the box correction is going to avoid the sphere impostor clipping, our impostor appearance still looks quite simply, very color saturated and with a poor lightning reflection effect. At this point, we should take a look at our implemented code, and reformulate algorithm math’s. As we know, our algorithm implementation works nice if the spheres are somewhat small represented in the viewport. But if the spheres are reasonably close to the camera, they don’t look like a sphere. This is the most important fact the algorithm has to take into account, since in our viewer, we will want to approach as much as possible to our molecules. Therefore, we will try to ray trace the position and normal of a sphere at a certain sphere point in our algorithm implementation. In optics, a ray is an idealized model of light, obtained by choosing a line that is perpendicular to the wave fronts of the actual light, and that points in the direction of energy flow[34]. Figure 16 Two-dimensional representation of our scene. The pixel point will be the pixel represented in the window’s image. The ray traced is represented in full gradient orange for the frontwards cast and a doted orange line for the backwards cast. Each scene object will be intersected twice. The rendered solution will be the first impostor hit. ORIOL GIRALT 40 In computer graphics, it works by tracing a path from an imaginary eye (camera) through a particular pixel in a virtual screen, and calculating the color of the object visible through it. In our case, we will not be implementing a full ray tracing algorithm; instead, we will use it only to get the position and normal of a sphere at a certain point. As we have defined before, a ray is a line, therefore it will have a position and direction. In addition, it also means that this line will have an infinite number of points. Thus, each point can be expressed with the following equation: 𝑷 󰇍 󰇍 (𝒕) = 𝑫 󰇍 󰇍 󰇍 󰇍 𝒕+ 𝑶 󰇍 󰇍 𝑫 󰇍 󰇍 󰇍 󰇍 =𝑹𝒂𝒚 𝑫𝒊𝒓𝒆𝒄𝒕𝒊𝒐𝒏 𝑶 󰇍 󰇍 =𝑹𝒂𝒚 𝑶𝒓𝒊𝒈𝒊𝒏 For each fragment call, we want to detect the point which it hits the sphere, if any. If the ray intersects the sphere, then we use that point and normal for our lighting equation. Given a sphere radius 𝑹, we know every point 𝑷 󰇍 󰇍 will be from a distance 𝑹 from the sphere center. Therefore, the equation for computing the points located on the sphere could be like: ‖𝑷 󰇍 󰇍 − 𝑺 󰇍 󰇍 ‖= 𝑹 𝑹=𝑺𝒑𝒉𝒆𝒓𝒆 𝑹𝒂𝒅𝒊𝒖𝒔 𝑺 󰇍 󰇍 =𝑺𝒑𝒉𝒆𝒓𝒆 𝑪𝒆𝒏𝒕𝒆𝒓 At this point, we can substitute our ray equation for 𝑷 󰇍 󰇍 : ‖𝑫 󰇍 󰇍 󰇍 󰇍 𝒕+ 𝑶 󰇍 󰇍 − 𝑺 󰇍 󰇍 ‖= 𝑹 Our ray traced goes from the camera into the scene and, since we're in camera space, the camera will be at the origin coordinates. Therefore, 𝑶 󰇍 󰇍 will have a value of zero and ORIOL GIRALT 47 However, we are not telling to the shader which array index has to use. Without telling the shader which array index to use, it always uses the first one. Thus, we will only be able to see part of the batched spheres, the first sphere of each batch call (see Figure 21). The array index corresponding to an instance is known as its instance ID. The GPU passes it to the shader's vertex program via the vertex data. It is an unsigned integer named instanceID. We can simply use the UNITY_VERTEX_INPUT_INSTANCE_ID macro to include it in our VertexData structure. It is defined in UnityInstancing, which is included by Unity. It gives us the correct definition of the instance ID, or empty value when instancing isn't enabled [8]. We now have access to the instance ID in our vertex program, when instancing is enabled. However, to make the macro work and get the array index, the instance's array index has to be globally available for all shader code. We have to manually set this up via the UNITY_SETUP_INSTANCE_ID macro, which must be done in the vertex program before any code that might potentially need it. Now, the shader can access the transformation matrices of all instances, so the spheres are rendered at their actual locations. As we mentioned before, one limitation of batching is that they are limited to objects that have identical materials. This limitation becomes a problem when we desire variety Figure 21 Scene capture with the camera focus centered to 5000 spheres. The sphere materials have the GPU instancing enabled. No array index is assigned. As we can see in the statistics table, the batch call number is 42, meaning it rendered 125 sphere per time. Furthermore, we can observe than it made 3.8 million tris calls and 2.6 million vertices calls. Despite we wanted 5000 spheres shown in scene, we can only see a few, concretely 42 spheres. Because we haven’t assigned any index, the shader will only render the first mesh of each batch call. ORIOL GIRALT 48 in the objects that we render. This is our case, since each molecule will have different color types, such by the molecule chain, the residue or the atom type. Instead of creating a new material instance per sphere, we can use material property blocks. These are small objects which contain overrides for shader properties. Alternatively, instead of directly assigning the material's color, set the color of a property block and pass that to the sphere's renderer. This allows us to reuse one block to configure all of our instances. Additionally, the GPU has to know about which property is overriding. When rendering instanced objects, Unity makes the transformation matrices available to the GPU by uploading arrays to its memory. Unity does the same for the properties stored in material property blocks. Like the transformation matrices, the color data will be uploaded to the GPU as an array when instancing is enabled. The UNITY_DEFINE_INSTANCED_PROP macro takes care of the correct declaration syntax for us. Figure 22 Scene capture with the camera focus centered to 5000 spheres. The sphere materials have the GPU instancing enabled. The array index is assigned. Each sphere will have assigned one color randomly. As we can see in the statistics table, the batch call number is 5002, meaning it rendered 1 sphere per time. Furthermore, we can observe than it made 3.8 million tris calls and 2.6 million vertices calls. Even though we have enabled batching for our material, it no longer works. as each now has its own material, the shader state has to be changed for each sphere as well. ORIOL GIRALT 49 4.4. Techniques performance & comparison 4.4.1. Testing the rendering techniques Once we have implemented our molecular geometry rendering techniques, will proceed to perform a series of rendering tests in order evaluate the performance of our previously defined techniques. In order to execute the tests, we will create a new scene with an empty mesh prefab. This mesh will contain a script that will instantiate N number of molecular geometries meshes, each mesh with a random color. The instantiated meshes will not be further than M unity’s scale units from the prefab center. N and M will be variable inputs introduced by the user. Figure 23 Scene capture with the camera focus centered to 5000 spheres. The sphere materials have the GPU instancing enabled. Each sphere will have assigned one color randomly. Unlike the previous scene of Figure 22, material property blocks has been created and color data will be uploaded to the GPU. As we can see in the statistics table, the batch call number is 42, meaning it rendered 1 sphere per time. Material property block batching has been enabled. As we can see, our colored spheres are batched again. ORIOL GIRALT 50 We will execute three different frame-rate performance tests, each test with a different camera plane. The planes will be medium close and far. In all the three tests, the camera will be focusing at the center of the prefab. With these three differenced planes styles, we will be able to see if the bottleneck resides in the vertex or in the fragment shader. We will test the UV-sphere, the billboard impostor sphere, the GPU instancing of UV- Spheres and the GPU instancing of the billboard impostor. We will instantiate 4 different sets of meshes, each with 100, 1000, 5000 and 10000 respectively. This way we will be able to compare them and see which obtains the best performance and which is the best candidate our molecular viewer. The objective of this test is to evaluate the average frame rate (fps) that we obtain in each proposed scene. In order to get the average frame rate, we will capture the scene Figure 24 Three captures of the three test scenes. The top left capture has a medium camera plane; the atom perfectly fits the viewport. The top right capture has a far camera plane; the atom is camera centered and the viewport present margins before arriving the molecule. The bottom left capture shows a close camera plane. The viewport is filled with molecular geometry meshes. ORIOL GIRALT 51 frame rate every second, 100 times. Then, we will compute the obtained average frame rate value. Therefore, the resulted values of each test will be the following ones: 4.4.1.1. Medium plane performance test Table 7 Frame rate table from the medium plane performance test 4.4.1.2. Far plane performance test (fps) 100 1 000 5 000 10 000 UV-sphere 218.1 104.0 34.7 21.4 Impostor 225.5 145.3 60.1 43.8 UV-sphere + GPU Instancing 108.0 141.2 119.4 41.6 Impostor + GPU Instancing 109.7 142.6 121.9 55.5 (fps) 100 1 000 5 000 10 000 UV-sphere 218.9 105.6 45.8 23.5 ORIOL GIRALT 52 Table 8 Frame rate table from the far plane performance test 4.4.1.3. Close plane performance test Table 9 Frame rate table from the close plane performance test Impostor 228. 147.6 66.1 49.7 UV-sphere + GPU Instancing 110.3 146.0 130.1 53.2 Impostor + GPU Instancing 109.4 146.7 135.4 68.1 (fps) 100 1 000 5 000 10 000 UV-sphere 220.0 104.5 44.1 18.8 Impostor 224.3 142.9 68.4 41.1 UV-sphere + GPU Instancing 116.6 141.3 124.6 42.0 Impostor + GPU Instancing 108.1 141.8 120.1 50.5 ORIOL GIRALT 53 4.4.2. Performance test conclusions If we take a look at the obtained results, we can see that the billboard impostor gets a clearly better performance than the UV-sphere every aspect. However, despite the impostor gets stunning performance result in low number of instanced meshes, the GPU can obtain better performance than the billboard impostor in large instantiation quantities. Nonetheless, the performance technique test that obtained the best result in high instantiation number was the combination of the billboard impostor with the GPU instancing rendering technique. Despite the performance in fewer instantiation number is worse than the expected, the molecule proteins from the .pdb don’t tend to have such a lower number of atoms and tent to be higher values (closer to the 5000 to 10 000 units). Furthermore, the frame rate still enough to display it fluently and without compromising the system performance or the user experience. Moreover, if we compare the obtained results of each camera plane, we can see than the far plane tests have a better performance than the closer plane tests, which have a worse performance. The difference can be insignificantly in the lower instantiation numbers, but, if we pay attention, we will able to see than this difference on the performance value increases while the number of instances increases. This differentiation increase between the distances of planes can give us a very important hint about whether it would be the bottleneck; in the vertex or in the fragment shader. Since the lower frame rates are obtained in the closer camera plane, we can conclude than the bottleneck will be located at the fragment shader: The closer camera plane will capture a scene where the full viewport will be full of instanced meshes and no landscape will be appreciated on the margins. This means than our viewport screen will be fully painted with our rendered meshes. If we compared with the far camera plane viewport, the far camera viewport will just draw our rendered scenes in the center of our viewport screen, and resulted meshes bounding box will not ORIOL GIRALT 54 even be a quarter of the viewport. Therefore, the closer plane will consume more of fragment shader than the farther plane, since it requires more mesh painting. If we percept a downgrade of the framerate while we are filling the viewport with our instantiated meshes, it means than the bottleneck is situated in the fragment shader and not in the vertex shader. ORIOL GIRALT 55 5. Large molecular models design 5.1. Rendering molecular models on Unity Engine 5.1.1. Data model overview In order to build a reusable and a future expandable project, we will create hierarchical data model that abstracts and formalizes all the information of a molecule and divides it in hierarchical classes. When we are building the data model, we will try to decompose each concept as much as possible as well as we encapsulate each one in order to achieve the maximum concurrence. Figure 25 Diagram of the most relevant classes in the molecular viewer’s data model. As we can observe, the data follows a hierarchical structure form as well as it isolates each class component. The component class diagram representation is sketched with plantUML open source. [aax] ORIOL GIRALT 56 Since explaining each model class and method would be overwhelming, the Figure 25 shows an UML class diagram of the data model in which we will be able to observe each class attributes, as well as the dependency between components. 5.1.2. Building the PDB parser The Protein Data Bank (PDB) is a dat49se for the three-dimensional structural data of large biological molecules, such as proteins and nucleic acids. Biologists and biochemists from around the world submit its research data, making it freely accessible for anyone. The Worldwide PDB (wwPDB) organization manages the PDB archive and ensures that the PDB data is freely and publicly available globally [46]. The file format initially used by the PDB was called the .PDB file format. This original format was restricted to 80 characters per line. Later, an XML version of this format called PDBML, was launched in 2005. However, we will strictly stick to the original .PDB file format. The primary information stored in the PDB archive consists of coordinate files for biological molecules. These files list the atoms in each protein, and their 3D location in space. A typical PDB formatted file includes a large "header" section of text that summarizes the protein, citation information, and the details of the structure solution, followed by the sequence, composed by long list of the atoms and their coordinates. The archive also contains the experimental observations that are used to determine these atomic coordinates. ORIOL GIRALT 63 5.2.3. Runtime performance comparison In order to observe the algorithm performance and visualize the improvements than the k-d tree brings to our bond computing algorithm, we will implement a simple performance test between the k-d tree algorithm and a basic brute force algorithm. In order to perform this test, we will build a simple script that given the number of elements n as input parameter, it will build and array set if size n of random 3-d points, and will find the nearest neighbor of all the elements in the set. This process will be repeated m times, each time with a different set n. the final results will be a regression of each of the obtained execution’s run time values. If we observe the obtained graph representation of the Figure 28, we can see that the results where as we expected. The values have skyrocketed in run time execution when we reached the 64 thousand number of elements, bringing and exponential curve tot the representation. The k-d tree algorithm keeps bringing a stable performance and increments polynomial while we increase the elements number. Figure 29 Performance results of the K-d Tree algorithm (grey) versus the Brute force algorithm (orange). The abscises axis shows the number of elements to perform, represented in thousands (kilos). The ordinates axis shows the run time execution of the algorithms in seconds. ORIOL GIRALT 64 However, we have to take into account that the run time execution of the k-d tree not only includes the neighbor search, but also includes the tree structure creation. This will have a cost of 𝐎(𝒏 𝒍𝒐𝒈 𝒏), the same of the overall cost of every neighbor search. This means the run time execution time of this tests will be a little bit higher since that in our project, the tree would only be built once. Therefore, we can conclude than the k-d tree is a really good optimization for our algorithm implementation; Not only improves considerably the bond’s computation time, but it also can be reusable, since we are building a tree structure than have more utilities rather than bond computing, but also can be used for other future methods and implementations such as group selection or a possible atom scrolling selection etc. 5.3. Silhouette rendering 5.3.1. Overview One of the main techniques that will help the user to interact with the atoms of the molecule will be the silhouette rendering. Here, we will make the use of vertex transformations, which will move each vertex along its surface normal vector to create a larger outline of an object. While this vertex transformation is quite simple, it will be creating a reasonable rendering of the outline. It also requires use of the stencil buffer, which is also discussed. Therefore, we will try to render a world space silhouette shader, which is such efficient that will barely impact our frame-rate. It will create an outline by moving vertices along their normal vector, as well as it will avoid occlusions of the outlined object by its outline. We will also be able to select the silhouette thickness as well as its color. Finally, we will talk about the visual results and will performance a stress test to analyze the impact of the silhouette rendering in our molecular visualizer. ORIOL GIRALT 65 5.3.2. World Space Silhouette rendering As we mentioned before, one method to create a silhouette around an object is to enlarge the object by moving its vertices along their surface normal vectors. Given the position and the normal vector in object coordinates, this we could implement it easily in a vertex shader; The vertex shader will multiply the surface normal vector with the user-specified uniform of the thickness (since it’s a uniform, it will allow an adjustable thickness of the outline) and will add it to the position of the vertex. All these vertex steps will be computed in world space coordinates. One important thing to mention is that this vertex transformation works better with smooth surfaces. To give to the outline the color we will simple return the user-specified uniform of the color in the fragment shader. Such as the silhouette thickness we will be able to customize this color value. The more challenging part of rendering this kind of outline is to avoid occlusions of the outlined object, which are projected by the outline itself: since we have enlarged the object to create the outline, the larger outline will usually occlude the object that we want to outline. On the other hand, the outline should occlude other objects in the background and it should be occluded by objects in the foreground. Therefore, it should behave like any other opaque object, except when it is in front of the outlined object. Figure 30 Two captures of the world space silhouette in a ball&sticks molecular representation. The right capture shows a single silhouette rendered in front of the other geometrical meshes. The left capture shows multiple silhouettes rendered behind the geometrical meshes ORIOL GIRALT 66 If we assume that we first we will render a regular version of the object that we want to outline, and after we will proceed to render the outline, we can state the problem with a couple of steps; the outline should only be rasterized for pixels that are not covered by the outlined object. This way, our problem can be solved with the use of the stencil test. The stencil test is a per-sample operation performed after the fragment shader. The fragment's stencil value is tested against the value in the current stencil buffer; if the test fails, the fragment is culled [43]. The stencil test is used to limit the rasterization to certain parts of the framebuffer; in our case to the parts of the framebuffer that are not covered by the object that we want to outline. Therefore, our strategy will be first marking all pixels that are covered by the object that we want to outline in the stencil buffer. After that, when rendering the outline, we can use a stencil test to rasterize the outline only in pixels that haven't been marked. To mark all pixels that are covered by an object with a value of 1 in the stencil buffer, we can use the ShaderLab syntax provided by Unity in a Pass block before the GLSL implementation starts [43]. 5.3.3. Silhouette performance test As we did in chapter 4.4, we will execute a series of performance tests in order to evaluate the performance of our silhouette rendering technique. We will use the same test scene and the same manners we did in the last performance test. However, we will just execute one performance test; the center plane one. We will not perform the other planes ones since we have determined than the bottleneck was in our fragment shader, and this technique is basically performed in the fragment shader, so there is no chance the bottleneck is moved to the vertex shader. ORIOL GIRALT 67 Therefore, the obtained table is the following one: Table 10 Frame rate table from the world space silhouette performance test If we observe the resulted performance results, we can see than the than the frame rate barely decreases when we instantiate a low number of meshes. However, the framerate drastically decreases as we increase the instantiation number. (fps) 100 1 000 5 000 10 000 No Silhouette 109.7 142.6 121.9 55.5 With Silhouette 107.4 101.0 18.2 8.6 ORIOL GIRALT 68 6. Interaction with Molecular Models 6.1. Introduction 6.1.1. Introduction to Unity framework and tools Unity is a cross-platform game engine developed by Unity Technologies that was released in June 2005. The engine is mainly used to create videogames as well as simulations for many platforms, but the engine utilities can be infinite. Unity brings us the ability to create three-dimensional and two-dimensional scenes, as well as a primary scripting API in C#, including Direct3D, OpenGL, OpenGL ES or WebGL. Unity previously supported other languages such as JavaScript, Boo, but both deprecated in order to prior C# [44]. Unity encompass the Virtual Reality (VR), Augmented Reality (AR), and Mixed Reality (MR) into the umbrella term of XR [44]. Despite we are exclusively using the VR tools, most of the features that Unity offers to us will be referred with the XR term. However, in order to not cause any confusion, we will just refer it as VR term. Unity provides built-in support for a number of virtual reality devices. Its device availability is on a per-platform basis, meaning that not every device is available for every platform. Multiple devices are available on certain platforms, and you can choose which VR devices your app will support from the available list. At runtime, only one device can be active at any given time. However, it is possible to switch between devices if you have chosen to support multiple devices in your application. 6.1.1. GUI introduction A graphical user interface (GUI), is a type of user interface which allows users to interact with objects and devices through graphical icons and visual indicators, instead of text- ORIOL GIRALT 69 based user interfaces, such as typed command labels or text navigation. GUIs were introduced in counterpart of the perceived hard steep learning curve of command-line interfaces (CLIs), which require commands to be typed [49]. Because a GUI is much more visually intuitive, we decided than the interaction with the molecular models will be made with a GUI rather than a typical command line interface. A GUI offers a lot of access to properties and features, in addition, a GUI its more user friendly than a command line, especially for new or novice users, which makes a GUI being used by more users and increasing. Moreover, a GUI has more colors and is more visually appealing, leading to a potential reduction in visual strain. However, each GUI has a different design and structure when it comes to perform different tasks. Even different iterations of the same GUI, can have many different functions and changes, making it ambiguous sometimes. Furthermore, a GUI requires more system resources because of the elements that require loading, such as icons and fonts [50]. Most of the GUIs are rendered in camera space however, we will take advantage of the VR immersion to design a world space GUI which will make the interaction more reciprocal with the molecule and is going to create a more sensation of reality and scene awareness, which we cannot obtain with conventional GUIs. 6.1.2. Establishing a Three-tier Architecture In order to define an efficient GUI, we will need to have the maximum level of concurrence and abstraction from the data model proposed in chapter 5.1.2. Therefore, we will take into practice the Three-tier architecture design pattern. A Three-tier architecture is organized into three major parts; the presentation tier (GUI), the logic or control tier, and the data tier. It follows a client-server structure and all the user, as well as each tier, is developed and maintained as independent modules. ORIOL GIRALT 70 Separating the application graphical user interface and the molecular data model will mean a better load balancing as well as it will make easier to modify or replace any tier without affecting the other ones. This way, any change performed by the GUI will be processed in the logic tier, and therefore forwards to the data model or vice versa. For example, if we want to change the data model of the molecule and add a new hypothetical parameter, it will not affect the control tier and neither the presentation tier Apart from the previously defined advantages, the three-tier architecture is intended to allow any of the three tiers to be upgraded or replaced independently in response to future changes and upgrade implementations. This will allow us to implement future methods by modules and our application will still be functional and any future expansion will not be overwhelming or will require to reformulate the full data structure. Figure 31 Three-tier Architecture diagram. As we observe, the data model and the presentation model are not communicated between each other. The control tier is the intermediary between the two other tiers. ORIOL GIRALT 71 6.1.3. Multiple SDK supporting Nowadays, there are many VR headsets available on the market. However, each headset uses a different SDK. When we are developing our molecular viewer application, we will try to reach the maximum number of developers and researchers. Therefore, we cannot assume that they are going to use the HTC Vive headset as we do. Our application will need to support multiple SDKs. In order to support multiple SDKs, we will make use of the VRTK toolkit [51]. The main feature of VRTK toolkit is the SDK abstraction layer feature; if we use the VRTK input components for our left and right controller’s mechanics of our application, then it will just work on any supported SDK. Therefore, our application will work on SteamVR, Oculus or even PSVR without the need of any extra coding. [52] Furthermore, VRTK offers a VR Simulator that works with the mouse and the keyboard controllers. Furthermore, the simulator provides a device simulation support of any third-parties SDKs. This means a user could test his project methods and implementations without the need of the VR headset. Figure 32 Scene capture of the VR Simulator provided by VRTK tools. ORIOL GIRALT 72 6.2. Defining our GUI 6.2.1. First GUI contact As we know, the VR give us a deeper sensation and awareness of the scene than a conventional screen can offer to us. However, it can also be more ambiguous and some controls and interactions can be confusing. When we are designing a virtual reality’s GUI, the have to make sure than the user is connoisseur of the provided GUI indicators as well as it knows how to use them. Therefore, when the user puts on the VR headset and initialize the application for the first time, he must know which the main interaction tools (haptic controllers) are and where positioned relative to the scene space are. The way we will make the user aware of his inputs will be with a graphical visual indicator, which is a faithful representation of our HTC Vive haptic controllers. Additionally, those graphic controllers indicate which kind of input action the user is making; the graphical indicators will include from the track pad touch and press position to the buttons press & release events to the trigger pressed intensity. Despite we provided to the user a graphical fact of the inputs and events that will take place with the haptic controllers, we still need to provide more information. The quantity of actions than the viewer provides are substantial and the learning curve may be harder than a conventional screen GUI. Thus, we will have to show in a certain way to the user, which are the actions than each input handles. This way the user will perfectly know all the event actions and we will avoid some possible action unawareness or misunderstood. The way we will do it is by building a set of custom controller tooltips prefabs, whose will constantly indicate which action or event is doing each input. Those prefabs tooltips will not be interactable, but will show all possible methods and possibilities the haptic controllers will provide. ORIOL GIRALT 79 o Molecule Transformations Switch Mode -> Grip Button The grip button will trigger between the rotation & altitude and the free translation mode: • The first mode is the rotation & altitude mode. This is the default mode and is composed by two actions transformations, one action for each axis: ▪ The first action, controlled with the X axis, is the rotation. The molecule will rotate to its left relative to the object coordinate’s Y axis if the value is negative. Aversely, it will rotation to its right relative to the object coordinate’s Y axis if the value is positive. The amount of value tracked by the trackpad touch X axis will affect the quantity of rotation degrees; if the value of the X axis is closer to the -1 or 1 values (left & right sides respectively) it will rotate more than a value close to the 0 value (center). ▪ The second action, controlled by the Y axis is the altitude mode. This mode will transform the position of the molecule relative to the vector up (Y axis) in object coordinates. This way we can control the altitude of the molecule. The amount of value tracked by the trackpad touch Y axis will affect the quantity of rotation degrees; if the value of the Y axis is closer to the -1 or 1 values (left & right sides respectively) it will rotate more than a value close to the 0 value (center). This method is designed because the molecules proteins have a wide range of forms and, sometimes, they tend to be really tall, even more than the user. Hence, we can allocate the molecule where we desire and see the full parts and molecule compositions with a full variety of perspectives. ORIOL GIRALT 80 Furthermore, we will be able to observe the tallest parts of the molecule that could be too much higher to see by the user. • The second mode is the free translation mode. In this mode we can freely displace the molecule around the scene. This mode will displace the molecule its X and Z coordinates and will ignore the Y coordinate since we don’t to affect the molecule’s altitude. The Y axis will translate the molecule around the vector forward of the haptic controller. If the value is positive the molecule will move forward. However, if the value is negative the molecule will move backwards. The X axis will translate the molecule around the vector cross of the haptic controller. If the value is positive it will move to the right. Aversely, if the value is negative it will move to the right. o Precision Transformations Mode -> Trigger Button The trigger press will activate the precision mode for molecule transformations: The precision mode is no more than a functionality used along the touchpad touch, which will divide the transformation’s input value to the half. This way we can obtain more precision in our molecule transformations. 6.2.2.2. Right Controller event description o Options Menu / Stored Selection -> Menu Button The menu button will activate the options menu and the stored selection modes: ORIOL GIRALT 81 • The options menu will perform the main interactions and modifications of the molecule’s properties, as well as will be responsible of the application’s settings. The menu canvas will be composed by two main panels; The top and the bottom panels: ▪ The top panel will be composed by three horizontal layered buttons. Those buttons will be the load, properties and settings buttons. The button’s click will alternate the bottom panel between the load, properties and settings panel menus. ▪ The bottom panel will be composed by the load, properties and settings menus: ➢ Load Menu: The load panel menu will be responsible of reading all the filenames of the .PDB folder and then, load them to a button scroll list. It will be composed by the next UI elements: ❖ Button Scroll List: The button scroll list will contain a set of buttons with the label names of all the .pdb filenames, one button for each file. It has two input interactions methods: the Figure 37 Scene capture of the load menu ORIOL GIRALT 82 first one, is using the GUI scroll bar presented at the right of the scroll list. The second one will be through scrolling the touchpad sensor. In the button scroll list, only one button is able to be selected at time. ❖ Select Button: This button, found on the bottom of the scroll list, will be the responsible of loading the .pdb models to our molecule mesh. When the button is clicked, the actual molecule mesh will be cleared and it will be loaded with the molecule with the same filename as the last scroll button is selected. This action will be ignored if the selected model is the same as the actual model. ➢ Properties Menu: The properties menu will be responsible of modifying the molecule’s traits and properties. It will be composed by the following UI elements: ❖ Model Dropdown: Some .pdb files can contain more than one protein models. The model dropdown will load and number all Figure 38 Scene capture of the properties menu ORIOL GIRALT 83 the models that the molecule has. The default loaded model will be the first one. ❖ Amino Ligand Style Dropdown: The main functionality of the amino dropdown will be to alternate through the available primary structure’s representations of the Amino Acids. It has the following possibilities: Spacefill Primary representation. (Default mode) Ball & Stick Primary representation. None Primary representation (Empty). Figure 39 Scene captures of the three different primary representations of the same molecule. The top left capture shows a spacefill representation. The top right capture shows a ball & stick representation. The bottom left capture shows an empty representation of the Aminoacid ligands and a spacefill representation for the Heterogen ligands. ORIOL GIRALT 84 ❖ Hetero Ligand Style Dropdown: As the amino style dropdown, the functionality of the hetero dropdown will be to alternate through the available primary structure’s representations of the Heterogens molecule atoms. It has the following possibilities: Spacefill Primary representation. (Default mode) Ball & Stick Primary representation. None Primary representation (Empty). ❖ Color Group Dropdown: The color group dropdown will be responsible of grouping the atoms in colors depending of the selected clustering mode. The different possibilities are the following: By element/CPK: This mode will color the atoms following the CPK coloring table. (Default mode) By Residue: The atoms will be colored depending of its residue value. There are 25 different colors and they will be alternated making the module of the residue’s order value. By Chain: The atoms will be colored depending of the chain number. There are 25 different colors and they will be alternated making the module of the chain’s order value. Amino/Hetero: The atoms will be colored depending if they are amino or hetero. The amino atoms will be ORIOL GIRALT 85 colored in red, while the hetero atoms will be colored in yellow. ❖ Water Toggle: The water toggle will toggle the water atom’s visibility. If the toggle is on, the water atoms will be active whereas, if the toggle is off, the water atoms will be hidden. The default mode will be ON. ❖ Oxygen Toggle: The oxygen toggle will toggle the oxygen atom’s visibility. If the toggle is on, the oxygen atoms will be active whereas, if the toggle is off, the oxygen atoms will be hidden. The default mode will be ON Figure 40 Scene captures of the same molecule with different coloring set groups. The top left capture presents the CPK color set. The top right capture presents the Residue color set. The bottom left capture presents the Chain color set. The bottom right capture presents the Amino/Hetero color set. ORIOL GIRALT 86 ❖ Restore Default View Button: This button will be the responsible of restoring the default settings of the properties panel. If the button is clicked, the elements will be restored to its default value. ➢ Settings Menu: The settings menu will be responsible of managing the settings value of the molecule & plane transformations. It will be composed by the following UI elements: ❖ Molecule Size Slider: The molecule size slider will be responsible of managing the molecule’s mesh transform size. If the slider value is on the right, the molecule will be bigger whereas, if the slider is on the right, the molecule will be smaller. ❖ Elevation Speed Slider: The elevation speed slider will manage the amount of distance that will take part on the molecule’s altitude displacement. If the slider is on the right, the displacement will be greater whereas, if the slider is on the left, the displacement will be lesser. Figure 41 Scene capture of the settings menu ORIOL GIRALT 87 ❖ Rotation Speed Slider: The rotation speed slider will manage the amount of rotation the molecule will perform. If the slider is on the right, the rotation will be greater whereas, if the slider is on the left, the rotation will be lesser. ❖ Plane Speed Slider: The plane speed slider will manage the amount of distance displaced by our plane culler. If the slider is on the right, the displacement will be greater whereas, if the slider is on the left, the displacement will be lesser. ❖ Plane Size Slider: The plane size slider will manage the size of our plane culler. If the slider is on the right, the plane will be bigger whereas, if the slider is on the left, the plane will be lesser. ❖ Controller Tooltips Toggle: The controller tooltips toggle will toggle the tooltips’ visibility. If the toggle is on, the controller’s tooltips will be active whereas, if the toggle is off, the controller’s tooltips will be hidden. The default mode will be ON. ❖ Restore Default View Button: This button will be the responsible of restoring the default settings of the properties panel. If the button is clicked, the elements will be restored to its default value. The controller tooltip toggle will not be affected. When the menu is active, it will always be located on front of the camera user. If we turn the camera, the canvas will move accordingly. However, when the controller receives a trackpad touch input, the canvas position is blocked and will not be reposition ORIOL GIRALT 88 back to the user’s camera’s the controller until it stops receiving the controller’s input. This way the menu will be displaced while we are changing the parameters of the menu. • The stored selection canvas will be responsible of giving the proper information of the actual molecule’s selection. There are three different possible canvas: ▪ No Selection Canvas: The no selection canvas indicates that no atom or bond is selected. This canvas is composed by a single text label. The text is in bold and with red font color. ▪ Atom Properties Canvas: The atom selection canvas will be responsible of showing the selected atoms properties. It will have the following label parameters: ❖ Index Label: The index label displays the index of the selected atom. ❖ Type Label: The type label displays the element type of the selected atom. Figure 42 Scene capture of the no selection canvas Figure 43 Scene capture of the atom properties canvas ORIOL GIRALT 95 6.3.2. Masking Events Description Once we have toggled and activated the masking mode with the controller’s right grip button, the wireframe plane indicator will appear in front of the user camera, perpendicularly to the forward vector. The plane will follow the user’s displacements or camera movements and will keep its position. The plane is set to a default position but, we can manage the plane’s displacement thought the trackpad sensor touch. The X axis will be ignored. If the tracked value is positive, the masking plane will go forward whereas, if the value is negative, the masking plane will go backwards. The amount of value tracked by the sensor affects the quantity of rotation degrees; if the value of the Y axis is closer to the -1 or 1 values (left & right sides respectively) it will rotate more than a value close to the 0 value (center). ORIOL GIRALT 96 7. Conclusions 7.1. Summary of the project Molecular visualization software is an upcoming and growing sector than it’s tracing its path thanks to the incoming technologies. Not only allows to compute time-consuming CPU and GPU programs and renders in lesser time, but also introduces more complex and complete visualization methods that allow to research and investigate the molecules and proteins in a more interactive and comprehensible way. The recent introduction of the VR to the market is a very important point to remark, since the launched VR technologies are such recent than they lack a reference or even an open source visualizer in the biomolecular and biochemist world that would provide such visualization methods. The VR interaction methods are still on develop and investigation processes and no techniques or standard methods are properly defined yet. However, in this project, we have taken advantage of the recent launch of the commercial VR glasses in order to construct an alternative way to visualize the molecule and protein models. This visualizer not only allows the user to read any molecule from the most common and used codification molecular file types from the biggest molecular dat49se, but also allows to control and modify the molecule properties with a pair of haptic controllers in which the controller ray trace will be the main interaction method. During the process we have developed a strictly project planification that allowed us to achieve our objectives satisfactorily; we have built a complete molecule parser and data model which can read thousands of the mainly three-dimensional structural data for large biological molecules. We have introduced and implemented three different atom and bond geometry representation methods, and therefore, discuss its advantages and drawbacks of each method as well as finding its bottlenecks. We have designed a complete three-dimensional graphical user interface that interacts with the represented ORIOL GIRALT 97 molecule and follows a Three-tier architecture. We have implemented a complete raybased selection technique. Finally, we implemented a dynamic clipping plane than activates and deactivates the meshes based on the relative position of the camera. For the proper accomplishment of the project tasks, we have developed a series of methods and techniques that reduced considerably the render and computing process time. For each technique, we have developed a series of performance and stress tests in order to compare it with other available methods and see its disadvantages and bottlenecks as wells as its strong traits. During the realization of this project, we have accomplished our proposed project objectives; we presented molecular viewer, in which any user is able to properly interact with ease with the molecule while it keeps a well-defined and rendered mesh that reacts to the graphical interface transformations and properties modifications as well as provides comfortable selection and masking techniques. This viewer also provides a fully customizable menu options sets that not only englobes interface properties but also model projection properties. However, we found some troubles during the realization of the project. We encountered really hard problems with the implementation of the billboard impostor technique through Cg Language; it’s basic syntax and depth buffer’s capabilities didn’t allowed us to properly instance the depth value of our impostor mesh. Furthermore, the rupture of the computer’s graphics card that required a replacement of another capable of running the VR system and lately, the temporal unviability of the VR headset has taken us away from our planning and forced us to take alternative path in order to succeed with our objectives. ORIOL GIRALT 98 7.2. Future research Before we initially started our project, we determined a strict schedule for our guidelines to follow. During each step plan, we set a series of restrictions in order to accomplish or goals and objectives. However, we there still certain limitations that impede to our molecular viewer to bring the full potential of our project. If we truly want to offer a complete visualizer, that squeezes all virtual reality’s immersion capabilities as well as brings a full visualization of the biomolecular structures of the actual reference techniques, there are still many methods and implementations and future researches we could make. In this section we will introduce and discuss some possible enhancements that we could implements to our molecular viewer as well as we will deliberate about some possible researches, we could make in order to improve our render and computational performance; Representation of other protein visualization structures: during the realization of this molecular viewer, we have only represented the primary structure of proteins. However, there still many others three-dimensional representations we could render and recreate in our viewer. Those methods are also really important in the biomolecular and biochemical world, and are frequently used by the researchers to interpret and interact with the catalogued molecules. Even though the primary representation was made by some of the most knowing and basic geometrical forms, the other structures requires more complex forms and meshes. We could generate the structure meshes based on the atom’s coordinates and information than we have stored in the file and in the data model. Even we could try to generate an impostor of the hypothetical mesh. Introduction of other selection techniques: In our project we have introduced two different selection techniques. Though, we could still include more methods to make different precision selections. One possible way could be to take ORIOL GIRALT 99 advantage of the k-d tree and implement, for example, to implement a nearest neighbor selection which guided with our trackpad. This obviously means to perform a series of enhancements and operations to or k-d tree algorithm, which will also take into account the slide direction to select the incoming element, taking into account its camera to object transformations, etc. Investigate more molecular geometry rendering techniques: In chapter 4 we introduced and subsequently analyzed and compared many different renderings of molecular geometries that allowed us to make possible visualize huge molecular models such as the proteins. We have discussed the good points and the limitations of each one and, with the results and analysis extracted, we could improve our render performance to increase our frame rate. For example, we could research and investigate how to expand the limitations of the GPU instancing in order to allow to the buffer to include more instanced meshes in order to allow the instantiation of bigger molecular models. Unity has an open source version and it supports a huge active community of developers. As the same way we have implemented the pertinent methods to allow multiple color instantiation, we could research for possible methods we could implement to improve our performance. These are only a few of the possible enhancements and investigations we could perform to our project in order to build, step by step, a more complete molecular viewer. Furthermore, the VR tools and sources are continuously evolving and the incoming community and research investigations are on top of the day. If we keep looking for new articles that are related to the biomolecular and biochemical world, as well as the introduction of new VR interaction techniques, we could take advantage of it and implement it to our project. ORIOL GIRALT 100 7.3. Concluding statements Not all geometry rendering techniques are able to represent the molecular geometries. Molecules has a very high number of atoms and bonds and can be really expensive if we talk about its computational cost. The most well-known used molecular representation technique is the billboard impostor technique. However, there still other viable representation methods such as the GPU instancing. Each method has its strong points and weaknesses nonetheless, the proper implementation and working praxis allowed to our molecular visualizer to perform a real time rendering and visualizations that doesn’t compromise our system performance. The introduction of the VR tools allowed us to implement a deeper and more immersive molecular viewer. A world space GUI not only brings the advantage that doesn’t partially occupy the user viewport, but also leads to a more potentially awareness of the changes produced on the represented molecule. Furthermore, the introduction of the VR trackpads replacing the conventional mouse and keyboard enables a full range of threedimensional space selections as well as a more complete control of the mesh transformations. ORIOL GIRALT 101 8. Bibliography [1] «Átomo», in Diccionario de la Lengua Española (22 ed.). Real Academia Española (2001). [Website]. Retrieved March 1, 2018. [2] Kumari, I., Sandhu, P., Ahmed, M., & Akhter, Y. (2017, August 30). Molecular Dynamics Simulations, Challenges and Opportunities: A Biologist's Prospective. Retrieved April 07, 2018, from https://www.ncbi.nlm.nih.gov/pubmed/28637405 [3] McNaught, A. D., & Wilkinson, A. (2000). IUPAC compendium of chemical terminology (PDF), Cambridge, England: Royal Society of Chemistry. Retrieved March 1, 2018. [4] "Proteïna". Anonymous. Gran Enciclopèdia Catalana (Website), Barcelona, Spain: Enciclopèdia Catalana (1965). Retrieved March 1, 2018 from https://www.enciclopedia.cat/enciclopedies. [5] "Amino acid". Cambridge Dictionaries Online (Website), Cambridge University Press. 2015. Retrieved March 1, 2018 from https://dictionary.cambridge.org/dictionary/. [6] Jessica Mayand and David S.Goodsell. (2017). What is a Protein? (Online Video) ,20 November 2017. Retrieved February 28, 2018 from http://pdb101.rcsb.org/learn/videos/what-is-a-protein-video. [7] D. Voet and J.G. Voet. Biochemistry (Book), 4a ed. John Wiley & Sons, 2010. Retrieved March 1, 2018. ORIOL GIRALT 102 [8] S.S. Batsanov. Van der W35s Radii of Elements (PDF). Inorganic Materials, 2011. pg 1031-1046. Retrieved March 4, 2018. [9] Corey, Robert B.; Pauling, Linus. Molecular models of amino acids, peptides, and proteins (PDF). Review of Scientific Instruments, (1953). pg 621–627. Retrieved March 4, 2018. [10] Olmsted J, Williams GM (1997). Chemistry: The Molecular Science (PDF). Jones & Bartlett Learning. pg 87. Retrieved March 4, 2018. [11] Richardson, Jane S. (2000), Early ribbon drawings of proteins (PDF), Nature Structural Biology, pg 624–625. Retrieved March 5, 2018. [12][13] Bank, R. P. (n.d.). Homepage. [Website]. Retrieved March 10, 2018, from https://www.rcsb.org/ [14] Corey, Robert B.; Pauling, Linus. Molecular models of amino acids, peptides, and proteins (PDF). Review of Scientific Instruments, (1953). pg 621–627. Retrieved March 4, 2018. [15] Olmsted J, Williams GM (1997). Chemistry: The Molecular Science (PDF). Jones & Bartlett Learning. pg 87. Retrieved March 4, 2018. [16] Richardson, Jane S. (2000), Early ribbon drawings of proteins (PDF), Nature Structural Biology, pg 624–625. Retrieved March 5, 2018. ORIOL GIRALT 103 [17] Technologies, U. (n.d.). Unity Manual. Retrieved March 10, 2018, from https://docs.unity3d.com/es/current/Manual/index.html [18] J. F. (n.d.). Unity C# Tutorials. Retrieved March 10, 2018, from http://catlikecoding.com/unity/tutorials/ [19] The Cg Tutorial. (n.d.). Retrieved March 12, 2018, from http://developer.download.nvidia.com/CgTutorial/cg_tutorial_chapter01.html [20] Schawarzer F. A., & Lotan I. IUPAC Approximation of Protein Structure for Fast Similarity Measures (PDF), Computer Science, Stanford University, Stanford, CA. Retrieved March 11, 2018. [21] P. R. (n.d.). Learning Modern 3D Graphics Programming. Retrieved March 8, 2018, from https://paroj.github.io/gltut/Illumination/Tutorial%2013.html [22] P. R. (n.d.) (2012, February 07). Paroj/gltut. Retrieved March 12, 2018, from https://github.com/paroj/gltut/tree/master/Tut%2013%20Impostors [23] Technologies, U. (n.d.). GPU instancing. Retrieved March 12, 2018, from https://docs.unity3d.com/Manual/GPUInstancing.html [24] (n.d.). Models and Structural Diagrams in the 1860s. Retrieved April 08, 2018, from https://webspace.yale.edu/chem125/125/history99/6Stereochemistry/models/models.h tml ORIOL GIRALT 104 [25] (n.d.). Proteins, Scientific figures. Retrieved April 08, 2018, from http://www.wikipremed.com/image_archive.php?code=040101 [26] Allen Sherrod Game Graphics Programming (PDF), Course Technology PTR Retrieved August 21, 2018. [27] Dr. Steve Cunningham Computer Graphics: Programming, Problem Solving, and Visual Communication (PDF), Computer Science Department California State University Stanislaus Turlock, CA, pg 274. Retrieved August 22, 2018. [28] Moller, Thomas Real-Time Rendering, Fourth Edition (PDF), Computer Science Taylor & Francis Boca Raton, CA, pg 559. Retrieved August 22, 2018. [29] Larson, Brad Enhancing Molecules using OpenGL ES 2.0 (Website), published 11 May 2011. Retrieved August 18, 2018 from http://www.sunsetlakesoftware.com/ 2011/05/08/enhancing-molecules-using-opengl-es-20 [30] "Sphere". Oxford Living Dictionaries (Website), Cambridge University Press. 2015. Retrieved February 9, 2018 from https://en.oxforddictionaries.com/definition/sphere [31] "Icosahedron". Oxford Living Dictionaries (Website), Cambridge University Press. 2015. Retrieved February 9, 2018 from https://en.oxforddictionaries.com/definition/ sphere [32] Jason L. McKesson Learning Modern 3D Graphics Programming (Website), published 2012. Retrieved March 23, 2018 from http://www.cse.chalmers.se/edu/year/2018/course/TDA361/LearningModern3DGraphi csProgramming.pdf