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 2.35 by greg, Wed Jan 10 17:45:11 2018 UTC vs.
Revision 2.39 by greg, Fri Apr 19 19:01:32 2019 UTC

# Line 209 | Line 209 | m_brdf(                        /* color a ray that hit a BRDTfunc material
209          int  hitfront = 1;
210          BRDFDAT  nd;
211          RAY  sr;
212        double  mirtest=0, mirdist;
213        double  transtest=0, transdist;
212          int  hasrefl, hastrans;
213          int  hastexture;
214          COLOR  ctmp;
# Line 261 | Line 259 | m_brdf(                        /* color a ray that hit a BRDTfunc material
259          multcolor(nd.tdiff, nd.mcolor);
260          hasrefl = (bright(nd.rdiff) > FTINY);
261          hastrans = (bright(nd.tdiff) > FTINY);
264        mirdist = transdist = r->rot;
262                                                  /* load cal file */
263          nd.dp = NULL;
264          mf = getfunc(m, 9, 0x3f, 0);
# Line 287 | Line 284 | m_brdf(                        /* color a ray that hit a BRDTfunc material
284                  rayvalue(&sr);
285                  multcolor(sr.rcol, sr.rcoef);
286                  addcolor(r->rcol, sr.rcol);
287 <                if (!hastexture || r->crtype & (SHADOW|AMBIENT)) {
288 <                        transtest = 2.0*bright(sr.rcol);
289 <                        transdist = r->rot + sr.rt;
293 <                }
287 >                if ((!hastexture || r->crtype & (SHADOW|AMBIENT)) &&
288 >                                nd.tspec > bright(nd.tdiff) + bright(nd.rdiff))
289 >                        r->rxt = r->rot + raydistance(&sr);
290          }
291 <        if (r->crtype & SHADOW) {               /* the rest is shadow */
296 <                r->rt = transdist;
291 >        if (r->crtype & SHADOW)                 /* the rest is shadow */
292                  return(1);
293 <        }
293 >
294                                                  /* compute reflected ray */
295          setbrdfunc(&nd);
296          errno = 0;
# Line 309 | Line 304 | m_brdf(                        /* color a ray that hit a BRDTfunc material
304                  checknorm(sr.rdir);
305                  rayvalue(&sr);
306                  multcolor(sr.rcol, sr.rcoef);
307 +                copycolor(r->mcol, sr.rcol);
308                  addcolor(r->rcol, sr.rcol);
309 <                if (!hastexture && r->ro != NULL && isflat(r->ro->otype)) {
310 <                        mirtest = 2.0*bright(sr.rcol);
311 <                        mirdist = r->rot + sr.rt;
312 <                }
309 >                r->rmt = r->rot;
310 >                if (r->ro != NULL && isflat(r->ro->otype) &&
311 >                                !hastexture | (r->crtype & AMBIENT))
312 >                        r->rmt += raydistance(&sr);
313          }
314                                                  /* compute ambient */
315          if (hasrefl) {
# Line 340 | Line 336 | m_brdf(                        /* color a ray that hit a BRDTfunc material
336          if (hasrefl | hastrans || m->oargs.sarg[6][0] != '0')
337                  direct(r, dirbrdf, &nd);        /* add direct component */
338  
343        d = bright(r->rcol);                    /* set effective distance */
344        if (transtest > d)
345                r->rt = transdist;
346        else if (mirtest > d)
347                r->rt = mirdist;
348
339          return(1);
340   }
341  
# Line 419 | Line 409 | m_brdf2(                       /* color a ray that hit a BRDF material */
409                  multambient(ctmp, r, nd.pnorm);
410                  addcolor(r->rcol, ctmp);        /* add to returned color */
411          }
412 <        if (nd.trans > FTINY) {         /* from other side */
412 >        if (nd.trans > FTINY) {                 /* from other side */
413                  flipsurface(r);
414                  vtmp[0] = -nd.pnorm[0];
415                  vtmp[1] = -nd.pnorm[1];
# Line 448 | Line 438 | setbrdfunc(                    /* set up brdf function and variables */
438                  return(0);      /* it's OK, setfunc says we're done */
439                                  /* else (re)assign special variables */
440          multv3(vec, np->pnorm, funcxf.xfm);
441 <        varset("NxP", '=', vec[0]/funcxf.sca);
442 <        varset("NyP", '=', vec[1]/funcxf.sca);
443 <        varset("NzP", '=', vec[2]/funcxf.sca);
444 <        varset("RdotP", '=', np->pdot <= -1.0 ? -1.0 :
441 >        varset("NxP`", '=', vec[0]/funcxf.sca);
442 >        varset("NyP`", '=', vec[1]/funcxf.sca);
443 >        varset("NzP`", '=', vec[2]/funcxf.sca);
444 >        varset("RdotP`", '=', np->pdot <= -1.0 ? -1.0 :
445                          np->pdot >= 1.0 ? 1.0 : np->pdot);
446          varset("CrP", '=', colval(np->mcolor,RED));
447          varset("CgP", '=', colval(np->mcolor,GRN));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines