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

SCM Repository

[diderot] Annotation of /branches/pure-cfg/test/vr-lite.diderot
ViewVC logotype

Annotation of /branches/pure-cfg/test/vr-lite.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 309 - (view) (download)
Original Path: trunk/test/vr-lite.diderot

1 : glk 309 // vr-lite.diderot
2 :     //
3 :     // simple diffuse-only volume rendering with head-light, with an
4 :     // opacity function that varies linearly between two values
5 :     //
6 :    
7 :     input string dataFile; // name of dataset
8 :     input real stepSz = 0.1; // size of steps
9 :     input vec3 eye; // location of eye point
10 :     input vec3 orig; // location of pixel (0,0)
11 :     input vec3 cVec; // vector between pixels horizontally
12 :     input vec3 rVec; // vector between pixels vertically
13 :     input real valOpacMin; // highest value with opacity 0.0
14 :     input real valOpacMax; // lowest value with opacity 1.0
15 :    
16 :     image(3)[] img = load (dataFile);
17 :    
18 :     //field#1(3)[] F = convolve (bspln3, img);
19 :     field#2(3)[] F = img ⊛ bspln3;
20 :    
21 :     actor RayCast (int row, int col)
22 :     {
23 :     vec3 pos = orig + real(row)*rVec + real(col)*cVec;
24 :     vec3 dir = (pos - eye)/|pos - eye|;
25 :     real t = 0.0;
26 :     real transp = 1.0;
27 :     real gray = 0.0;
28 :     output vec4 rgba = [0.0, 0.0, 0.0, 0.0];
29 :    
30 :     update
31 :     {
32 :     pos = pos + stepSz*dir;
33 :     if (inside (pos,F)) {
34 :     real val = F@pos;
35 :     vec3 grad = (∇ F)@pos;
36 :     vec3 norm = -grad/|grad|;
37 :     if (val > valOpacMin) { // we have some opacity
38 :     real opac = 0.0; // dummy initialization
39 :     if (val > valOpacMax) {
40 :     opac = 1.0;
41 :     } else {
42 :     opac = (val - valOpacMin)/(valOpacMax - valOpacMin);
43 :     }
44 :     gray = gray + transp*opac*max(0, dot(-dir,norm));
45 :     transp = transp*(1.0 - opac);
46 :     }
47 :     }
48 :     if (transp < 0.01) { // early ray termination
49 :     transp = 0.0;
50 :     rgba[0] = gray; rgba[1] = gray; rgba[2] = gray;
51 :     rgba[3] = 1.0-transp;
52 :     stabilize;
53 :     }
54 :     if (t > 40.0) {
55 :     // do we have a stabilize() code block?
56 :     rgba[0] = gray; rgba[1] = gray; rgba[2] = gray;
57 :     rgba[3] = 1.0-transp;
58 :     stabilize;
59 :     }
60 :     t = t + stepSz;
61 :     }
62 :    
63 :     /* render: output rgba */
64 :     }
65 :    
66 :     initially [ RayCast(r, c) | r in 0..199, c in 0..199 ];

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