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 1.1 by greg, Thu Feb 2 10:41:21 1989 UTC vs.
Revision 2.9 by greg, Fri Dec 8 18:22:07 1995 UTC

# Line 16 | Line 16 | static char SCCSid[] = "$SunId$ LBL";
16  
17   #ifdef  DISPERSE
18   #include  "source.h"
19 + static  disperse();
20 + static int  lambda();
21   #endif
22  
23   /*
# Line 48 | Line 50 | static char SCCSid[] = "$SunId$ LBL";
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   {
56        double  sqrt(), pow();
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 80 | 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));
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 = intens(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 113 | 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 127 | Line 151 | register RAY  *r;
151                          if (m->otype != MAT_DIELECTRIC
152                                          || r->rod > 0.0
153                                          || r->crtype & SHADOW
154 +                                        || !directvis
155                                          || m->oargs.farg[4] == 0.0
156                                          || !disperse(m, r, p.rdir, trans))
157   #endif
158                          {
159 +                                copycolor(p.cext, ctrans);
160 +                                p.albedo = talb;
161                                  rayvalue(&p);
135                                multcolor(mcolor, r->pcol);     /* modify */
162                                  scalecolor(p.rcol, trans);
163                                  addcolor(r->rcol, p.rcol);
164 +                                if (nratio >= 1.0-FTINY && nratio <= 1.0+FTINY)
165 +                                        r->rt = r->rot + p.rt;
166                          }
167                  }
168          }
# Line 151 | Line 179 | register RAY  *r;
179                  scalecolor(p.rcol, refl);       /* color contribution */
180                  addcolor(r->rcol, p.rcol);
181          }
182 <
183 <        multcolor(r->rcol, mcolor);             /* multiply by transmittance */
182 >                                /* rayvalue() computes absorption */
183 >        return(1);
184   }
185  
186  
# Line 165 | Line 193 | RAY  *r;
193   FVECT  vt;
194   double  tr;
195   {
168        double  sqrt();
196          RAY  sray, *entray;
197          FVECT  v1, v2, n1, n2;
198          FVECT  dv, v2Xdv;
199          double  v2Xdvv2Xdv;
200 <        int  sn, success = 0;
201 <        double  omega;
200 >        int  success = 0;
201 >        SRCINDEX  si;
202          FVECT  vtmp1, vtmp2;
203          double  dtmp1, dtmp2;
204          int  l1, l2;
# Line 233 | Line 260 | double  tr;
260          v2Xdvv2Xdv = DOT(v2Xdv, v2Xdv);
261  
262                                          /* check sources */
263 <        for (sn = 0; sn < nsources; sn++) {
263 >        initsrcindex(&si);
264 >        while (srcray(&sray, r, &si)) {
265  
266 <                if ((omega = srcray(&sray, r, sn)) == 0.0 ||
239 <                                DOT(sray.rdir, v2) < MINCOS)
266 >                if (DOT(sray.rdir, v2) < MINCOS)
267                          continue;                       /* bad source */
241                
268                                                  /* adjust source ray */
269  
270                  dtmp1 = DOT(v2Xdv, sray.rdir) / v2Xdvv2Xdv;
# Line 253 | Line 279 | double  tr;
279                                                  /* trace source ray */
280                  normalize(sray.rdir);
281                  rayvalue(&sray);
282 <                if (intens(sray.rcol) <= FTINY) /* missed it */
282 >                if (bright(sray.rcol) <= FTINY) /* missed it */
283                          continue;
284                  
285                  /*
# Line 263 | Line 289 | double  tr;
289                   */
290                  
291                  fcross(vtmp1, v2Xdv, sray.rdir);
292 <                dtmp1 = sqrt(omega  / v2Xdvv2Xdv / PI);
292 >                dtmp1 = sqrt(si.dom  / v2Xdvv2Xdv / PI);
293  
294                                                          /* compute first ray */
295                  for (i = 0; i < 3; i++)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines