--- ray/src/rt/ambient.c 1989/08/08 17:31:23 1.6 +++ ray/src/rt/ambient.c 1989/09/05 09:46:17 1.7 @@ -21,8 +21,6 @@ static char SCCSid[] = "$SunId$ LBL"; #define OCTSCALE 0.5 /* ceil((valid rad.)/(cube size)) */ -#define WDONE 4 /* stop if wsum/wmin is at or above */ - extern CUBE thescene; /* contains space boundaries */ extern COLOR ambval; /* global ambient component */ @@ -166,28 +164,8 @@ double s; int i; register int j; register AMBVAL *av; - + /* do this node */ wsum = 0.0; - /* check children first */ - if (at->kid != NULL) { - s *= 0.5; - for (i = 0; i < 8; i++) { - for (j = 0; j < 3; j++) { - ck0[j] = c0[j]; - if (1<rop[j] < ck0[j] - OCTSCALE*s) - break; - if (r->rop[j] > ck0[j] + (1.0+OCTSCALE)*s) - break; - } - if (j == 3) - wsum += sumambient(acol, r, at->kid+i, ck0, s); - } - if (wsum*ambacc >= WDONE) - return(wsum); /* close enough */ - } - /* check this node */ for (av = at->alist; av != NULL; av = av->next) { /* * Ray strength test. @@ -225,7 +203,7 @@ double s; * Jittering final test reduces image artifacts. */ wt = sqrt(e1) + sqrt(e2); - wt *= 0.9 + 0.2*frandom(); + wt *= .9 + .2*frandom(); if (wt > ambacc) continue; if (wt <= 1e-3) @@ -236,6 +214,23 @@ double s; copycolor(ct, av->val); scalecolor(ct, wt); addcolor(acol, ct); + } + if (at->kid == NULL) + return(wsum); + /* do children */ + s *= 0.5; + for (i = 0; i < 8; i++) { + for (j = 0; j < 3; j++) { + ck0[j] = c0[j]; + if (1<rop[j] < ck0[j] - OCTSCALE*s) + break; + if (r->rop[j] > ck0[j] + (1.0+OCTSCALE)*s) + break; + } + if (j == 3) + wsum += sumambient(acol, r, at->kid+i, ck0, s); } return(wsum); }