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.30 by greg, Wed Aug 7 05:10:09 2013 UTC vs.
Revision 2.35 by greg, Wed Jan 10 17:45:11 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 140 | Line 142 | dirbrdf(               /* compute source contribution */
142          lddx[3] = omega;
143                                          /* compute BRTDF */
144          if (np->mp->otype == MAT_BRTDF) {
145 <                if (sa[6][0] == '0')            /* special case */
145 >                if (sa[6][0] == '0' && !sa[6][1])       /* special case */
146                          colval(ctmp,RED) = 0.0;
147                  else
148                          colval(ctmp,RED) = funvalue(sa[6], 4, lddx);
149 <                if (sa[7][0] == '0')
149 >                if (sa[7][0] == '0' && !sa[7][1])
150                          colval(ctmp,GRN) = 0.0;
151                  else if (!strcmp(sa[7],sa[6]))
152                          colval(ctmp,GRN) = colval(ctmp,RED);
153                  else
154                          colval(ctmp,GRN) = funvalue(sa[7], 4, lddx);
155 <                if (!strcmp(sa[8],sa[6]))
155 >                if (sa[8][0] == '0' && !sa[8][1])
156 >                        colval(ctmp,BLU) = 0.0;
157 >                else if (!strcmp(sa[8],sa[6]))
158                          colval(ctmp,BLU) = colval(ctmp,RED);
159                  else if (!strcmp(sa[8],sa[7]))
160                          colval(ctmp,BLU) = colval(ctmp,GRN);
# Line 205 | 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=0;
213 <        double  transtest=0, transdist=0;
212 >        double  mirtest=0, mirdist;
213 >        double  transtest=0, transdist;
214          int  hasrefl, hastrans;
215          int  hastexture;
216          COLOR  ctmp;
# Line 237 | Line 241 | m_brdf(                        /* color a ray that hit a BRDTfunc material
241                          m->oargs.farg[8]);
242                                                  /* get modifiers */
243          raytexture(r, m->omod);
244 <        hastexture = DOT(r->pert,r->pert) > FTINY*FTINY;
244 >        hastexture = (DOT(r->pert,r->pert) > FTINY*FTINY);
245          if (hastexture) {                       /* perturb normal */
246                  nd.pdot = raynormal(nd.pnorm, r);
247          } else {
# Line 255 | Line 259 | m_brdf(                        /* color a ray that hit a BRDTfunc material
259          copycolor(nd.mcolor, r->pcol);          /* get pattern color */
260          multcolor(nd.rdiff, nd.mcolor);         /* modify diffuse values */
261          multcolor(nd.tdiff, nd.mcolor);
262 <        hasrefl = bright(nd.rdiff) > FTINY;
263 <        hastrans = bright(nd.tdiff) > FTINY;
262 >        hasrefl = (bright(nd.rdiff) > FTINY);
263 >        hastrans = (bright(nd.tdiff) > FTINY);
264 >        mirdist = transdist = r->rot;
265                                                  /* load cal file */
266          nd.dp = NULL;
267          mf = getfunc(m, 9, 0x3f, 0);
# Line 269 | Line 274 | m_brdf(                        /* color a ray that hit a BRDTfunc material
274          if ((errno == EDOM) | (errno == ERANGE))
275                  objerror(m, WARNING, "compute error");
276          else if (rayorigin(&sr, TRANS, r, ctmp) == 0) {
277 <                if (!(r->crtype & SHADOW) && hastexture) {
277 >                if (hastexture && !(r->crtype & (SHADOW|AMBIENT))) {
278                                                  /* perturb direction */
279 <                        VSUM(sr.rdir, r->rdir, r->pert, -.75);
279 >                        VSUB(sr.rdir, r->rdir, r->pert);
280                          if (normalize(sr.rdir) == 0.0) {
281                                  objerror(m, WARNING, "illegal perturbation");
282                                  VCOPY(sr.rdir, r->rdir);
# Line 282 | Line 287 | m_brdf(                        /* color a ray that hit a BRDTfunc material
287                  rayvalue(&sr);
288                  multcolor(sr.rcol, sr.rcoef);
289                  addcolor(r->rcol, sr.rcol);
290 <                if (!hastexture) {
290 >                if (!hastexture || r->crtype & (SHADOW|AMBIENT)) {
291                          transtest = 2.0*bright(sr.rcol);
292                          transdist = r->rot + sr.rt;
293                  }
294          }
295 <        if (r->crtype & SHADOW)                 /* the rest is shadow */
295 >        if (r->crtype & SHADOW) {               /* the rest is shadow */
296 >                r->rt = transdist;
297                  return(1);
298 +        }
299                                                  /* compute reflected ray */
300          setbrdfunc(&nd);
301          errno = 0;
# Line 363 | Line 370 | m_brdf2(                       /* color a ray that hit a BRDF material */
370                  objerror(m, USER, "bad # arguments");
371                                                  /* check for back side */
372          if (r->rod < 0.0) {
373 <                if (!backvis && m->otype != MAT_TFUNC
367 <                                && m->otype != MAT_TDATA) {
373 >                if (!backvis) {
374                          raytrans(r);
375                          return(1);
376                  }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines