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.8 by greg, Fri May 10 08:51:02 1991 UTC vs.
Revision 1.12 by greg, Fri Jun 28 10:04:02 1991 UTC

# Line 122 | Line 122 | double  omega;                 /* light source size */
122          if (ldot > 0.0 ? np->rspec <= FTINY : np->tspec <= FTINY)
123                  return;         /* no specular component */
124                                          /* set up function */
125 <        setfunc(np->mp, np->pr);
125 >        setbrdfunc(np);
126          sa = np->mp->oargs.sarg;
127          errno = 0;
128                                          /* transform light vector */
# Line 192 | Line 192 | register RAY  *r;
192          double  transtest, transdist;
193          COLOR  ctmp;
194          double  dtmp;
195        FVECT  vec;
195          register int  i;
196                                                  /* check arguments */
197          switch (m->otype) {
# Line 237 | Line 236 | register RAY  *r;
236          raytexture(r, m->omod);
237          nd.pdot = raynormal(nd.pnorm, r);       /* perturb normal */
238          multcolor(nd.mcolor, r->pcol);          /* modify material color */
240        r->rt = r->rot;                         /* default ray length */
239          transtest = 0;
240                                                  /* load auxiliary files */
241          if (m->otype == MAT_PDATA || m->otype == MAT_MDATA
# Line 260 | Line 258 | register RAY  *r;
258                          loadfunc(m->oargs.sarg[1]);
259          }
260                                                  /* set special variables */
261 <        setfunc(m, r);
264 <        multv3(vec, nd.pnorm, funcxf.xfm);
265 <        varset("NxP", '=', vec[0]/funcxf.sca);
266 <        varset("NyP", '=', vec[1]/funcxf.sca);
267 <        varset("NzP", '=', vec[2]/funcxf.sca);
268 <        varset("RdotP", '=', nd.pdot);
269 <        varset("CrP", '=', colval(nd.mcolor,RED));
270 <        varset("CgP", '=', colval(nd.mcolor,GRN));
271 <        varset("CbP", '=', colval(nd.mcolor,BLU));
261 >        setbrdfunc(&nd);
262                                                  /* compute transmitted ray */
263          if (m->otype == MAT_BRTDF && nd.tspec > FTINY) {
264                  RAY  sr;
265                  errno = 0;
266 <                setcolor(ctmp, varvalue(m->oargs.sarg[0]),
267 <                                varvalue(m->oargs.sarg[1]),
268 <                                varvalue(m->oargs.sarg[2]));
266 >                setcolor(ctmp, varvalue(m->oargs.sarg[3]),
267 >                                varvalue(m->oargs.sarg[4]),
268 >                                varvalue(m->oargs.sarg[5]));
269                  scalecolor(ctmp, nd.tspec);
270                  if (errno)
271                          objerror(m, WARNING, "compute error");
# Line 303 | Line 293 | register RAY  *r;
293          if (m->otype == MAT_BRTDF && nd.rspec > FTINY) {
294                  RAY  sr;
295                  errno = 0;
296 <                setcolor(ctmp, varvalue(m->oargs.sarg[3]),
297 <                                varvalue(m->oargs.sarg[4]),
298 <                                varvalue(m->oargs.sarg[5]));
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);
300                  if (errno)
301                          objerror(m, WARNING, "compute error");
# Line 345 | Line 335 | register RAY  *r;
335                                                  /* check distance */
336          if (transtest > bright(r->rcol))
337                  r->rt = transdist;
338 + }
339 +
340 +
341 + setbrdfunc(np)                  /* set up brdf function and variables */
342 + register BRDFDAT  *np;
343 + {
344 +        FVECT  vec;
345 +
346 +        if (setfunc(np->mp, np->pr) == 0)
347 +                return(0);      /* it's OK, setfunc says we're done */
348 +                                /* else (re)assign special variables */
349 +        multv3(vec, np->pnorm, funcxf.xfm);
350 +        varset("NxP", '=', vec[0]/funcxf.sca);
351 +        varset("NyP", '=', vec[1]/funcxf.sca);
352 +        varset("NzP", '=', vec[2]/funcxf.sca);
353 +        varset("RdotP", '=', np->pdot <= -1.0 ? -1.0 :
354 +                        np->pdot >= 1.0 ? 1.0 : np->pdot);
355 +        varset("CrP", '=', colval(np->mcolor,RED));
356 +        varset("CgP", '=', colval(np->mcolor,GRN));
357 +        varset("CbP", '=', colval(np->mcolor,BLU));
358 +        return(1);
359   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines