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

SCM Repository

[diderot] Diff of /branches/pure-cfg/test/vr-kcomp.diderot
ViewVC logotype

Diff of /branches/pure-cfg/test/vr-kcomp.diderot

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

revision 776, Thu Apr 7 21:50:30 2011 UTC revision 827, Sat Apr 16 00:40:34 2011 UTC
# Line 3  Line 3 
3  vec3 camUp = [0.0, 0.0, 1.0];  vec3 camUp = [0.0, 0.0, 1.0];
4  real camNear = -1.0;  real camNear = -1.0;
5  real camFar = 1.0;  real camFar = 1.0;
6  real camFOV = 5.0;  real camFOV = 4.5;
7  int imgResU = 200;  int imgResU = 200;
8  int imgResV = 200;  int imgResV = 200;
9  real rayStep = 0.01;  real rayStep = 0.01;
10  real valOpacMin = 0.05;          // highest value with opacity 0.0  real valOpacMin = 0.08;          // highest value with opacity 0.0
11  real valOpacMax = 0.06;          // lowest value with opacity 1.0  real valOpacMax = 0.09;          // lowest value with opacity 1.0
12    
13  real camDist = |camAt - camEye|;  real camDist = |camAt - camEye|;
14  real camVspNear = camNear + camDist;  real camVspNear = camNear + camDist;
# Line 19  Line 19 
19  real camVmax = tan(camFOV*3.1415926536/360.0)*camDist;  real camVmax = tan(camFOV*3.1415926536/360.0)*camDist;
20  real camUmax = camVmax*real(imgResU)/real(imgResV);  real camUmax = camVmax*real(imgResU)/real(imgResV);
21    
22  vec3 lightVspDir = [0.9, -1.0, -2.5];  vec3 lightVspDir = [-1.0, -1.0, -3.5];
23  vec3 lightDir = normalize(lightVspDir[0]*camU + lightVspDir[1]*camV + lightVspDir[2]*camN);  vec3 lightDir = normalize(lightVspDir[0]*camU + lightVspDir[1]*camV + lightVspDir[2]*camN);
24    
25  real phongKa = 0.05;  real phongKa = 0.02;
26  real phongKd = 0.80;  real phongKd = 0.60;
27  real phongKs = 0.20;  real phongKs = 0.40;
28  real phongSp = 30.0;  real phongSp = 30.0;
29    
30  image(3)[] img = load ("../data/vox1-9.nrrd");  image(3)[] img = load ("../data/vox1-9.nrrd");
# Line 44  Line 44 
44      real gray = 0.0;      real gray = 0.0;
45      int myui = ui;      int myui = ui;
46      int myvi = vi;      int myvi = vi;
47        field#1(3)[] myFc0 = Fc0;
48        field#1(3)[] myFc1 = Fc1;
49      output vec4 rgba = [0.0, 0.0, 0.0, 0.0];      output vec4 rgba = [0.0, 0.0, 0.0, 0.0];
50      // ##########  END  per-ray initialization      // ##########  END  per-ray initialization
51    
# Line 53  Line 55 
55         if (inside (rayPos,Fc1)) {         if (inside (rayPos,Fc1)) {
56            // ########## BEGIN per-sample code            // ########## BEGIN per-sample code
57            real val = 0.0;            real val = 0.0;
58            vec3 grad = [0.0,0.0,0.0];            vec3 norm = [0.0,0.0,0.0];
59            // HEY (scoping BUG): the strand parameters (e.g. ui, vi) can't            // HEY (scoping BUG): the strand parameters (e.g. ui, vi) can't
60            // appear in conditionals            // appear in conditionals
61            if (myui + myvi < imgResU) {            if (myui + myvi < imgResU) {
62               val = Fc0@rayPos;               val = myFc0@rayPos;
63               grad = ∇Fc0@rayPos;               norm = normalize(-∇myFc0@rayPos);
64            } else {            } else {
65               val = Fc1@rayPos;               val = myFc1@rayPos;
66               grad = ∇Fc1@rayPos;               norm = normalize(-∇myFc1@rayPos);
67            }            }
           vec3 norm = normalize(-grad);  
68            if (val > valOpacMin) {  // we have some opacity            if (val > valOpacMin) {  // we have some opacity
69                real opac = min(1.0, lerp(0.0, 1.0, valOpacMin, val, valOpacMax));                real opac = min(1.0, lerp(0.0, 1.0, valOpacMin, val, valOpacMax));
70                real ld = lightDir • norm;                real ld = lightDir • norm;
71                  real hd = norm • normalize(lightDir + normalize(camEye - rayPos));
72                real mat = (  phongKa                real mat = (  phongKa
73                            + phongKd*(ld if ld > 0.0 else 0.0)                            + phongKd*(ld if ld > 0.0 else 0.0)
74                            + phongKs*(pow(ld, phongSp) if ld > 0.0 else 0.0));                            + phongKs*(hd^phongSp if hd > 0.0 else 0.0));
75                gray = gray + transp*opac*mat;                gray = gray + transp*opac*mat;
76                transp = transp*(1.0 - opac);                transp = transp*(1.0 - opac);
77            }            }
78            // ##########  END  per-sample code            // ##########  END  per-sample code
79         }         }
80         if (transp < 0.01) {  // early ray termination         if (transp < 0.01) {  // early ray termination
81            rgba = [gray, gray, gray, 1.0];            transp = 0.0;
82              // HEY (BUG) stabilize function not working
83              // setting rgba should be done there
84              rgba = [gray, gray, gray, 1.0-transp];
85            stabilize;            stabilize;
86         }         }
87         if (rayN > camVspFar) {         if (rayN > camVspFar) {
88              // HEY (BUG) (same as above)
89            rgba = [gray, gray, gray, 1.0-transp];            rgba = [gray, gray, gray, 1.0-transp];
90            stabilize;            stabilize;
91         }         }
92         rayN = rayN + rayStep;         rayN = rayN + rayStep;
93      }      }
94    
95        stabilize {
96    //       rgba = [gray, gray, gray, 1.0-transp];
97        }
98    
99      /* render: output maxval */      /* render: output maxval */
100  }  }
101    

Legend:
Removed from v.776  
changed lines
  Added in v.827

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