2012 by Carlos Rafael Giani (e0325834 AT student.tuwien.ac.at , dv AT pseudoterminal.org)
This is zMol, the implementation of the paper "Ambient Occlusion and Edge Cueing to Enhance Real Time Molecular Visualization" , 2006 by Tarini et al. The implementation is designed as a C++ library, which is embedded in other projects. As a demonstration, a Qt4 viewer was implemented, which uses zMol.
The zMol library and the qt viewer are put under the zLib/libpng license (the license text is included).
The Bitbucket repository where the project is hosted is available here.
A copy of the source code is included here locally, in Source/. Click here to access it.
Prebuilt Windows binaries are available in Binaries/. Click here to access it.
(The two links above assume your browser can display the contents of local folders.)
The Doxygen-generated code documentation is available here.
The directory structure is described in more detail below.
The main focus of the zMol library is the impostor-based rendering described in the Tarini paper, together with applied ambient occlusion. Atoms are modeled as quads, which are then filled with sphere shapes that are drawn in a fragment shader. Using impostors drastically increases rendering efficiency, and also eliminates tesselation artifacts. In addition, it allows for easy drawing of depth-aware borders.
The ambient occlusion generation step as described in the paper works in the following way: the molecule is rendered from a point of view, a shadowmap is generated, and projected into a texture atlas. For each atom, a patch exists in the atlas. The patches record the shadowing received by the shadow map. This is done for many different but uniformly distributed directions. The results are accumulated. With enough well-distributed directions, this shadowmapping accumulation produces a result that approximates ambient occlusion.
Another way to visualize this is to imagine for example 100 light sources, distributed uniformly around the molecule. Each light source produces a shadowmap, which is applied to the molecule. The sum of all these shadowmaps is the approximated ambient occlusion.
Projection and unprojection functions described in the paper are used for mapping from/to the texture atlas. The atlas is generated only once, and then used for rendering the molecule to screen. In other words, when viewing the molecule, the atlas is used like a regular texture by the rendered sphere impostors. The impostors are "textured".
Since the atom spheres are impostors and therefore generated, it becomes easy to produce borders. The quads are simply extended by the
desired border width. In the fragment shader, a certain "border" region is established, which is: radius < border color <= (radius + border width)
The border is made depth-aware by extruding it not only sideways, but also to the back. The depth buffer then performs the necessary clipping.
The Qt viewer shows the zMol rendering to the left, and a set of controls to the right. It starts with a test molecule, which is made up of 5 atoms. To the top left, the File menu is placed, "Open" will open a file dialog, which can be used to load PDB Protein Data Bank molecule files. The Samples/ directory contains a few PDB files for demonstration purposes.
The zMol rendering can be rotated by clicking the left mouse button and dragging the mouse.
The following list describes the controls:
zMol was tested with the following configuration: Core i5-2500K 3.30 GHz, 16 GB system RAM, a GeForce GTX 560 with 1 GB GDDR5 video memory, Windows 7 Professional 64-bit. The nVidia drivers version 285.62 were used. Support for OpenGL 3.3 (or newer) is required. The hardware must be able to create 2048x2048 textures, and support the GL_R16 and GL_DEPTH_COMPONENT OpenGL texture formats.
The required C++11 features are:
The source code directory in turn is organized in this fashion: