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.10 by greg, Thu Feb 22 16:56:39 1996 UTC vs.
Revision 2.13 by gwlarson, Wed Jun 17 12:53:07 1998 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1986 Regents of the University of California */
1 > /* Copyright (c) 1998 Silicon Graphics, Inc. */
2  
3   #ifndef lint
4 < static char SCCSid[] = "$SunId$ LBL";
4 > static char SCCSid[] = "$SunId$ SGI";
5   #endif
6  
7   /*
# Line 51 | Line 51 | static int  lambda();
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 */
54 > extern COLOR  salbedo;                  /* global scattering albedo */
55  
56  
57   static double
# Line 72 | Line 72 | register RAY  *r;
72   {
73          double  cos1, cos2, nratio;
74          COLOR  ctrans;
75 <        double  talb;
76 <        double  mabsorp;
75 >        COLOR  talb;
76          double  refl, trans;
77          FVECT  dnorm;
78          double  d1, d2;
# Line 100 | Line 99 | register RAY  *r;
99                  setcolor(r->cext, -mylog(m->oargs.farg[0]*colval(r->pcol,RED)),
100                                   -mylog(m->oargs.farg[1]*colval(r->pcol,GRN)),
101                                   -mylog(m->oargs.farg[2]*colval(r->pcol,BLU)));
102 <                r->albedo = 0.;
102 >                setcolor(r->albedo, 0., 0., 0.);
103                  r->gecc = 0.;
104                  if (m->otype == MAT_INTERFACE) {
105                          setcolor(ctrans,
106                                  -mylog(m->oargs.farg[4]*colval(r->pcol,RED)),
107                                  -mylog(m->oargs.farg[5]*colval(r->pcol,GRN)),
108                                  -mylog(m->oargs.farg[6]*colval(r->pcol,BLU)));
109 <                        talb = 0.;
109 >                        setcolor(talb, 0., 0., 0.);
110                  } else {
111                          copycolor(ctrans, cextinction);
112 <                        talb = salbedo;
112 >                        copycolor(talb, salbedo);
113                  }
114          } else {                                /* outside */
115                  nratio = 1.0 / nratio;
# Line 118 | Line 117 | register RAY  *r;
117                  setcolor(ctrans, -mylog(m->oargs.farg[0]*colval(r->pcol,RED)),
118                                   -mylog(m->oargs.farg[1]*colval(r->pcol,GRN)),
119                                   -mylog(m->oargs.farg[2]*colval(r->pcol,BLU)));
120 <                talb = 0.;
120 >                setcolor(talb, 0., 0., 0.);
121                  if (m->otype == MAT_INTERFACE) {
122                          setcolor(r->cext,
123                                  -mylog(m->oargs.farg[4]*colval(r->pcol,RED)),
124                                  -mylog(m->oargs.farg[5]*colval(r->pcol,GRN)),
125                                  -mylog(m->oargs.farg[6]*colval(r->pcol,BLU)));
126 <                        r->albedo = 0.;
126 >                        setcolor(r->albedo, 0., 0., 0.);
127                          r->gecc = 0.;
128                  }
129          }
131        mabsorp = exp(-bright(r->cext)*r->rot);         /* approximate */
130  
131          d2 = 1.0 - nratio*nratio*(1.0 - cos1*cos1);     /* compute cos theta2 */
132  
# Line 152 | Line 150 | register RAY  *r;
150                  refl *= 0.5;
151                  trans = 1.0 - refl;
152  
153 <                if (rayorigin(&p, r, REFRACTED, mabsorp*trans) == 0) {
153 >                if (rayorigin(&p, r, REFRACTED, trans) == 0) {
154  
155                                                  /* compute refracted ray */
156                          d1 = nratio*cos1 - cos2;
# Line 165 | Line 163 | register RAY  *r;
163                                          || r->crtype & SHADOW
164                                          || !directvis
165                                          || m->oargs.farg[4] == 0.0
166 <                                        || !disperse(m, r, p.rdir, trans))
166 >                                        || !disperse(m, r, p.rdir,
167 >                                                        trans, ctrans, talb))
168   #endif
169                          {
170                                  copycolor(p.cext, ctrans);
171 <                                p.albedo = talb;
171 >                                copycolor(p.albedo, talb);
172                                  rayvalue(&p);
173                                  scalecolor(p.rcol, trans);
174                                  addcolor(r->rcol, p.rcol);
# Line 180 | Line 179 | register RAY  *r;
179          }
180                  
181          if (!(r->crtype & SHADOW) &&
182 <                        rayorigin(&p, r, REFLECTED, mabsorp*refl) == 0) {
182 >                        rayorigin(&p, r, REFLECTED, refl) == 0) {
183  
184                                          /* compute reflected ray */
185                  for (i = 0; i < 3; i++)
# Line 199 | Line 198 | register RAY  *r;
198   #ifdef  DISPERSE
199  
200   static
201 < disperse(m, r, vt, tr)          /* check light sources for dispersion */
201 > disperse(m, r, vt, tr, cet, abt)  /* check light sources for dispersion */
202   OBJREC  *m;
203   RAY  *r;
204   FVECT  vt;
205   double  tr;
206 + COLOR  cet, abt;
207   {
208          RAY  sray, *entray;
209          FVECT  v1, v2, n1, n2;
# Line 289 | Line 289 | double  tr;
289                  if (l1 > MAXLAMBDA || l1 < MINLAMBDA)   /* not visible */
290                          continue;
291                                                  /* trace source ray */
292 +                copycolor(sray.cext, cet);
293 +                copycolor(sray.albedo, abt);
294                  normalize(sray.rdir);
295                  rayvalue(&sray);
296                  if (bright(sray.rcol) <= FTINY) /* missed it */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines