Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /web/htdocs/index.html
ViewVC logotype

Diff of /web/htdocs/index.html

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 389, Tue Oct 12 20:46:30 2010 UTC revision 390, Wed Oct 13 19:56:41 2010 UTC
# Line 1  Line 1 
1  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2          "http://www.w3.org/TR/html4/strict.dtd">          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3  <html>  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4  <head>  <head>
5      <meta http-equiv="content-type" content="text/html; charset=utf-8" />
6          <title>Diderot project</title>          <title>Diderot project</title>
7          <meta name="generator" content="BBEdit 9.5">          <meta name="generator" content="BBEdit 9.5">
8      <style type="text/css" title="text/css">
9        /* <![CDATA[ */
10            .code-display {
11                    font-family: "Courier", monospace;
12                    white-space: pre;
13                    border: 1px solid #CBCBCB;
14                    background-color: #FFF8ED;
15                    color: mediumblue;
16                    width: 800px;
17                    padding: 1em;
18            }
19            .code-type {
20                    color: darkblue;
21                    font-weight: bold;
22            }
23            .code-kw {
24                    color: darkblue;
25                    font-weight: bold;
26            }
27            .code-comment {
28                    color: darkred;
29                    font-style: italic;
30            }
31            .warning {
32                    background-color: #FFFF66;
33                    color: red;
34                    font-style: italic;
35                    padding: 1em;
36            }
37        /* ]]> */
38      </style>
39  </head>  </head>
40  <body>  <body>
41    
# Line 83  Line 115 
115  configuration.  configuration.
116  </p>  </p>
117    
118    <h4>An example: A simple volume renderer in Diderot</h4>
119    <p>
120    The following code is a simple diffuse-only volume rendering with head-light
121    written in Diderot.
122    It uses an opacity function that varies linearly between two values.
123    This example illustrates the use of probing both a field and its gradient.
124    </p>
125    <p class="warning">
126    This example uses Unicode characters for convolution (code point <tt>\u229B</tt>)
127    and differentiation (code point <tt>\u2207</tt>).
128    If your browser has trouble with displaying these characters, an
129    ASCII-only version can be found <a href="vr-lite-ascii.html">here</a>.
130    </p>
131    
132    <div align="center">
133    <div align="left" class="code-display"><span class="code-type">input</span> <span class="code-type">string</span> dataFile;    <span class="code-comment">// name of dataset</span>
134    <span class="code-type">input</span> <span class="code-type">real</span> stepSz = 0.1;  <span class="code-comment">// size of steps</span>
135    <span class="code-type">input</span> <span class="code-type">vec3</span> eye;           <span class="code-comment">// location of eye point</span>
136    <span class="code-type">input</span> <span class="code-type">vec3</span> orig;          <span class="code-comment">// location of pixel (0,0)</span>
137    <span class="code-type">input</span> <span class="code-type">vec3</span> cVec;          <span class="code-comment">// vector between pixels horizontally</span>
138    <span class="code-type">input</span> <span class="code-type">vec3</span> rVec;          <span class="code-comment">// vector between pixels vertically</span>
139    <span class="code-type">input</span> <span class="code-type">real</span> valOpacMin;    <span class="code-comment">// highest value with opacity 0.0</span>
140    <span class="code-type">input</span> <span class="code-type">real</span> valOpacMax;    <span class="code-comment">// lowest value with opacity 1.0 </span>
141    
142    <span class="code-type">image(3)[]</span> img = load (dataFile);
143    <span class="code-type">field#1(3)[]</span> F = img ⊛ bspln3;
144    
145    <span class="code-kw">actor</span> RayCast (<span class="code-type">int</span> row, <span class="code-type">int</span> col)
146    {
147        <span class="code-type">vec3</span> pos = orig + <span class="code-type">real</span>(row)*rVec + <span class="code-type">real</span>(col)*cVec;
148        <span class="code-type">vec3</span> dir = (pos - eye)/|pos - eye|;
149        <span class="code-type">real</span> t = 0.0;
150        <span class="code-type">real</span> transp = 1.0;
151        <span class="code-type">real</span> gray = 0.0;
152        <span class="code-type">output</span> <span class="code-type">vec4</span>   rgba = [0.0, 0.0, 0.0, 0.0];
153    
154        <span class="code-kw">update</span> {
155            pos = pos + stepSz*dir;
156            <span class="code-kw">if</span> (inside (pos,F)) {
157                <span class="code-type">real</span> val = F@pos;
158                <span class="code-type">vec3</span> grad = ∇F@pos;
159                <span class="code-type">vec3</span> norm = -grad / |grad|;
160                <span class="code-kw">if</span> (val > valOpacMin) {  <span class="code-comment">// we have some opacity </span>
161                    <span class="code-type">real</span> opac =
162                            1.0 <span class="code-kw">if</span> (val > valOpacMax)
163                            <span class="code-kw">else</span> (val - valOpacMin)/(valOpacMax - valOpacMin);
164                    gray = gray + transp*opac*max(0.0, dot(-dir,norm));
165                    transp = transp*(1.0 - opac);
166                }
167            }
168            <span class="code-kw">if</span> (transp < 0.01) {  <span class="code-comment">// early ray termination</span>
169                transp = 0.0;
170                <span class="code-kw">stabilize</span>;
171            }
172            <span class="code-kw">if</span> (t > 40.0) {
173                <span class="code-kw">stabilize</span>;
174            }
175            t = t + stepSz;
176        }
177    
178         <span class="code-kw">stabilize</span> {
179            rgba = [gray, gray, gray, 1.0-transp];
180         }
181    
182    }
183    
184    <span class="code-kw">initially</span> [ RayCast(r, c) | r in 0..199, c in 0..199 ];
185    </div>
186    </div>
187    
188  <h3>Status</h3>  <h3>Status</h3>
189  <p>  <p>
190  We have a prototype language design that can handle simple examples, such as volume  We have a prototype language design that can handle simple examples, such as volume
# Line 102  Line 204 
204  </ul>  </ul>
205    
206  <hr />  <hr />
207  Last modified: October 4, 2010.  Last modified: October 13, 2010.
208  <hr />  <hr />
209    
210  </body>  </body>

Legend:
Removed from v.389  
changed lines
  Added in v.390

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0