--- ray/src/rt/srcsupp.c 1991/11/08 16:34:24 1.16 +++ ray/src/rt/srcsupp.c 1992/02/26 09:49:37 2.4 @@ -1,4 +1,4 @@ -/* Copyright (c) 1991 Regents of the University of California */ +/* Copyright (c) 1992 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -535,16 +535,26 @@ register RAY *r; #define distglow(m, r) (m->otype==MAT_GLOW && \ r->rot > m->oargs.farg[3]) -/* badambient * +/* badcomponent * * - * We must avoid including counting light sources in the ambient calculation, + * We must avoid counting light sources in the ambient calculation, * since the direct component is handled separately. Therefore, any * ambient ray which hits an active light source must be discarded. + * The same is true for stray specular samples, since the specular + * contribution from light sources is calculated separately. */ -#define badambient(m, r) ((r->crtype&(AMBIENT|SHADOW))==AMBIENT && \ - !distglow(m, r)) +#define badcomponent(m, r) (r->crtype&(AMBIENT|SPECULAR) && \ + !(r->crtype&SHADOW || r->rod < 0.0 || \ + distglow(m, r))) +/* overcount * + * + * All overcounting possibilities are contained here. + */ + +#define overcount(m, r) (badcomponent(m,r) || wrongsource(m,r)) + /* passillum * * * An illum passes to another material type when we didn't hit it @@ -570,7 +580,7 @@ register OBJREC *m; register RAY *r; { /* check for over-counting */ - if (wrongsource(m, r) || badambient(m, r)) + if (overcount(m, r)) return; /* check for passed illum */ if (passillum(m, r)) {