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

SCM Repository

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

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

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

trunk/test/vr-phong.diderot revision 243, Fri Aug 6 15:27:47 2010 UTC branches/vis12/test/vr-phong.diderot revision 1927, Sat Jun 23 18:09:16 2012 UTC
# Line 1  Line 1 
1  // vr.diderot  // vr-phong.diderot
2  //  //
3  // volume rendering example in Diderot  // volume rendering example in Diderot
4  //  //
5    
 input string dataFile;          // name of dataset  
 input string txfFile;           // name of transfer-function file  
6  input real stepSz;              // size of steps  input real stepSz;              // size of steps
7  input vec3 lightDir;  input vec3 lightDir;
8  input vec3 lightRGB;  input vec3 lightRGB;
# Line 17  Line 15 
15  input real ks;  input real ks;
16  input real sh;  input real sh;
17    
18  image(3)[] img = load (dataFile);  field#2(3)[] F = bspln3 (*) image("../data/txs.nrrd");
19    field#0(1)[4] txf = tent ⊛ image("../data/dummy-txf-rgba.nrrd");
20    
21  //field#1(3)[] F = convolve (bspln3, img);  strand RayCast (int row, int col)
 field#2(3)[] F = convolve (bspln3, img);  
   
 field#0(1)[4] txf = convolve (tent, load(txfFile));  
   
 actor RayCast (int row, int col)  
22  {  {
23      vec3        pos = orig + real(row)*rVec + real(col)*cVec;      vec3        pos = orig + real(row)*rVec + real(col)*cVec;
24      vec3        dir = (pos - eye)/|pos - eye|;      vec3        dir = normalize(pos - eye);
25      real        t = 0.0;      real        t = 0.0;
26      output vec3 rayRGB = [0.0, 0.0, 0.0];      output vec3 rayRGB = [0.0, 0.0, 0.0];
27      real        rayTransp = 1.0;      real        rayTransp = 1.0;
# Line 36  Line 30 
30      {      {
31          if (inside (pos,F)) {          if (inside (pos,F)) {
32             real val = F@pos;             real val = F@pos;
33             vec3 grad = (D F)@pos;             vec3 norm = normalize(-∇F@pos);
34             vec3 norm = grad/|grad|;             vec3 halfDir = normalize(lightDir - dir);
35             vec3 halfDir = (lightDir - dir)/|lightDir - dir|;             vec4 matRGBA = txf@val;
            vec4 matRGBA = txf@[val];  
36             vec3 matRGB = [matRGBA[0],matRGBA[1],matRGBA[2]];             vec3 matRGB = [matRGBA[0],matRGBA[1],matRGBA[2]];
37             real ldotn = dot(lightDir, norm);             real ldotn = lightDir • norm;
38             real hdotn = dot(halfDir, norm);             real hdotn = halfDir • norm;
39             vec3 pntRGB = (ka + kd*ldotn)*modulate(matRGB,lightRGB) + ks*pow(hdotn,sh)*lightRGB;             vec3 pntRGB = (ka + kd*ldotn)*modulate(matRGB,lightRGB) + ks*hdotn^sh*lightRGB;
40             rayRGB = rayRGB + rayTransp*matRGBA[3]*pntRGB;             rayRGB = rayRGB + rayTransp*matRGBA[3]*pntRGB;
41             rayTransp = rayTransp*(1.0 - matRGBA[3]);             rayTransp = rayTransp*(1.0 - matRGBA[3]);
42          }          }

Legend:
Removed from v.243  
changed lines
  Added in v.1927

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