--- ray/src/rt/m_bsdf.c 2018/08/08 04:15:18 2.54 +++ ray/src/rt/m_bsdf.c 2019/06/10 13:56:52 2.57 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: m_bsdf.c,v 2.54 2018/08/08 04:15:18 greg Exp $"; +static const char RCSid[] = "$Id: m_bsdf.c,v 2.57 2019/06/10 13:56:52 greg Exp $"; #endif /* * Shading for materials with BSDFs taken from XML data files @@ -116,7 +116,7 @@ compute_through(BSDFDAT *ndp) {0, -1.6}, {1.6, 0}, }; - const double peak_over = 1.5; + const double peak_over = 1.3 + .4*frandom(); /* jitter threshold */ SDSpectralDF *dfp; FVECT pdir; double tomega, srchrad; @@ -555,6 +555,7 @@ sample_sdf(BSDFDAT *ndp, int sflags) rayvalue(&tr); multcolor(tr.rcol, tr.rcoef); addcolor(ndp->pr->rcol, tr.rcol); + ndp->pr->rxt = ndp->pr->rot + raydistance(&tr); ++ntotal; b = bright(ndp->cthru); } else @@ -634,8 +635,10 @@ m_bsdf(OBJREC *m, RAY *r) /* get BSDF data */ nd.sd = loadBSDF(m->oargs.sarg[hasthick]); /* early shadow check #2 */ - if (r->crtype & SHADOW && (nd.sd->tf == NULL) & (nd.sd->tb == NULL)) + if (r->crtype & SHADOW && (nd.sd->tf == NULL) & (nd.sd->tb == NULL)) { + SDfreeCache(nd.sd); return(1); + } /* diffuse reflectance */ if (hitfront) { cvt_sdcolor(nd.rdiff, &nd.sd->rLambFront); @@ -691,6 +694,7 @@ m_bsdf(OBJREC *m, RAY *r) } if (ec) { objerror(m, WARNING, "Illegal orientation vector"); + SDfreeCache(nd.sd); return(1); } setcolor(nd.cthru, 0, 0, 0); /* consider through component */ @@ -698,6 +702,7 @@ m_bsdf(OBJREC *m, RAY *r) compute_through(&nd); if (r->crtype & SHADOW) { RAY tr; /* attempt to pass shadow ray */ + SDfreeCache(nd.sd); if (rayorigin(&tr, TRANS, r, nd.cthru) < 0) return(1); /* no through component */ VCOPY(tr.rdir, r->rdir);