--- ray/src/rt/srcsupp.c 1991/10/21 12:58:16 1.14 +++ ray/src/rt/srcsupp.c 1991/11/08 16:34:24 1.16 @@ -174,7 +174,7 @@ register OBJREC *so; for (i = 0; i < 3; i++) src->ss[SU][i] = src->ss[SV][i] = src->ss[SW][i] = 0.0; for (i = 0; i < 3; i++) - src->ss[i][i] = .886227 * so->oargs.farg[3]; + src->ss[i][i] = .7236 * so->oargs.farg[3]; } @@ -212,9 +212,10 @@ OBJREC *so; co = getcone(so, 0); if (CO_R0(co) > .2*co->al) /* heuristic constraint */ objerror(so, WARNING, "source aspect too small"); + src->sflags |= SCYL; for (i = 0; i < 3; i++) src->sloc[i] = .5 * (CO_P1(co)[i] + CO_P0(co)[i]); - src->srad = co->al; + src->srad = .5*co->al; src->ss2 = 2.*CO_R0(co)*co->al; /* set sampling vectors */ for (i = 0; i < 3; i++) @@ -227,7 +228,7 @@ OBJREC *so; fcross(src->ss[SW], src->ss[SV], co->ad); normalize(src->ss[SW]); for (i = 0; i < 3; i++) - src->ss[SW][i] *= .886227 * CO_R0(co); + src->ss[SW][i] *= .8559 * CO_R0(co); fcross(src->ss[SV], src->ss[SW], co->ad); } @@ -499,19 +500,66 @@ register RAY *r; } -#define wrongsource(m, r) (r->rsrc>=0 && \ - source[r->rsrc].so!=r->ro && \ - (m->otype!=MAT_ILLUM || \ - objptr(source[r->rsrc].so->omod)->otype==MAT_ILLUM)) +/**************************************************************** + * The following macros were separated from the m_light() routine + * because they are very nasty and difficult to understand. + */ +/* wrongillum * + * + * We cannot allow an illum to pass to another illum, because that + * would almost certainly constitute overcounting. + * However, we do allow an illum to pass to another illum + * that is actually going to relay to a virtual light source. + */ + +#define wrongillum(m, r) (!(source[r->rsrc].sflags&SVIRTUAL) && \ + objptr(source[r->rsrc].so->omod)->otype==MAT_ILLUM) + +/* wrongsource * + * + * This source is the wrong source (ie. overcounted) if we are + * aimed to a different source than the one we hit and the one + * we hit is not an illum which should be passed. + */ + +#define wrongsource(m, r) (r->rsrc>=0 && source[r->rsrc].so!=r->ro && \ + (m->otype!=MAT_ILLUM || wrongillum(m,r))) + +/* distglow * + * + * A distant glow is an object that sometimes acts as a light source, + * but is too far away from the test point to be one in this case. + */ + #define distglow(m, r) (m->otype==MAT_GLOW && \ r->rot > m->oargs.farg[3]) +/* badambient * + * + * We must avoid including 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. + */ + #define badambient(m, r) ((r->crtype&(AMBIENT|SHADOW))==AMBIENT && \ !distglow(m, r)) +/* passillum * + * + * An illum passes to another material type when we didn't hit it + * on purpose (as part of a direct calculation), or it is relaying + * a virtual light source. + */ + #define passillum(m, r) (m->otype==MAT_ILLUM && \ - !(r->rsrc>=0&&source[r->rsrc].so==r->ro)) + (r->rsrc<0 || source[r->rsrc].so!=r->ro || \ + source[r->rsrc].sflags&SVIRTUAL)) + +/* srcignore * + * + * The -di flag renders light sources invisible, and here is the test. + */ #define srcignore(m, r) (directinvis && !(r->crtype&SHADOW) && \ !distglow(m, r))