--- ray/src/rt/m_brdf.c 2018/11/13 19:58:33 2.36 +++ ray/src/rt/m_brdf.c 2019/02/13 02:38:26 2.38 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: m_brdf.c,v 2.36 2018/11/13 19:58:33 greg Exp $"; +static const char RCSid[] = "$Id: m_brdf.c,v 2.38 2019/02/13 02:38:26 greg Exp $"; #endif /* * Shading for materials with arbitrary BRDF's @@ -284,7 +284,8 @@ m_brdf( /* color a ray that hit a BRDTfunc material rayvalue(&sr); multcolor(sr.rcol, sr.rcoef); addcolor(r->rcol, sr.rcol); - if (!hastexture || r->crtype & (SHADOW|AMBIENT)) + if ((!hastexture || r->crtype & (SHADOW|AMBIENT)) && + nd.tspec > bright(nd.tdiff) + bright(nd.rdiff)) r->rxt = r->rot + raydistance(&sr); } if (r->crtype & SHADOW) /* the rest is shadow */ @@ -407,7 +408,7 @@ m_brdf2( /* color a ray that hit a BRDF material */ multambient(ctmp, r, nd.pnorm); addcolor(r->rcol, ctmp); /* add to returned color */ } - if (nd.trans > FTINY) { /* from other side */ + if (nd.trans > FTINY) { /* from other side */ flipsurface(r); vtmp[0] = -nd.pnorm[0]; vtmp[1] = -nd.pnorm[1]; @@ -436,10 +437,10 @@ setbrdfunc( /* set up brdf function and variables */ return(0); /* it's OK, setfunc says we're done */ /* else (re)assign special variables */ multv3(vec, np->pnorm, funcxf.xfm); - varset("NxP", '=', vec[0]/funcxf.sca); - varset("NyP", '=', vec[1]/funcxf.sca); - varset("NzP", '=', vec[2]/funcxf.sca); - varset("RdotP", '=', np->pdot <= -1.0 ? -1.0 : + varset("NxP`", '=', vec[0]/funcxf.sca); + varset("NyP`", '=', vec[1]/funcxf.sca); + varset("NzP`", '=', vec[2]/funcxf.sca); + varset("RdotP`", '=', np->pdot <= -1.0 ? -1.0 : np->pdot >= 1.0 ? 1.0 : np->pdot); varset("CrP", '=', colval(np->mcolor,RED)); varset("CgP", '=', colval(np->mcolor,GRN));