by Manuel Kröter, 2013
Molecule Viewer is a program to visualize molecules in a 3d rendering. The user can load any molecule file from the Protein Data Bank (http://www.rcsb.org/pdb/home/home.do) with the PDB format.
Many traditional methods to render 3d molecules have the problem that the spatial structure of the molecule can hardly be seen, especially true for large molecules. So the focus of the Molecule Viewer is the better perception of this spatial structure. See the section Functionality in order to see more details how the program works.
The program was implemented during the course "Visualization 2" at the Technical University of Vienna in Spring 2013. It is based on the paper "Ambient Occlusion and Edge Cueing to Enhance Real Time Molecular Visualization", written in 2006 by Tarini et al.
You can see a video demonstration on Youtube.
As stated in the overview, the Molecule Viewer tries to improve the spatial perception of the molecule. One reason for a bad spatial perception is the use of constant value for the ambient lighting. In this implementation the ambient lighting was better approximated by using Ambient Occlusion. In addition to that, depth aware contour lines are used to further enhance the result.
Besides the focus on the spatial perception, the rendering should be done efficiently in real-time. The only geometry used to model a molecule are spheres for each atom. Tarini et. al. propose the use of 2d impostors for the atoms of a molecule, so no 3d meshes or something like that are used.
At the center of an atom one point is drawn and then transformed to a quad in the geometry shader. These quads are then transformed to spheres in the fragment shader. Since a sphere is well known, the correct depth and surface normal can be reconstructed easily depending on the distance of the current fragment to the center. If the distance to the center is larger than the radius, the pixel is discarded completely. For shadow mapping it is not even needed to reconstruct the depth and normals, because only the mid surfaces are responsible for casting the shadows. So it is very fast and efficient to render depth maps.
The ambient lighting of a point on the surface of a sphere is approximated by determining which percentage of the hemisphere above this point is occluded. If everything is occluded the ambient term is 0 and it increases with the molecule being less and less occluded. Now the occluded percentage has to be approximated as well.
One can think of this process as follows:
The molecule is lit by multiple lights which are distributed uniformly around the molecule. Each of these lights contribute to the ambient term of a surface point if they can directly illuminate it. The exact contribution also depends on the light direction and the surface normal of the sphere at that point (the cosine of the angle between the two vectors is used). If the hemisphere is more occluded, less lights can directly illuminate the sphere surface point.
In the implementation it is solved using shadow maps and a ambient occlusion texture:
The two dimensional ambient occlusion texture should contain the ambient lighting for all points of the molecule at the end. Each atom/sphere of the molecule is assigned a patch in this texture. Through a projection each point on this sphere is assigned a small area in this patch.
The molecule is rendered from multiple different view points (which have to be uniformly distributed around the molecule). For each view point it is rendered twice:
Then go on with the next point of view. When finished, the texture can be used to look up the ambient lighting during the normal render pass using the inverse projection to get back from the ambient texture coordinates to the sphere point. The ambient term has to be computed only once after the molecule was loaded.
When using depth aware contour lines, the width of the contours around the spheres depend on the depth difference to next sphere lying behind the current one. If there is no sphere behind (only background behind the sphere), the width of the contour is maximal. If there are two spheres intersecting, there should be no contour line at the intersection. So the user can see the difference in depth through the width of the contours, which enhances the spatial perception.
Since imposter based rendering is used, and therefore the spheres are "produced" in the fragment shader, it is easy to add depth aware contours. The 2d quads are just made a little bit bigger, the fragment shader can then add a border around the sphere with a given width. All pixels with a certain distance to the center of the sphere belong to the contour and are drawn as black pixels: (radius + contour width) > contour distance > radius.
Download and extract
program. Then go to folder "bin" and run "MolView.exe" to start the
program.
The molecule is rendered at the left side of the window, the current settings can be seen and changed at the right side. To load a molecule, go to File and then Load Molecule. Choose any valid file in the PDB format and the molecule will be loaded. This can take some time because the ambient lighting/ambient occlusion is precomputed at this stage. PDB molecule files can be found and downloaded at the Protein Data Bank. A few PDB files are already provided and can be found in the "samples" folder.
Interactions with the molecule
Render
Settings
Following settings can be modified to affect the way the molecule is shown: