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

SCM Repository

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

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

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

revision 55, Tue Apr 20 15:59:05 2010 UTC revision 59, Tue May 4 15:54:33 2010 UTC
# Line 24  Line 24 
24    
25  actor RayCast (int row, int col)  actor RayCast (int row, int col)
26  {  {
27      vec3        pos = orig + row*rVec + col*cVec;      //// * : int x vec3 -> vec3
28        //// + : vec3 x vec3 -> vec3
29        vec3        pos = orig + real(row)*rVec + real(col)*cVec;
30        //// |()| : vec -> real
31        //// - : vec3 x vec3 -> vec3
32        //// / : vec3 x real -> vec3
33      vec3        dir = (pos - eye)/|pos - eye|;      vec3        dir = (pos - eye)/|pos - eye|;
34      real        t = 0.0;      real        t = 0.0;
35      vec3        rayRGB = (0.0, 0.0, 0.0);      vec3        rayRGB = (0.0, 0.0, 0.0);
# Line 33  Line 38 
38      update      update
39      {      {
40          if (inside (pos,F)) {          if (inside (pos,F)) {
41               //// @ : field x vec3 -> real
42             real val = F@pos;             real val = F@pos;
43               //// D : field -> field
44             vec3 grad = (D F)@pos;             vec3 grad = (D F)@pos;
45             vec3 norm = grad/|grad|;             vec3 norm = grad/|grad|;
46             vec3 half = (lightDir - dir)/|lightDir - dir|;             vec3 half = (lightDir - dir)/|lightDir - dir|;
47             vec4 matRGBA = txf@val;             vec4 matRGBA = txf@val;
48             vec3 matRGB = (matRGBA[0],matRGBA[1],matRGBA[2]);             vec3 matRGB = (matRGBA[0],matRGBA[1],matRGBA[2]);
49               //// dot : vec3 x vec3 -> real
50             real ldotn = dot(lightDir,norm);             real ldotn = dot(lightDir,norm);
51             real hdotn = dot(halfDir,norm);             real hdotn = dot(halfDir,norm);
52             // hey the per-component multiplication is in matRGB*lightRGB             // hey the per-component multiplication is in matRGB*lightRGB
53             vec3 pntRGB = (ka + kd*ldotn)*matRGB*lightRGB + ks*pow(hdotn,psh)*lightRGB;             //// * : real x vec3 -> vec3
54             rayRGB = rayRGB + rayTranps*matRGBA[3]*matRGB;             //// modulate : vec3 x vec3 -> vec3
55               //// + : vec3 x vec3 -> vec3
56               //// pow : real x real -> real
57               vec3 pntRGB = (ka + kd*ldotn)*modulate(matRGB,lightRGB) + ks*pow(hdotn,psh)*lightRGB;
58               rayRGB = rayRGB + rayTranps*matRGBA[3]*pntRGB;
59               //// * : real x real -> real
60               //// - : real x real -> real
61             rayTransp = rayTranps*(1.0 - matRGBA[3]);             rayTransp = rayTranps*(1.0 - matRGBA[3]);
62          }          }
63            //// > : real x real -> bool
64            //// < : real x real -> bool
65            //// || : bool x bool -> bool
66          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
67              stabilize;              stabilize;
68          pos = pos + stepSz*dir;          pos = pos + stepSz*dir;

Legend:
Removed from v.55  
changed lines
  Added in v.59

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