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.26 by rschregle, Wed May 20 13:12:06 2015 UTC vs.
Revision 2.32 by greg, Fri Nov 17 20:02:07 2023 UTC

# Line 51 | Line 51 | static double mylog(double  x);
51  
52   #define  MINCOS         0.997           /* minimum dot product for dispersion */
53  
54 < static
55 < double
54 > static double
55   mylog(          /* special log for extinction coefficients */
56          double  x
57   )
# Line 72 | Line 71 | m_dielectric(  /* color a ray which hit a dielectric in
71   )
72   {
73          double  cos1, cos2, nratio;
74 <        COLOR  ctrans;
76 <        COLOR  talb;
74 >        COLOR  pcol, ctrans, talb;
75          int  hastexture;
78        double  transdist=0, transtest=0;
79        double  mirdist=0, mirtest=0;
76          int     flatsurface;
77          double  refl, trans;
78          FVECT  dnorm;
# Line 108 | Line 104 | m_dielectric(  /* color a ray which hit a dielectric in
104                  nratio = m->oargs.farg[3] + m->oargs.farg[4]/MLAMBDA;
105          else
106                  nratio = m->oargs.farg[3] / m->oargs.farg[7];
107 <        
107 >
108 >        scolor_rgb(pcol, r->pcol);
109          if (cos1 < 0.0) {                       /* inside */
110                  hastexture = -hastexture;
111                  cos1 = -cos1;
112                  dnorm[0] = -dnorm[0];
113                  dnorm[1] = -dnorm[1];
114                  dnorm[2] = -dnorm[2];
115 <                setcolor(r->cext, -mylog(m->oargs.farg[0]*colval(r->pcol,RED)),
116 <                                 -mylog(m->oargs.farg[1]*colval(r->pcol,GRN)),
117 <                                 -mylog(m->oargs.farg[2]*colval(r->pcol,BLU)));
115 >                setcolor(r->cext, -mylog(m->oargs.farg[0]*colval(pcol,RED)),
116 >                                 -mylog(m->oargs.farg[1]*colval(pcol,GRN)),
117 >                                 -mylog(m->oargs.farg[2]*colval(pcol,BLU)));
118                  setcolor(r->albedo, 0., 0., 0.);
119                  r->gecc = 0.;
120                  if (m->otype == MAT_INTERFACE) {
121                          setcolor(ctrans,
122 <                                -mylog(m->oargs.farg[4]*colval(r->pcol,RED)),
123 <                                -mylog(m->oargs.farg[5]*colval(r->pcol,GRN)),
124 <                                -mylog(m->oargs.farg[6]*colval(r->pcol,BLU)));
122 >                                -mylog(m->oargs.farg[4]*colval(pcol,RED)),
123 >                                -mylog(m->oargs.farg[5]*colval(pcol,GRN)),
124 >                                -mylog(m->oargs.farg[6]*colval(pcol,BLU)));
125                          setcolor(talb, 0., 0., 0.);
126                  } else {
127                          copycolor(ctrans, cextinction);
# Line 133 | Line 130 | m_dielectric(  /* color a ray which hit a dielectric in
130          } else {                                /* outside */
131                  nratio = 1.0 / nratio;
132  
133 <                setcolor(ctrans, -mylog(m->oargs.farg[0]*colval(r->pcol,RED)),
134 <                                 -mylog(m->oargs.farg[1]*colval(r->pcol,GRN)),
135 <                                 -mylog(m->oargs.farg[2]*colval(r->pcol,BLU)));
133 >                setcolor(ctrans, -mylog(m->oargs.farg[0]*colval(pcol,RED)),
134 >                                 -mylog(m->oargs.farg[1]*colval(pcol,GRN)),
135 >                                 -mylog(m->oargs.farg[2]*colval(pcol,BLU)));
136                  setcolor(talb, 0., 0., 0.);
137                  if (m->otype == MAT_INTERFACE) {
138                          setcolor(r->cext,
139 <                                -mylog(m->oargs.farg[4]*colval(r->pcol,RED)),
140 <                                -mylog(m->oargs.farg[5]*colval(r->pcol,GRN)),
141 <                                -mylog(m->oargs.farg[6]*colval(r->pcol,BLU)));
139 >                                -mylog(m->oargs.farg[4]*colval(pcol,RED)),
140 >                                -mylog(m->oargs.farg[5]*colval(pcol,GRN)),
141 >                                -mylog(m->oargs.farg[6]*colval(pcol,BLU)));
142                          setcolor(r->albedo, 0., 0., 0.);
143                          r->gecc = 0.;
144                  }
# Line 171 | Line 168 | m_dielectric(  /* color a ray which hit a dielectric in
168  
169                  trans *= nratio*nratio;         /* solid angle ratio */
170  
171 <                setcolor(p.rcoef, trans, trans, trans);
171 >                setscolor(p.rcoef, trans, trans, trans);
172  
173                  if (rayorigin(&p, REFRACTED, r, p.rcoef) == 0) {
174  
# Line 202 | Line 199 | m_dielectric(  /* color a ray which hit a dielectric in
199                                  copycolor(p.cext, ctrans);
200                                  copycolor(p.albedo, talb);
201                                  rayvalue(&p);
202 <                                multcolor(p.rcol, p.rcoef);
203 <                                addcolor(r->rcol, p.rcol);
202 >                                smultscolor(p.rcol, p.rcoef);
203 >                                saddscolor(r->rcol, p.rcol);
204                                                  /* virtual distance */
205                                  if (flatsurface ||
206                                          (1.-FTINY <= nratio) &
207 <                                                (nratio <= 1.+FTINY)) {
208 <                                        transtest = 2*bright(p.rcol);
212 <                                        transdist = r->rot + p.rt;
213 <                                }
207 >                                                (nratio <= 1.+FTINY))
208 >                                        r->rxt = r->rot + raydistance(&p);
209                          }
210                  }
211          }
212 <        setcolor(p.rcoef, refl, refl, refl);
212 >        setscolor(p.rcoef, refl, refl, refl);
213  
214          if (!(r->crtype & SHADOW) &&
215                          rayorigin(&p, REFLECTED, r, p.rcoef) == 0) {
# Line 227 | Line 222 | m_dielectric(  /* color a ray which hit a dielectric in
222                  checknorm(p.rdir);
223                  rayvalue(&p);                   /* reflected ray value */
224  
225 <                multcolor(p.rcol, p.rcoef);     /* color contribution */
226 <                addcolor(r->rcol, p.rcol);
225 >                smultscolor(p.rcol, p.rcoef);   /* color contribution */
226 >                copyscolor(r->mcol, p.rcol);
227 >                saddscolor(r->rcol, p.rcol);
228                                                  /* virtual distance */
229 <                if (flatsurface) {
230 <                        mirtest = 2*bright(p.rcol);
231 <                        mirdist = r->rot + p.rt;
236 <                }
229 >                r->rmt = r->rot;
230 >                if (flatsurface)
231 >                        r->rmt += raydistance(&p);
232          }
238                                /* check distance to return */
239        d1 = bright(r->rcol);
240        if (transtest > d1)
241                r->rt = transdist;
242        else if (mirtest > d1)
243                r->rt = mirdist;
233                                  /* rayvalue() computes absorption */
234          return(1);
235   }
# Line 347 | Line 336 | disperse(  /* check light sources for dispersion */
336                  copycolor(sray.albedo, abt);
337                  normalize(sray.rdir);
338                  rayvalue(&sray);
339 <                if (bright(sray.rcol) <= FTINY) /* missed it */
339 >                if (pbright(sray.rcol) <= FTINY)        /* missed it */
340                          continue;
341                  
342                  /*
# Line 372 | Line 361 | disperse(  /* check light sources for dispersion */
361                  if (l2 < 0)
362                          continue;
363                                          /* compute color from spectrum */
364 <                if (l1 < l2)
364 >                if (l1 < l2)            /* XXX should use direct spectral xfer */
365                          spec_rgb(ctmp, l1, l2);
366                  else
367                          spec_rgb(ctmp, l2, l1);
368 <                multcolor(ctmp, sray.rcol);
368 >                multscolor(ctmp, sray.rcol);
369                  scalecolor(ctmp, tr);
370 <                addcolor(r->rcol, ctmp);
370 >                saddcolor(r->rcol, ctmp);
371                  success++;
372          }
373          return(success);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines