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

SCM Repository

[diderot] Diff of /trunk/test/vr-lite.diderot
ViewVC logotype

Diff of /trunk/test/vr-lite.diderot

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

revision 313, Tue Aug 17 20:38:44 2010 UTC revision 1370, Wed Jun 22 21:11:20 2011 UTC
# Line 12  Line 12 
12  input vec3 rVec;                // vector between pixels vertically  input vec3 rVec;                // vector between pixels vertically
13  input real valOpacMin;          // highest value with opacity 0.0  input real valOpacMin;          // highest value with opacity 0.0
14  input real valOpacMax;          // lowest value with opacity 1.0  input real valOpacMax;          // lowest value with opacity 1.0
15    // valOpacMin,Max pairs for sample datasets:
16    // txs.nrrd 0.15, 0.35
17    // vfrhand-nohip.nhdr, for skin: 200, 500
18    // vfrhand-nohip.nhdr, for bone: 1330, 1630
19    
20  image(3)[] img = load (dataFile);  image(3)[] img = load (dataFile);
21    
22  //field#1(3)[] F = convolve (bspln3, img);  //field#1(3)[] F = convolve (bspln3, img);
23  field#2(3)[] F = img ⊛ bspln3;  field#2(3)[] F = img ⊛ bspln3;
24    
25  actor RayCast (int row, int col)  strand RayCast (int row, int col)
26  {  {
27      vec3 pos = orig + real(row)*rVec + real(col)*cVec;      vec3 pos = orig + real(row)*rVec + real(col)*cVec;
28      vec3 dir = (pos - eye)/|pos - eye|;      vec3 dir = normalize(pos - eye);
29      real t = 0.0;      real t = 0.0;
30      real transp = 1.0;      real transp = 1.0;
31      real gray = 0.0;      real gray = 0.0;
# Line 31  Line 35 
35      {      {
36          pos = pos + stepSz*dir;          pos = pos + stepSz*dir;
37          if (inside (pos,F)) {          if (inside (pos,F)) {
38              real val = F@pos;              real val = F(pos);
39              vec3 grad = (∇ F)@pos;              vec3 norm = -normalize(∇F(pos));
             vec3 norm = -grad/|grad|;  
40              if (val > valOpacMin) {  // we have some opacity              if (val > valOpacMin) {  // we have some opacity
41                  real opac = 0.0;     // dummy initialization                  real opac = min(1.0, lerp(0.0, 1.0, valOpacMin, val, valOpacMax));
42                  if (val > valOpacMax) {                  gray = gray + transp*opac*max(0.0, -dir • norm);
                    opac = 1.0;  
                 } else {  
                    opac = (val - valOpacMin)/(valOpacMax - valOpacMin);  
                 }  
                 gray = gray + transp*opac*max(0.0, dot(-dir,norm));  
43                  transp = transp*(1.0 - opac);                  transp = transp*(1.0 - opac);
44              }              }
45          }          }
46          if (transp < 0.01) {  // early ray termination          if (transp < 0.01) {  // early ray termination
47              transp = 0.0;              transp = 0.0;
48              rgba = [gray, gray, gray, 1.0-transp];              rgba = [gray, gray, gray, 1.0-transp]; /* FIXME */
49              stabilize;              stabilize;
50          }          }
51          if (t > 40.0) {          if (t > 40.0) {
52              // do we have a stabilize() code block?              rgba = [gray, gray, gray, 1.0-transp]; /* FIXME */
             rgba = [gray, gray, gray, 1.0-transp];  
53              stabilize;              stabilize;
54          }          }
55          t = t + stepSz;          t = t + stepSz;
56      }      }
57    
58         stabilize {
59    //        rgba = [gray, gray, gray, 1.0-transp];
60         }
61    
62      /* render: output rgba */      /* render: output rgba */
63  }  }
64    

Legend:
Removed from v.313  
changed lines
  Added in v.1370

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