51 |
|
#define MAX_SORT_INTVL (SORT_INTVL<<6) |
52 |
|
#endif |
53 |
|
|
54 |
+ |
|
55 |
+ |
static double qambacc = 0.; /* ambient accuracy to the 1/4 power */ |
56 |
|
static double avsum = 0.; /* computed ambient value sum (log) */ |
57 |
|
static unsigned int navsum = 0; /* number of values in avsum */ |
58 |
|
static unsigned int nambvals = 0; /* total number of indirect values */ |
134 |
|
if (newa < 0.0) |
135 |
|
newa = 0.0; |
136 |
|
ambdiff = fabs(newa - ambacc); |
137 |
< |
if (ambdiff >= .01 && (ambacc = newa) > FTINY && nambvals > 0) |
138 |
< |
sortambvals(1); /* rebuild tree */ |
137 |
> |
if (ambdiff >= .01 && (ambacc = newa) > FTINY) { |
138 |
> |
qambacc = sqrt(sqrt(ambacc)); |
139 |
> |
if (nambvals > 0) |
140 |
> |
sortambvals(1); /* rebuild tree */ |
141 |
> |
} |
142 |
|
} |
143 |
|
|
144 |
|
|
325 |
|
ok = makeambient(acol, r, nrm, rdepth-1); |
326 |
|
rdepth--; |
327 |
|
if (ok) { |
328 |
< |
multcolor(aval, acol); /* got new value */ |
328 |
> |
multcolor(aval, acol); /* computed new value */ |
329 |
|
return; |
330 |
|
} |
331 |
|
dumbamb: /* return global value */ |
459 |
|
amb.weight = 1.25*r->rweight; |
460 |
|
setcolor(acol, AVGREFL, AVGREFL, AVGREFL); |
461 |
|
/* compute ambient */ |
462 |
< |
if (!doambient(acol, r, amb.weight, uvw, amb.rad, amb.gpos, amb.gdir)) { |
458 |
< |
setcolor(acol, 0.0, 0.0, 0.0); |
459 |
< |
return(0); |
460 |
< |
} |
462 |
> |
i = doambient(acol, r, amb.weight, uvw, amb.rad, amb.gpos, amb.gdir); |
463 |
|
scalecolor(acol, 1./AVGREFL); /* undo assumed reflectance */ |
464 |
+ |
if (i <= 0) /* no Hessian => no storage */ |
465 |
+ |
return(i); |
466 |
|
/* store value */ |
467 |
|
VCOPY(amb.pos, r->rop); |
468 |
|
amb.ndir = encodedir(r->ron); |
534 |
|
at = &atrunk; |
535 |
|
VCOPY(ck0, thescene.cuorg); |
536 |
|
s = thescene.cusize; |
537 |
< |
while (s*(OCTSCALE/2) > av->rad[1]*ambacc) { |
537 |
> |
while (s*(OCTSCALE/2) > av->rad[1]*qambacc) { |
538 |
|
if (at->kid == NULL) |
539 |
|
if ((at->kid = newambtree()) == NULL) |
540 |
|
error(SYSTEM, "out of memory in avinsert"); |