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

Comparing ray/src/rt/pmapmat.c (file contents):
Revision 2.20 by rschregle, Thu Dec 6 12:21:38 2018 UTC vs.
Revision 2.23 by rschregle, Wed Jan 20 19:44:15 2021 UTC

# Line 145 | Line 145 | void photonRay (const RAY *rayIn, RAY *rayOut,
145   }
146  
147  
148
148   static void addPhotons (const RAY *r)
149   /* Insert photon hits, where applicable */
150   {
151     if (!r -> rlvl)
152 <      /* Add direct photon map at primary hitpoint */
152 >      /* Add direct photon at primary hitpoint */
153        newPhoton(directPmap, r);
154     else {
155 <      /* Add global or precomputed photon map at indirect hitpoint */
155 >      /* Add global or precomputed photon at indirect hitpoint */
156        newPhoton(preCompPmap ? preCompPmap : globalPmap, r);
157  
158        /* Store caustic photon if specular flag set */
# Line 319 | Line 318 | static int normalPhotonScatter (OBJREC *mat, RAY *rayI
318        }
319     else raytexture(rayIn, mat -> omod);
320    
321 +   nd.mp = mat;
322     nd.rp = rayIn;
323    
324     /* Get material color */
# Line 480 | Line 480 | static int normalPhotonScatter (OBJREC *mat, RAY *rayI
480  
481  
482  
483 < static void getacoords (ANISODAT *np)
483 > static void getacoords (ANISODAT *nd)
484   /* Set up coordinate system for anisotropic sampling; cloned from aniso.c */
485   {
486 <   MFUNC  *mf;
487 <   int  i;
486 >   MFUNC *mf;
487 >   int   i;
488  
489 <   mf = getfunc(np->mp, 3, 0x7, 1);
490 <   setfunc(np->mp, np->rp);
489 >   mf = getfunc(nd -> mp, 3, 0x7, 1);
490 >   setfunc(nd -> mp, nd -> rp);
491     errno = 0;
492  
493     for (i = 0; i < 3; i++)
494 <      np->u[i] = evalue(mf->ep[i]);
494 >      nd -> u [i] = evalue(mf -> ep [i]);
495    
496 <   if ((errno == EDOM) | (errno == ERANGE)) {
497 <      objerror(np->mp, WARNING, "compute error");
498 <      np->specfl |= SP_BADU;
499 <      return;
500 <   }
501 <  
502 <   if (mf->fxp != &unitxf)
503 <      multv3(np->u, np->u, mf->fxp->xfm);
496 >   if (errno == EDOM || errno == ERANGE)
497 >      nd -> u [0] = nd -> u [1] = nd -> u [2] = 0.0;
498        
499 <   fcross(np->v, np->pnorm, np->u);
499 >   if (mf -> fxp != &unitxf)
500 >      multv3(nd -> u, nd -> u, mf -> fxp -> xfm);
501  
502 <   if (normalize(np->v) == 0.0) {
508 <      objerror(np->mp, WARNING, "illegal orientation vector");
509 <      np->specfl |= SP_BADU;
510 <      return;
511 <   }
502 >   fcross(nd -> v, nd -> pnorm, nd -> u);
503    
504 <   fcross(np->u, np->v, np->pnorm);
504 >   if (normalize(nd -> v) == 0.0) {
505 >      if (fabs(nd -> u_alpha - nd -> v_alpha) > 0.001)
506 >         objerror(nd -> mp, WARNING, "illegal orientation vector");
507 >      getperpendicular(nd -> u, nd -> pnorm, 1);
508 >      fcross(nd -> v, nd -> pnorm, nd -> u);
509 >      nd -> u_alpha = nd -> v_alpha =
510 >         sqrt(0.5 * (sqr(nd -> u_alpha) + sqr(nd -> v_alpha)));
511 >   }
512 >   else fcross(nd -> u, nd -> v, nd -> pnorm);
513   }
514  
515  
# Line 616 | Line 615 | static int anisoPhotonScatter (OBJREC *mat, RAY *rayIn
615     if (mat -> oargs.nfargs != (mat -> otype == MAT_TRANS2 ? 8 : 6))
616        objerror(mat, USER, "bad number of real arguments");
617        
618 +   nd.mp = mat;
619     nd.rp = rayIn;
620   nd.mp = objptr(rayIn -> ro -> omod);
620    
621     /* get material color */
622     copycolor(nd.mcolor, mat -> oargs.farg);
# Line 661 | Line 660 | static int anisoPhotonScatter (OBJREC *mat, RAY *rayIn
660     if (nd.rspec > FTINY) {
661        nd.specfl |= SP_REFL;
662        
663 <      /* comput   e specular color */
663 >      /* compute specular color */
664        if (mat -> otype == MAT_METAL2)
665           copycolor(nd.scolor, nd.mcolor);
666        else setcolor(nd.scolor, 1, 1, 1);
# Line 1033 | Line 1032 | static int aliasPhotonScatter (OBJREC *mat, RAY *rayIn
1032     /* Replacement scattering routine */
1033     photonScatter [aliasRec.otype] (&aliasRec, rayIn);
1034  
1036 #if 0
1035     /* Avoid potential memory leak? */
1036     if (aliasRec.os != aliasPtr -> os) {
1037 <      if (aliasObj -> os)
1038 <         free_os(aliasObj);
1037 >      if (aliasPtr -> os)
1038 >         free_os(aliasPtr);
1039        aliasPtr -> os = aliasRec.os;
1040     }
1043 #endif
1041  
1042     return 0;
1043   }
# Line 1490 | Line 1487 | static int brdfPhotonScatter (OBJREC *mat, RAY *rayIn)
1487     /* Check argz */
1488     if (mat -> oargs.nsargs < 10 || mat -> oargs.nfargs < 9)
1489        objerror(mat, USER, "bad # arguments");
1490 +      
1491     nd.mp = mat;
1492     nd.pr = rayIn;
1493     /* Dummiez */
# Line 1580 | Line 1578 | static int brdfPhotonScatter (OBJREC *mat, RAY *rayIn)
1578              objerror(mat, WARNING, "illegal perturbation");
1579              VCOPY(rayOut.rdir, rayIn -> rdir);
1580           }
1583         else VCOPY(rayOut.rdir, rayIn -> rdir);
1581        }
1582 +      else VCOPY(rayOut.rdir, rayIn -> rdir);
1583     }
1584     else if (xi > (albedo -= prDiff)) {
1585        /* Diffuz reflekzion */
# Line 1638 | Line 1636 | int brdf2PhotonScatter (OBJREC *mat, RAY *rayIn)
1636  
1637     nd.mp = mat;
1638     nd.pr = rayIn;
1639 +  
1640     /* Material kolour */
1641     setcolor(nd.mcolor, mat -> oargs.farg [0], mat -> oargs.farg [1],
1642              mat -> oargs.farg [2]);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines