File: r3d_transparent.html

package info (click to toggle)
raster3d 3.0-2-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,988 kB
  • sloc: fortran: 10,785; ansic: 1,057; makefile: 317; sh: 252; csh: 15
file content (127 lines) | stat: -rw-r--r-- 5,102 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<html>
  <head>
    <title>Transparent surfaces in Raster3D</title>
    <!-- OWNER_NAME="Ethan A Merritt, Biological Structure" -->
    <LINK rev=made href="mailto:merritt@u.washington.edu">
    <!-- OWNER_INFO="University of Washington Box 357742, Seattle WA 98195" -->
   <LINK REL=stylesheet HREF="r3d_docstyle.css" TEXT="text/css">
  </head>

<body>
	<h1 align=center>Transparent surfaces in Raster3D</h1>
<hr>

<h4>Transparency</h4> 
<a href="render.html#objects">
MATERIAL descriptions</a> 
(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.
<p>

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 can try the fix described at the end of this section. 
<p>

Here is an example of a MATERIAL description which specifies a transparent
surface:
<pre>
    8
    17.0    0.6     -1.0 -1.0 -1.0     0.9        0 0 0 0

    ^       ^       ^    ^    ^        ^          ^
    |       |       |    |    |        |          |
    MPHONG  MSPEC   SR   SG   SB       CLRITY     OPTS
</pre>
The first record specifies a MATERIAL description (object type 8).
The following record contains a set of parameters which apply to this
material.
<dl>
<dt>MPHONG 
        <dd> overrides the global Phong parameter in the header; a lower
             value (&lt;20.) smears out specular highlights over a larger area,
             which is probably a good idea for transparent surfaces.

<dt>MSPEC  
        <dd> overrides the global SPECLR parameter in the header; controls what
             fraction of the total shading is due to specular reflection. This
             probably should be &gt;0.5 for a transparent object.

<dt>SR/SG/SB 
	<dd> 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.

<dt>CLRITY 
	<dd> 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.

<dt>OPTS   
	<dd> These four parameters are reserved for future expansion of the
             MATERIAL specification.  OPTS[1] controls how overlapping transparent
	     objects are treated.  
	     <dl>
	     <dt>OPTS[1] = 0
		 <dd> All transparent objects will be rendered, subject to the 
		 limit that at a depth of three overlapping transparent objects
		 the third is effectively opaque
	     <dt>OPTS[1] = 1
		 <dd> Only the topmost surface of any given 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.
	     <dt>OPTS[1] = 2
	     	 <dd> The rear-facing portions of transparent spheres, cylinders,
		 and tesselated surfaces will be rendered (normally only the
		 front surfaces are rendered).
	     </dl>
	     OPTS[2] controls which algorithm is used to vary transparency as a 
	     function of alpha (=CLRITY) and the Z component of the surface normal.
	     OPTS[2] = 2 is theoretically more correct, but in
	     my opinion comes out looking less transparent than it should.
	     OPTS[2] = 0 is an empirical function that looks better to me.
	     <dl>
	     <dt>OPTS[2] = 0
	 	<dd> T(ZN) = 0.25 * (1 + cos(pi*alpha*ZN))^2
	     <dt>OPTS[2] = 1
	 	<dd> T(ZN) = (1 - abs(alpha*ZN))^2
	     <dt>OPTS[2] = 2
	 	<dd> T(ZN) = 1 - alpha ^ (sqrt(pi/4) / abs(ZN))
	     <dt>OPTS[2] = 3
	 	<dd> T(ZN) = 1 - alpha
	     </dl>

</dl>


</body>

<hr>
<a href="raster3d.html">
<img src="index_button.gif" align=top> Back to top </a>
<a href="http://www.bmsc.washington.edu/raster3d/raster3d.html">
<img src="r3d_icon.gif" alt="" align=top> Raster3D homepage </a>

<hr>
<address>
Ethan A Merritt / merritt@u.washington.edu / 
    <a href="http://www.bmsc.washington.edu/index.html">
    Biomolecular Structure Center at UW</a><br>
</address>

</html>