--- ray/src/rt/raytrace.c 1996/03/21 15:33:05 2.24 +++ ray/src/rt/raytrace.c 1997/12/23 18:25:15 2.29 @@ -1,4 +1,4 @@ -/* Copyright (c) 1995 Regents of the University of California */ +/* Copyright (c) 1996 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -27,7 +27,7 @@ extern int do_irrad; /* compute irradiance? */ extern COLOR ambval; /* ambient value */ extern COLOR cextinction; /* global extinction coefficient */ -extern double salbedo; /* global scattering albedo */ +extern COLOR salbedo; /* global scattering albedo */ extern double seccg; /* global scattering eccentricity */ extern double ssampdist; /* scatter sampling distance */ @@ -62,7 +62,7 @@ double rw; r->clipset = NULL; r->revf = raytrace; copycolor(r->cext, cextinction); - r->albedo = salbedo; + copycolor(r->albedo, salbedo); r->gecc = seccg; r->slights = NULL; } else { /* spawned ray */ @@ -79,7 +79,7 @@ double rw; } r->revf = ro->revf; copycolor(r->cext, ro->cext); - r->albedo = ro->albedo; + copycolor(r->albedo, ro->albedo); r->gecc = ro->gecc; r->slights = ro->slights; r->rweight = ro->rweight * rw; @@ -96,12 +96,12 @@ register RAY *r; { r->rno = raynum++; r->newcset = r->clipset; + r->robj = OVOID; r->ro = NULL; - r->rot = FHUGE; + r->rt = r->rot = FHUGE; r->pert[0] = r->pert[1] = r->pert[2] = 0.0; setcolor(r->pcol, 1.0, 1.0, 1.0); setcolor(r->rcol, 0.0, 0.0, 0.0); - r->rt = 0.0; } @@ -189,29 +189,28 @@ rayparticipate(r) /* compute ray medium participatio register RAY *r; { COLOR ce, ca; - double dist; double re, ge, be; if (intens(r->cext) <= 1./FHUGE) return; /* no medium */ - if ((dist = r->rot) >= FHUGE) - dist = 2.*thescene.cusize; /* what to use for infinity? */ - if (r->crtype & SHADOW) - dist *= 1. - salbedo; /* no scattering for sources */ - if (dist <= FTINY) - return; /* no effective ray travel */ - re = dist*colval(r->cext,RED); - ge = dist*colval(r->cext,GRN); - be = dist*colval(r->cext,BLU); - setcolor(ce, re>92. ? 0. : exp(-re), - ge>92. ? 0. : exp(-ge), - be>92. ? 0. : exp(-be)); + re = r->rot*colval(r->cext,RED); + ge = r->rot*colval(r->cext,GRN); + be = r->rot*colval(r->cext,BLU); + if (r->crtype & SHADOW) { /* no scattering for sources */ + re *= 1. - colval(r->albedo,RED); + ge *= 1. - colval(r->albedo,GRN); + be *= 1. - colval(r->albedo,BLU); + } + setcolor(ce, re<=0. ? 1. : re>92. ? 0. : exp(-re), + ge<=0. ? 1. : ge>92. ? 0. : exp(-ge), + be<=0. ? 1. : be>92. ? 0. : exp(-be)); multcolor(r->rcol, ce); /* path absorption */ - if (r->albedo <= FTINY || r->crtype & SHADOW) + if (r->crtype & SHADOW || intens(r->albedo) <= FTINY) return; /* no scattering */ - setcolor(ca, salbedo*colval(ambval,RED)*(1.-colval(ce,RED)), - salbedo*colval(ambval,GRN)*(1.-colval(ce,GRN)), - salbedo*colval(ambval,BLU)*(1.-colval(ce,BLU))); + setcolor(ca, + colval(r->albedo,RED)*colval(ambval,RED)*(1.-colval(ce,RED)), + colval(r->albedo,GRN)*colval(ambval,GRN)*(1.-colval(ce,GRN)), + colval(r->albedo,BLU)*colval(ambval,BLU)*(1.-colval(ce,BLU))); addcolor(r->rcol, ca); /* ambient in scattering */ srcscatter(r); /* source in scattering */ } @@ -555,7 +554,8 @@ OBJECT *cxs; checkset(oset, cxs); /* eliminate double-checking */ for (i = oset[0]; i > 0; i--) { o = objptr(oset[i]); - (*ofun[o->otype].funp)(o, r); + if ((*ofun[o->otype].funp)(o, r)) + r->robj = oset[i]; } if (r->ro == NULL) return(0); /* no scores yet */