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.32 by greg, Thu Aug 6 16:06:06 2015 UTC vs.
Revision 2.36 by greg, Tue Nov 13 19:58:33 2018 UTC

# Line 14 | Line 14 | static const char      RCSid[] = "$Id$";
14   #include  "otypes.h"
15   #include  "rtotypes.h"
16   #include  "func.h"
17 + #include  "pmapmat.h"
18  
19   /*
20   *      Arguments to this material include the color and specularity.
# Line 127 | Line 128 | dirbrdf(               /* compute source contribution */
128                  scalecolor(ctmp, dtmp);
129                  addcolor(cval, ctmp);
130          }
131 <        if (ldot > 0.0 ? np->rspec <= FTINY : np->tspec <= FTINY)
131 >        if ((ldot > 0.0 ? np->rspec <= FTINY : np->tspec <= FTINY) ||
132 >                        ambRayInPmap(np->pr))
133                  return;         /* diffuse only */
134                                          /* set up function */
135          setbrdfunc(np);
# Line 207 | Line 209 | m_brdf(                        /* color a ray that hit a BRDTfunc material
209          int  hitfront = 1;
210          BRDFDAT  nd;
211          RAY  sr;
210        double  mirtest=0, mirdist=0;
211        double  transtest=0, transdist=0;
212          int  hasrefl, hastrans;
213          int  hastexture;
214          COLOR  ctmp;
# Line 239 | Line 239 | m_brdf(                        /* color a ray that hit a BRDTfunc material
239                          m->oargs.farg[8]);
240                                                  /* get modifiers */
241          raytexture(r, m->omod);
242 <        hastexture = DOT(r->pert,r->pert) > FTINY*FTINY;
242 >        hastexture = (DOT(r->pert,r->pert) > FTINY*FTINY);
243          if (hastexture) {                       /* perturb normal */
244                  nd.pdot = raynormal(nd.pnorm, r);
245          } else {
# Line 257 | Line 257 | m_brdf(                        /* color a ray that hit a BRDTfunc material
257          copycolor(nd.mcolor, r->pcol);          /* get pattern color */
258          multcolor(nd.rdiff, nd.mcolor);         /* modify diffuse values */
259          multcolor(nd.tdiff, nd.mcolor);
260 <        hasrefl = bright(nd.rdiff) > FTINY;
261 <        hastrans = bright(nd.tdiff) > FTINY;
260 >        hasrefl = (bright(nd.rdiff) > FTINY);
261 >        hastrans = (bright(nd.tdiff) > FTINY);
262                                                  /* load cal file */
263          nd.dp = NULL;
264          mf = getfunc(m, 9, 0x3f, 0);
# Line 271 | Line 271 | m_brdf(                        /* color a ray that hit a BRDTfunc material
271          if ((errno == EDOM) | (errno == ERANGE))
272                  objerror(m, WARNING, "compute error");
273          else if (rayorigin(&sr, TRANS, r, ctmp) == 0) {
274 <                if (!(r->crtype & SHADOW) && hastexture) {
274 >                if (hastexture && !(r->crtype & (SHADOW|AMBIENT))) {
275                                                  /* perturb direction */
276 <                        VSUM(sr.rdir, r->rdir, r->pert, -.75);
276 >                        VSUB(sr.rdir, r->rdir, r->pert);
277                          if (normalize(sr.rdir) == 0.0) {
278                                  objerror(m, WARNING, "illegal perturbation");
279                                  VCOPY(sr.rdir, r->rdir);
# Line 284 | 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) {
288 <                        transtest = 2.0*bright(sr.rcol);
289 <                        transdist = r->rot + sr.rt;
290 <                }
287 >                if (!hastexture || r->crtype & (SHADOW|AMBIENT))
288 >                        r->rxt = r->rot + raydistance(&sr);
289          }
290          if (r->crtype & SHADOW)                 /* the rest is shadow */
291                  return(1);
292 +
293                                                  /* compute reflected ray */
294          setbrdfunc(&nd);
295          errno = 0;
# Line 304 | Line 303 | m_brdf(                        /* color a ray that hit a BRDTfunc material
303                  checknorm(sr.rdir);
304                  rayvalue(&sr);
305                  multcolor(sr.rcol, sr.rcoef);
306 +                copycolor(r->mcol, sr.rcol);
307                  addcolor(r->rcol, sr.rcol);
308 <                if (!hastexture && r->ro != NULL && isflat(r->ro->otype)) {
309 <                        mirtest = 2.0*bright(sr.rcol);
310 <                        mirdist = r->rot + sr.rt;
311 <                }
308 >                if (r->ro != NULL && isflat(r->ro->otype) &&
309 >                                !hastexture | (r->crtype & AMBIENT))
310 >                        r->rmt = r->rot + raydistance(&sr);
311          }
312                                                  /* compute ambient */
313          if (hasrefl) {
# Line 334 | Line 333 | m_brdf(                        /* color a ray that hit a BRDTfunc material
333          }
334          if (hasrefl | hastrans || m->oargs.sarg[6][0] != '0')
335                  direct(r, dirbrdf, &nd);        /* add direct component */
337
338        d = bright(r->rcol);                    /* set effective distance */
339        if (transtest > d)
340                r->rt = transdist;
341        else if (mirtest > d)
342                r->rt = mirdist;
336  
337          return(1);
338   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines