International
Tables for
Crystallography
Volume B
Reciprocal space
Edited by U. Shmueli

International Tables for Crystallography (2006). Vol. B. ch. 3.3, pp. 375-376   | 1 | 2 |

Section 3.3.1.5.5. Representation of surfaces by shading

R. Diamonda*

aMRC Laboratory of Molecular Biology, Hills Road, Cambridge CB2 2QH, England
Correspondence e-mail: rd10@cam.ac.uk

3.3.1.5.5. Representation of surfaces by shading

| top | pdf |

Many techniques have been developed, mainly for raster-graphics devices, for representing molecular surfaces and these have been very well reviewed by Max (1984[link]).

The simplest technique in this class consists in representing each atom by a uniform disc, or high polygon, which can be colour-coded and area-filled by the firmware of the device. If such atoms are sorted on their z coordinate and drawn in order, furthest ones first, so that nearer ones partly or completely overwrite the further ones then the result is a simple representation of the molecule as seen from the front. This technique is fast and has its uses when a rapid schematic is all that is required. In one sense it is wasteful to process distant atoms when they are going to be overwritten by foreground atoms, but front-to-back processing requires the boundaries of visible parts of partially obscured atoms near the front to be determined before they can be painted or, alternatively, every pixel must be tested before loading to see if it is already loaded. Not only does this approach give a uniform rendering over the whole area of one atom, it also gives a boundary between overlapping atoms with almost equal z values which completes the circle of the nearer atom, though it should be an arc of an ellipse when the atoms are drawn with radii exceeding their covalent radii.

Greater realism is achieved by establishing a z buffer, which is an additional area of memory with one word per pixel, in which is stored the z value of the currently loaded feature in each pixel. Treatments which take account of the sphericity are then possible and correct arcs of intersection for interpenetrating spheres and more complicated entities arise naturally through loading a colour value into a pixel only if the z coordinate is less than that of the currently loaded value. This z buffer and the associated x, y coordinates should be in picture space or screen space rather than display space since only after the application of perspective can points with the same x / w and y / w coordinates obscure one another.

It is usual in such systems to vary the intensity of colour within one atom by darkening it towards the circumference on the basis of the z coordinate. Some systems augment this impression of sphericity by highlighting. The simplest form of highlighting is an extension of the uniform disc treatment in which additional, brighter discs, possibly off centre, are associated with each atom. More general highlighting (Phong, 1975[link]) is computed from four unit vectors, these being the normal to the surface, the direction to a light source, the direction to the viewer and the normalized vector sum of these last two. Intensity levels may then be set as the sum of three terms: a constant, a term proportional to the scalar product of the first two vectors (if positive) and a term proportional to a high power of the scalar product of the first and last vectors; the higher the power the glossier the surface appears to be. This final term normally adds a white term, rather than the surface colour, supposing the light source to be white.

Shadows may also be rendered to give even greater realism. In addition to the z buffer and (x, y) frame buffer a second z buffer for z′ values associated with x′ and y′ is also required. These coordinates are then related by [x' = x + \alpha z], [y' = y + \beta z], [z' = z]. The second buffer is a ray buffer since [x' y'] are the coordinates with which an illuminating ray passing through (xyz) passes through the [z = 0] plane, and z′, stored at x′, y′, records the depth at which this ray encounters material. Thus any two pixels [(x_{1}y_{1}z_{1})] and [(x_{2}y_{2}z_{2})] are on the same illuminating ray if their x′ and y′ values are equal and the one with smaller z′ shadows the other. Processing a pixel at [(x_{1}y_{1}z_{1})] therefore involves first determining its visibility on the basis of the z buffer, as before, then, whether or not it is visible, setting [z'_{1} = z_{1}] and considering the value of z′ currently stored at [x'y'], which we call [z'_{2}].

If [z'_{1}\lt z'_{2}] then [x_{1}y_{1}z_{1}] is in light and must be loaded accordingly. From [z'_{2}] we find the previously processed pixel [(x_{2}y_{2}z_{2})] which is now in shade and which was in light when originally processed, so that the colour value stored at [x_{2} y_{2}] needs to be altered unless the pixel at [x_{2} y_{2}] is now [(x_{2}y_{2}z_{3})] with [z_{3}\lt z_{2}], in which case the pixel [(x_{2}y_{2}z_{2})] which has now become shadowed by [(x_{1}y_{1}z_{1})] has, in the meantime, been obscured by [(x_{2}y_{2}z_{3})] which is not shadowed by [(x_{1}y_{1}z_{1})] and no change is therefore needed. In either event [z'_{1}] then replaces [z'_{2}].

If [z'_{1}\gt z'_{2}] then [(x_{1}y_{1}z_{1})], if visible, is in shade and must be coloured accordingly, and in this case [z'_{2}] is not superseded.

This shadowing scheme corresponds to illumination by a light source at infinity in picture space or, equivalently, with a z coordinate equal to that of the eye in display space. For its implementation x, y and z may be in any convenient coordinate system, e.g. pixel addresses, but if x and y are expressed with the range −1 to 1 and z with the range 0 to 1 corresponding to the window then they may be identified as the quantities [x / w, y / w] and [z/w] of picture space (Section 3.3.1.3.1[link]).

If, in the notation of Section 3.3.1.3.5[link], the light source is placed at (P, Q, E, V) in display space and a ray leaves it in the direction (p, q, r, V) then [x' = {p\over r} \cdot {2(S - E)\over (R - L)} + {2(S - E)(P - C)\over (N - E)(R - L)} + {2C - R - L\over R - L},] which varies only with beam direction, [\alpha = {2(S - E)(F - N)(P - C)\over (F - E)(N - E)(R - L)}] and similarly for y′ and β.

References

First citation Max, N. L. (1984). Computer representation of molecular surfaces. J. Mol. Graphics, 2, 8–13, C2–C4.Google Scholar
First citation Phong, B. T. (1975). Illumination for computer generated images. Commun. ACM, 18, 311–317.Google Scholar








































to end of page
to top of page