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

Comparing ray/src/rt/aniso.c (file contents):
Revision 2.54 by greg, Sun Jul 29 19:01:39 2012 UTC vs.
Revision 2.55 by greg, Sun Jul 29 21:56:16 2012 UTC

# Line 61 | Line 61 | typedef struct {
61          double  pdot;           /* perturbed dot product */
62   }  ANISODAT;            /* anisotropic material data */
63  
64 < static void getacoords(RAY  *r, ANISODAT  *np);
65 < static void agaussamp(RAY  *r, ANISODAT  *np);
64 > static void getacoords(ANISODAT  *np);
65 > static void agaussamp(ANISODAT  *np);
66  
67  
68   static void
# Line 266 | Line 266 | m_aniso(                       /* shade ray that hit something anisotropic
266          if (r->ro != NULL && isflat(r->ro->otype))
267                  nd.specfl |= SP_FLAT;
268  
269 <        getacoords(r, &nd);                     /* set up coordinates */
269 >        getacoords(&nd);                        /* set up coordinates */
270  
271          if (nd.specfl & (SP_REFL|SP_TRAN) && !(nd.specfl & SP_BADU))
272 <                agaussamp(r, &nd);
272 >                agaussamp(&nd);
273  
274          if (nd.rdiff > FTINY) {         /* ambient from this side */
275                  copycolor(ctmp, nd.mcolor);     /* modified by material color */
# Line 304 | Line 304 | m_aniso(                       /* shade ray that hit something anisotropic
304  
305   static void
306   getacoords(             /* set up coordinate system */
307        RAY  *r,
307          ANISODAT  *np
308   )
309   {
# Line 312 | Line 311 | getacoords(            /* set up coordinate system */
311          int  i;
312  
313          mf = getfunc(np->mp, 3, 0x7, 1);
314 <        setfunc(np->mp, r);
314 >        setfunc(np->mp, np->rp);
315          errno = 0;
316          for (i = 0; i < 3; i++)
317                  np->u[i] = evalue(mf->ep[i]);
# Line 335 | Line 334 | getacoords(            /* set up coordinate system */
334  
335   static void
336   agaussamp(              /* sample anisotropic Gaussian specular */
338        RAY  *r,
337          ANISODAT  *np
338   )
339   {
# Line 348 | Line 346 | agaussamp(             /* sample anisotropic Gaussian specular */
346          int  i;
347                                          /* compute reflection */
348          if ((np->specfl & (SP_REFL|SP_RBLT)) == SP_REFL &&
349 <                        rayorigin(&sr, SPECULAR, r, np->scolor) == 0) {
349 >                        rayorigin(&sr, SPECULAR, np->rp, np->scolor) == 0) {
350                  nstarget = 1;
351                  if (specjitter > 1.5) { /* multiple samples? */
352 <                        nstarget = specjitter*r->rweight + .5;
352 >                        nstarget = specjitter*np->rp->rweight + .5;
353                          if (sr.rweight <= minweight*nstarget)
354                                  nstarget = sr.rweight/minweight;
355                          if (nstarget > 1) {
# Line 388 | Line 386 | agaussamp(             /* sample anisotropic Gaussian specular */
386                          for (i = 0; i < 3; i++)
387                                  h[i] = np->pnorm[i] +
388                                          d*(cosp*np->u[i] + sinp*np->v[i]);
389 <                        d = -2.0 * DOT(h, r->rdir) / (1.0 + d*d);
390 <                        VSUM(sr.rdir, r->rdir, h, d);
389 >                        d = -2.0 * DOT(h, np->rp->rdir) / (1.0 + d*d);
390 >                        VSUM(sr.rdir, np->rp->rdir, h, d);
391                                                  /* sample rejection test */
392 <                        if ((d = DOT(sr.rdir, r->ron)) <= FTINY)
392 >                        if ((d = DOT(sr.rdir, np->rp->ron)) <= FTINY)
393                                  continue;
394                          checknorm(sr.rdir);
395                          if (nstarget > 1) {     /* W-G-M-D adjustment */
396                                  if (nstaken) rayclear(&sr);
397                                  rayvalue(&sr);
398 <                                d = 2./(1. + r->rod/d);
398 >                                d = 2./(1. + np->rp->rod/d);
399                                  scalecolor(sr.rcol, d);
400                                  addcolor(scol, sr.rcol);
401                          } else {
402                                  rayvalue(&sr);
403                                  multcolor(sr.rcol, sr.rcoef);
404 <                                addcolor(r->rcol, sr.rcol);
404 >                                addcolor(np->rp->rcol, sr.rcol);
405                          }
406                          ++nstaken;
407                  }
# Line 411 | Line 409 | agaussamp(             /* sample anisotropic Gaussian specular */
409                          multcolor(scol, sr.rcoef);
410                          d = (double)nstarget/ntrials;
411                          scalecolor(scol, d);
412 <                        addcolor(r->rcol, scol);
412 >                        addcolor(np->rp->rcol, scol);
413                  }
414                  ndims--;
415          }
# Line 419 | Line 417 | agaussamp(             /* sample anisotropic Gaussian specular */
417          copycolor(sr.rcoef, np->mcolor);                /* modify by material color */
418          scalecolor(sr.rcoef, np->tspec);
419          if ((np->specfl & (SP_TRAN|SP_TBLT)) == SP_TRAN &&
420 <                        rayorigin(&sr, SPECULAR, r, sr.rcoef) == 0) {
420 >                        rayorigin(&sr, SPECULAR, np->rp, sr.rcoef) == 0) {
421                  nstarget = 1;
422                  if (specjitter > 1.5) { /* multiple samples? */
423 <                        nstarget = specjitter*r->rweight + .5;
423 >                        nstarget = specjitter*np->rp->rweight + .5;
424                          if (sr.rweight <= minweight*nstarget)
425                                  nstarget = sr.rweight/minweight;
426                          if (nstarget > 1) {
# Line 458 | Line 456 | agaussamp(             /* sample anisotropic Gaussian specular */
456                          for (i = 0; i < 3; i++)
457                                  sr.rdir[i] = np->prdir[i] +
458                                                  d*(cosp*np->u[i] + sinp*np->v[i]);
459 <                        if (DOT(sr.rdir, r->ron) >= -FTINY)
459 >                        if (DOT(sr.rdir, np->rp->ron) >= -FTINY)
460                                  continue;
461                          normalize(sr.rdir);     /* OK, normalize */
462                          if (nstaken)            /* multi-sampling */
463                                  rayclear(&sr);
464                          rayvalue(&sr);
465                          multcolor(sr.rcol, sr.rcoef);
466 <                        addcolor(r->rcol, sr.rcol);
466 >                        addcolor(np->rp->rcol, sr.rcol);
467                          ++nstaken;
468                  }
469                  ndims--;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines