ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/dielectric.c
(Generate patch)

Comparing ray/src/rt/dielectric.c (file contents):
Revision 2.8 by greg, Tue Dec 5 11:46:00 1995 UTC vs.
Revision 2.9 by greg, Fri Dec 8 18:22:07 1995 UTC

# Line 50 | Line 50 | static int  lambda();
50  
51   #define  MINCOS         0.997           /* minimum dot product for dispersion */
52  
53 + extern COLOR  cextinction;              /* global coefficient of extinction */
54 + extern double  salbedo;                 /* global scattering albedo */
55  
56 < m_dielectric(m, r)      /* color a ray which hit something transparent */
56 >
57 > m_dielectric(m, r)      /* color a ray which hit a dielectric interface */
58   OBJREC  *m;
59   register RAY  *r;
60   {
61          double  cos1, cos2, nratio;
62 <        COLOR  mcolor;
62 >        COLOR  ctrans;
63 >        double  talb;
64          double  mabsorp;
65          double  refl, trans;
66          FVECT  dnorm;
# Line 81 | Line 85 | register RAY  *r;
85                  dnorm[0] = -dnorm[0];
86                  dnorm[1] = -dnorm[1];
87                  dnorm[2] = -dnorm[2];
88 <                setcolor(mcolor, pow(m->oargs.farg[0], r->rot),
89 <                                 pow(m->oargs.farg[1], r->rot),
90 <                                 pow(m->oargs.farg[2], r->rot));
91 <                multcolor(mcolor, r->pcol);     /* modify */
88 >                setcolor(r->cext, -log(m->oargs.farg[0]*colval(r->pcol,RED)),
89 >                                 -log(m->oargs.farg[1]*colval(r->pcol,GRN)),
90 >                                 -log(m->oargs.farg[2]*colval(r->pcol,BLU)));
91 >                r->albedo = 0.;
92 >                r->gecc = 0.;
93 >                if (m->otype == MAT_INTERFACE) {
94 >                        setcolor(ctrans,
95 >                                -log(m->oargs.farg[4]*colval(r->pcol,RED)),
96 >                                -log(m->oargs.farg[5]*colval(r->pcol,GRN)),
97 >                                -log(m->oargs.farg[6]*colval(r->pcol,BLU)));
98 >                        talb = 0.;
99 >                } else {
100 >                        copycolor(ctrans, cextinction);
101 >                        talb = salbedo;
102 >                }
103          } else {                                /* outside */
104                  nratio = 1.0 / nratio;
105 <                if (m->otype == MAT_INTERFACE)
106 <                        setcolor(mcolor, pow(m->oargs.farg[4], r->rot),
107 <                                         pow(m->oargs.farg[5], r->rot),
108 <                                         pow(m->oargs.farg[6], r->rot));
109 <                else
110 <                        setcolor(mcolor, 1.0, 1.0, 1.0);
105 >
106 >                setcolor(ctrans, -log(m->oargs.farg[0]*colval(r->pcol,RED)),
107 >                                 -log(m->oargs.farg[1]*colval(r->pcol,GRN)),
108 >                                 -log(m->oargs.farg[2]*colval(r->pcol,BLU)));
109 >                talb = 0.;
110 >                if (m->otype == MAT_INTERFACE) {
111 >                        setcolor(r->cext,
112 >                                -log(m->oargs.farg[4]*colval(r->pcol,RED)),
113 >                                -log(m->oargs.farg[5]*colval(r->pcol,GRN)),
114 >                                -log(m->oargs.farg[6]*colval(r->pcol,BLU)));
115 >                        r->albedo = 0.;
116 >                        r->gecc = 0.;
117 >                }
118          }
119 <        mabsorp = bright(mcolor);
119 >        mabsorp = exp(-bright(r->cext)*r->rot);         /* approximate */
120  
121          d2 = 1.0 - nratio*nratio*(1.0 - cos1*cos1);     /* compute cos theta2 */
122  
# Line 115 | Line 137 | register RAY  *r;
137                  d1 = (d1 - d2) / (d1 + d2);
138                  refl += d1 * d1;
139  
140 <                refl /= 2.0;
140 >                refl *= 0.5;
141                  trans = 1.0 - refl;
142  
143                  if (rayorigin(&p, r, REFRACTED, mabsorp*trans) == 0) {
# Line 134 | Line 156 | register RAY  *r;
156                                          || !disperse(m, r, p.rdir, trans))
157   #endif
158                          {
159 +                                copycolor(p.cext, ctrans);
160 +                                p.albedo = talb;
161                                  rayvalue(&p);
162                                  scalecolor(p.rcol, trans);
163                                  addcolor(r->rcol, p.rcol);
# Line 155 | Line 179 | register RAY  *r;
179                  scalecolor(p.rcol, refl);       /* color contribution */
180                  addcolor(r->rcol, p.rcol);
181          }
182 <
159 <        multcolor(r->rcol, mcolor);             /* multiply by transmittance */
160 <
182 >                                /* rayvalue() computes absorption */
183          return(1);
184   }
185  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines