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

SCM Repository

[diderot] Annotation of /branches/pure-cfg/doc/report/vr-lite.tex
ViewVC logotype

Annotation of /branches/pure-cfg/doc/report/vr-lite.tex

Parent Directory Parent Directory | Revision Log Revision Log


Revision 335 - (view) (download) (as text)
Original Path: trunk/doc/report/vr-lite.tex

1 : jhr 335 \begin{lstlisting}[mathescape=true]
2 :     input string dataFile; // name of dataset
3 :     input real stepSz = 0.1; // size of steps
4 :     input vec3 eye; // location of eye point
5 :     input vec3 orig; // location of pixel (0,0)
6 :     input vec3 cVec; // vector between pixels horizontally
7 :     input vec3 rVec; // vector between pixels vertically
8 :     input real valOpacMin; // highest value with opacity 0.0
9 :     input real valOpacMax; // lowest value with opacity 1.0
10 :    
11 :     image(3)[] img = load (dataFile);
12 :     field#1(3)[] F = convolve (bspln3, img);
13 :    
14 :     actor RayCast (int row, int col)
15 :     {
16 :     vec3 pos = orig + real(row)*rVec + real(col)*cVec;
17 :     vec3 dir = (pos - eye)/|pos - eye|;
18 :     real t = 0.0;
19 :     real transp = 1.0;
20 :     real gray = 0.0;
21 :     output vec4 rgba = [0.0, 0.0, 0.0, 0.0];
22 :    
23 :     update {
24 :     pos = pos + stepSz*dir;
25 :     if (inside (pos,F)) {
26 :     real val = F@pos;
27 :     vec3 grad = ($\nabla$ F)@pos;
28 :     vec3 norm = -grad/|grad|;
29 :     if (val > valOpacMin) { // we have some opacity
30 :     real opac = 0.0; // dummy initialization
31 :     if (val > valOpacMax) opac = 1.0;
32 :     else opac = (val - valOpacMin)/(valOpacMax - valOpacMin);
33 :     gray = gray + transp*opac*max(0.0, dot(-dir,norm));
34 :     transp = transp*(1.0 - opac);
35 :     }
36 :     }
37 :     if (transp < 0.01) { // early ray termination
38 :     transp = 0.0;
39 :     stabilize;
40 :     }
41 :     else if (t > 40.0) {
42 :     stabilize;
43 :     }
44 :     t = t + stepSz;
45 :     }
46 :    
47 :     stabilize {
48 :     rgba = [gray, gray, gray, 1.0-transp];
49 :     }
50 :     }
51 :    
52 :     initially [ RayCast(r, c) | r in 0..199, c in 0..199 ];
53 :     \end{lstlisting}%

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