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

SCM Repository

[diderot] Diff of /branches/vis12-cl/test/vr-phong.diderot
ViewVC logotype

Diff of /branches/vis12-cl/test/vr-phong.diderot

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

revision 104, Tue Jun 1 16:04:19 2010 UTC revision 511, Tue Feb 8 17:01:43 2011 UTC
# Line 4  Line 4 
4  //  //
5    
6  input string dataFile;          // name of dataset  input string dataFile;          // name of dataset
7    input string txfFile;           // name of transfer-function file
8  input real stepSz;              // size of steps  input real stepSz;              // size of steps
9  input vec3 lightDir;  input vec3 lightDir;
10  input vec3 lightRGB;  input vec3 lightRGB;
# Line 18  Line 19 
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 = img (*) bspln3;
23  field#2(3)[] F = convolve (bspln3, img);  field#2(3)[] F = img (*) bspln3;
24    
25  field#0(1)[4] txf = convolve (tent, load("txf-rgba.nrrd"));  field#0(1)[4] txf = load(txfFile) ⊛ tent;
26    
27  actor RayCast (int row, int col)  strand RayCast (int row, int col)
28  {  {
     //// * : int x vec3 -> vec3  
     //// + : vec3 x vec3 -> vec3  
29      vec3        pos = orig + real(row)*rVec + real(col)*cVec;      vec3        pos = orig + real(row)*rVec + real(col)*cVec;
     //// |()| : vec -> real  
     //// - : vec3 x vec3 -> vec3  
     //// / : vec3 x real -> vec3  
30      vec3        dir = (pos - eye)/|pos - eye|;      vec3        dir = (pos - eye)/|pos - eye|;
31      real        t = 0.0;      real        t = 0.0;
32      vec3        rayRGB = [0.0, 0.0, 0.0];      output vec3 rayRGB = [0.0, 0.0, 0.0];
33      real        rayTransp = 1.0;      real        rayTransp = 1.0;
34    
35      update      update
36      {      {
37          if (inside (pos,F)) {          if (inside (pos,F)) {
            //// @ : field x vec3 -> real  
38             real val = F@pos;             real val = F@pos;
39             //// D : field -> field             vec3 grad = ∇F@pos;
            vec3 grad = (D F)@pos;  
40             vec3 norm = grad/|grad|;             vec3 norm = grad/|grad|;
41             vec3 halfDir = (lightDir - dir)/|lightDir - dir|;             vec3 halfDir = (lightDir - dir)/|lightDir - dir|;
42             vec4 matRGBA = txf@[val];             vec4 matRGBA = txf@val;
43             vec3 matRGB = [matRGBA[0],matRGBA[1],matRGBA[2]];             vec3 matRGB = [matRGBA[0],matRGBA[1],matRGBA[2]];
            //// dot : vec3 x vec3 -> real  
44             real ldotn = dot(lightDir, norm);             real ldotn = dot(lightDir, norm);
45             real hdotn = dot(halfDir, norm);             real hdotn = dot(halfDir, norm);
            // hey the per-component multiplication is in matRGB*lightRGB  
            //// * : real x vec3 -> vec3  
            //// modulate : vec3 x vec3 -> vec3  
            //// + : vec3 x vec3 -> vec3  
            //// pow : real x real -> real  
46             vec3 pntRGB = (ka + kd*ldotn)*modulate(matRGB,lightRGB) + ks*pow(hdotn,sh)*lightRGB;             vec3 pntRGB = (ka + kd*ldotn)*modulate(matRGB,lightRGB) + ks*pow(hdotn,sh)*lightRGB;
47             rayRGB = rayRGB + rayTransp*matRGBA[3]*pntRGB;             rayRGB = rayRGB + rayTransp*matRGBA[3]*pntRGB;
            //// * : real x real -> real  
            //// - : real x real -> real  
48             rayTransp = rayTransp*(1.0 - matRGBA[3]);             rayTransp = rayTransp*(1.0 - matRGBA[3]);
49          }          }
         //// > : real x real -> bool  
         //// < : real x real -> bool  
         //// || : bool x bool -> bool  
50          if (t > 1.0 || rayTransp < 0.01) // a little odd; ray terminates at length=1          if (t > 1.0 || rayTransp < 0.01) // a little odd; ray terminates at length=1
51              stabilize;              stabilize;
52          pos = pos + stepSz*dir;          pos = pos + stepSz*dir;

Legend:
Removed from v.104  
changed lines
  Added in v.511

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