--- ray/src/rt/m_brdf.c 2018/01/10 17:45:11 2.35 +++ ray/src/rt/m_brdf.c 2018/11/13 19:58:33 2.36 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: m_brdf.c,v 2.35 2018/01/10 17:45:11 greg Exp $"; +static const char RCSid[] = "$Id: m_brdf.c,v 2.36 2018/11/13 19:58:33 greg Exp $"; #endif /* * Shading for materials with arbitrary BRDF's @@ -209,8 +209,6 @@ m_brdf( /* color a ray that hit a BRDTfunc material int hitfront = 1; BRDFDAT nd; RAY sr; - double mirtest=0, mirdist; - double transtest=0, transdist; int hasrefl, hastrans; int hastexture; COLOR ctmp; @@ -261,7 +259,6 @@ m_brdf( /* color a ray that hit a BRDTfunc material multcolor(nd.tdiff, nd.mcolor); hasrefl = (bright(nd.rdiff) > FTINY); hastrans = (bright(nd.tdiff) > FTINY); - mirdist = transdist = r->rot; /* load cal file */ nd.dp = NULL; mf = getfunc(m, 9, 0x3f, 0); @@ -287,15 +284,12 @@ 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)) { - transtest = 2.0*bright(sr.rcol); - transdist = r->rot + sr.rt; - } + if (!hastexture || r->crtype & (SHADOW|AMBIENT)) + r->rxt = r->rot + raydistance(&sr); } - if (r->crtype & SHADOW) { /* the rest is shadow */ - r->rt = transdist; + if (r->crtype & SHADOW) /* the rest is shadow */ return(1); - } + /* compute reflected ray */ setbrdfunc(&nd); errno = 0; @@ -309,11 +303,11 @@ m_brdf( /* color a ray that hit a BRDTfunc material checknorm(sr.rdir); rayvalue(&sr); multcolor(sr.rcol, sr.rcoef); + copycolor(r->mcol, sr.rcol); addcolor(r->rcol, sr.rcol); - if (!hastexture && r->ro != NULL && isflat(r->ro->otype)) { - mirtest = 2.0*bright(sr.rcol); - mirdist = r->rot + sr.rt; - } + if (r->ro != NULL && isflat(r->ro->otype) && + !hastexture | (r->crtype & AMBIENT)) + r->rmt = r->rot + raydistance(&sr); } /* compute ambient */ if (hasrefl) { @@ -339,12 +333,6 @@ m_brdf( /* color a ray that hit a BRDTfunc material } if (hasrefl | hastrans || m->oargs.sarg[6][0] != '0') direct(r, dirbrdf, &nd); /* add direct component */ - - d = bright(r->rcol); /* set effective distance */ - if (transtest > d) - r->rt = transdist; - else if (mirtest > d) - r->rt = mirdist; return(1); }