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

Comparing ray/src/rt/m_brdf.c (file contents):
Revision 1.12 by greg, Fri Jun 28 10:04:02 1991 UTC vs.
Revision 1.16 by greg, Mon Aug 12 08:20:53 1991 UTC

# Line 191 | Line 191 | register RAY  *r;
191          BRDFDAT  nd;
192          double  transtest, transdist;
193          COLOR  ctmp;
194 <        double  dtmp;
194 >        double  dtmp, tspect, rspecr;
195          register int  i;
196                                                  /* check arguments */
197          switch (m->otype) {
# Line 246 | Line 246 | register RAY  *r;
246                                  break;
247                  if (i-3 != nd.dp->nd)
248                          objerror(m, USER, "dimension error");
249 <                if (!fundefined(m->oargs.sarg[3]))
250 <                        loadfunc(m->oargs.sarg[2]);
249 >                funcfile(m->oargs.sarg[2]);
250          } else if (m->otype == MAT_BRTDF) {
251                  nd.dp = NULL;
252 <                if (!fundefined(m->oargs.sarg[7]))
254 <                        loadfunc(m->oargs.sarg[9]);
252 >                funcfile(m->oargs.sarg[9]);
253          } else {
254                  nd.dp = NULL;
255 <                if (!fundefined(m->oargs.sarg[0]))
258 <                        loadfunc(m->oargs.sarg[1]);
255 >                funcfile(m->oargs.sarg[1]);
256          }
257                                                  /* set special variables */
258          setbrdfunc(&nd);
259                                                  /* compute transmitted ray */
260 +        tspect = 0.;
261          if (m->otype == MAT_BRTDF && nd.tspec > FTINY) {
262                  RAY  sr;
263                  errno = 0;
264                  setcolor(ctmp, varvalue(m->oargs.sarg[3]),
265                                  varvalue(m->oargs.sarg[4]),
266                                  varvalue(m->oargs.sarg[5]));
267 <                scalecolor(ctmp, nd.tspec);
267 >                scalecolor(ctmp, nd.trans);
268                  if (errno)
269                          objerror(m, WARNING, "compute error");
270 <                else if ((dtmp = bright(ctmp)) > FTINY &&
271 <                                rayorigin(&sr, r, TRANS, dtmp) == 0) {
272 <                        if (DOT(r->pert,r->pert) > FTINY*FTINY) {
270 >                else if ((tspect = bright(ctmp)) > FTINY &&
271 >                                rayorigin(&sr, r, TRANS, tspect) == 0) {
272 >                        if (!(r->crtype & SHADOW) &&
273 >                                        DOT(r->pert,r->pert) > FTINY*FTINY) {
274                                  for (i = 0; i < 3; i++) /* perturb direction */
275                                          sr.rdir[i] = r->rdir[i] -
276                                                          .75*r->pert[i];
# Line 290 | Line 289 | register RAY  *r;
289          if (r->crtype & SHADOW)                 /* the rest is shadow */
290                  return;
291                                                  /* compute reflected ray */
292 +        rspecr = 0.;
293          if (m->otype == MAT_BRTDF && nd.rspec > FTINY) {
294                  RAY  sr;
295                  errno = 0;
296                  setcolor(ctmp, varvalue(m->oargs.sarg[0]),
297                                  varvalue(m->oargs.sarg[1]),
298                                  varvalue(m->oargs.sarg[2]));
299                scalecolor(ctmp, nd.rspec);
299                  if (errno)
300                          objerror(m, WARNING, "compute error");
301 <                else if ((dtmp = bright(ctmp)) > FTINY &&
302 <                                rayorigin(&sr, r, REFLECTED, dtmp) == 0) {
301 >                else if ((rspecr = bright(ctmp)) > FTINY &&
302 >                                rayorigin(&sr, r, REFLECTED, rspecr) == 0) {
303                          for (i = 0; i < 3; i++)
304                                  sr.rdir[i] = r->rdir[i] +
305                                                  2.0*nd.pdot*nd.pnorm[i];
# Line 310 | Line 309 | register RAY  *r;
309                  }
310          }
311                                                  /* compute ambient */
312 <        if (nd.rdiff > FTINY) {
312 >        if ((dtmp = 1.0-nd.trans-rspecr) > FTINY) {
313                  ambient(ctmp, r);
314 <                if (m->otype == MAT_BRTDF)
316 <                        scalecolor(ctmp, nd.rdiff);
317 <                else
318 <                        scalecolor(ctmp, 1.0-nd.trans);
314 >                scalecolor(ctmp, dtmp);
315                  multcolor(ctmp, nd.mcolor);     /* modified by material color */
316                  addcolor(r->rcol, ctmp);        /* add to returned color */
317          }
318 <        if (nd.tdiff > FTINY) {                 /* from other side */
318 >        if ((dtmp = nd.trans-tspect) > FTINY) { /* from other side */
319                  flipsurface(r);
320                  ambient(ctmp, r);
321 <                if (m->otype == MAT_BRTDF)
326 <                        scalecolor(ctmp, nd.tdiff);
327 <                else
328 <                        scalecolor(ctmp, nd.trans);
321 >                scalecolor(ctmp, dtmp);
322                  multcolor(ctmp, nd.mcolor);
323                  addcolor(r->rcol, ctmp);
324                  flipsurface(r);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines