Transparent surfaces in Raster3D
Transparency! (New in version 2.2)
MATERIAL descriptions (object type 8) now include a parameter related to
transparency. Material descriptions apply to subsequent objects in the
render input file until an termination record (object type 9) is
encountered. This means that an entire surface representation, for
instance one generated by the program GRASP, can be rendered as transparent
by inserting one record in front of it and another at the end.
This is illustrated in example 6 of the Raster3D distribution kit.
Nothing is free, of course, and this includes transparency. I tried very
hard to leave normal bread-and-butter operation of the rendering program
unaffected by support for transparency. If you are actually rendering an
image which contains transparent objects, however, the program may slow
down by as much as a factor of 3. If your machine seems to do much worse
than this, you might wish to try to option described at the end of this
section.
Here is an example of a MATERIAL description which specifies a transparent
surface:
8
17.0 0.6 -1.0 -1.0 -1.0 0.9 0 0 0 0
^ ^ ^ ^ ^ ^ ^
| | | | | | |
MPHONG MSPEC SR SG SB CLRITY OPTS
The first record specifies a MATERIAL description (object type 8).
The following record contains a set of parameters which apply to this
material.
- MPHONG
- overrides the global Phong parameter in the header; a lower
value (<20.) smears out specular highlights over a larger area,
which is probably a good idea for transparent surfaces.
- MSPEC
- overrides the global SPECLR parameter in the header; controls what
fraction of the total shading is due to specular reflection. This
probably should be >0.5 for a transparent object.
- SR/SG/SB
- red, green, and blue components of the specular highlights.
Remember that each object has an associated RGB triple that
determines its colour. But the "colour" of a transparent object
is somewhat problematic, so you have the option of passing the
object's basic colour through to appear also in the specular
highlighting. This is indicated by setting SR, SG, SB negative
as in the example above.
- CLRITY
- This is a value between 0.0 and 1.0 indicating the degree of
clarity of the material. 0 indicates a completely opaque surface,
while 1 indicates a completely transparent surface. Values in the
range of 0.8 to 1.0 are probably appropriate.
- OPTS
- These four parameters are reserved for future expansion of the
MATERIAL specification. They must be present, but
but version 2.3 of the program uses only the first one (OPTS[1]).
The current options supported for this parameter are:
- OPTS[1] = 0
- All transparent objects will be rendered, subject to the
limit that at a depth of three overlapping transparent objects
the third is effectively opaque
- OPTS[1] = 1
- Only the topmost object of a transparent material will be
rendered at all. This will, for example, cause internal
cavities to disappear from a molecular surface covering
an entire protein. It also allows rendering only the outside
surface of a transparent CPK model.
What to do if transparent objects seem to turn your machine to molasses.
The extra time involved in rendering transparent objects is mostly due to
bookkeeping overhead rather than to the actual calculation of surface
properties, at least on the machines I have clocked it on. The algorithm
used, however, does include at least one cosine calculation for each pixel
and I can easily imagine that some machines (or FORTRAN libraries) would
execute this calculation very slowly indeed. Therefore I have put a
commented-out alternative algorithm in the render source code, along with
instructions for re-compiling. The alternative algorithm produces a slightly
less realistic result (in my purely empirical opinion) but avoids any cosine
functions.