--- ray/src/rt/raytrace.c 2015/05/21 15:28:24 2.67 +++ ray/src/rt/raytrace.c 2016/05/16 17:32:10 2.71 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: raytrace.c,v 2.67 2015/05/21 15:28:24 greg Exp $"; +static const char RCSid[] = "$Id: raytrace.c,v 2.71 2016/05/16 17:32:10 greg Exp $"; #endif /* * raytrace.c - routines for tracing and shading rays. @@ -51,6 +51,8 @@ rayorigin( /* start new ray from old one */ setcolor(r->rcoef, 1., 1., 1.); } else { rw = intens(rc); + if (rw > 1.0) + rw = 1.0; /* avoid calculation growth */ if (rc != r->rcoef) copycolor(r->rcoef, rc); } @@ -108,8 +110,12 @@ rayorigin( /* start new ray from old one */ if (r->crtype & SHADOW) /* shadow commitment */ return(0); /* ambient in photon map? */ - if (r->crtype & AMBIENT && photonMapping) - return(-1); + if (ro != NULL && ro->crtype & AMBIENT) { + if (causticPhotonMapping) + return(-1); + if (photonMapping && rt != TRANS) + return(-1); + } if (maxdepth <= 0 && rc != NULL) { /* Russian roulette */ if (minweight <= 0.0) error(USER, "zero ray weight in Russian roulette"); @@ -193,6 +199,11 @@ raytrans( /* transmit ray as is */ } +/* Macro for test to see if BSDF material uses proxy */ +#define isBSDFproxy(m) ((m)->otype == MAT_BSDF && (m)->oargs.nsargs && \ + strcmp((m)->oargs.sarg[0], "0")) + + int rayshade( /* shade ray r with material mod */ RAY *r, @@ -201,7 +212,7 @@ rayshade( /* shade ray r with material mod */ { OBJREC *m; - r->rt = r->rot; /* set effective ray length */ + r->rt = r->rot; /* preset effective ray length */ for ( ; mod != OVOID; mod = m->omod) { m = objptr(mod); /****** unnecessary test since modifier() is always called @@ -212,8 +223,9 @@ rayshade( /* shade ray r with material mod */ ******/ /* hack for irradiance calculation */ if (do_irrad && !(r->crtype & ~(PRIMARY|TRANS)) && + (ofun[m->otype].flags & (T_M|T_X)) && m->otype != MAT_CLIP && - (ofun[m->otype].flags & (T_M|T_X))) { + !isBSDFproxy(m)) { if (irr_ignore(m->otype)) { raytrans(r); return(1);