289 |
|
sortambvals(0); |
290 |
|
/* get ambient value */ |
291 |
|
setcolor(acol, 0.0, 0.0, 0.0); |
292 |
< |
d = sumambient(acol, r, nrm, rdepth, |
292 |
> |
d = sumambient(acol, r, intens(aval)*r->rweight, nrm, rdepth, |
293 |
|
&atrunk, thescene.cuorg, thescene.cusize); |
294 |
|
if (d > FTINY) { |
295 |
|
scalecolor(acol, 1.0/d); |
326 |
|
sumambient( /* get interpolated ambient value */ |
327 |
|
COLOR acol, |
328 |
|
register RAY *r, |
329 |
+ |
double aw, |
330 |
|
FVECT rn, |
331 |
|
int al, |
332 |
|
AMBTREE *at, |
352 |
|
*/ |
353 |
|
if (av->lvl > al) /* list sorted, so this works */ |
354 |
|
break; |
355 |
< |
if (av->weight < r->rweight-FTINY) |
355 |
> |
if (av->weight < 0.85*aw) |
356 |
|
continue; |
357 |
|
/* |
358 |
|
* Ambient radius test. |
431 |
|
break; |
432 |
|
} |
433 |
|
if (j == 3) |
434 |
< |
wsum += sumambient(acol, r, rn, al, at->kid+i, ck0, s); |
434 |
> |
wsum += sumambient(acol, r, aw, rn, al, |
435 |
> |
at->kid+i, ck0, s); |
436 |
|
} |
437 |
|
return(wsum); |
438 |
|
} |
439 |
|
|
440 |
|
|
441 |
|
extern double |
442 |
< |
makeambient( /* make a new ambient value */ |
442 |
> |
makeambient( /* make a new ambient value */ |
443 |
|
COLOR acol, |
444 |
|
RAY *r, |
445 |
|
COLOR ac, |
448 |
|
) |
449 |
|
{ |
450 |
|
AMBVAL amb; |
451 |
< |
double coef; |
451 |
> |
double awt; |
452 |
|
FVECT gp, gd; |
453 |
< |
/* compute weight */ |
454 |
< |
amb.weight = pow(AVGREFL, (double)al); |
455 |
< |
coef = intens(ac)*r->rweight; |
456 |
< |
if (coef < 0.1*amb.weight) /* heuristic */ |
457 |
< |
amb.weight = coef; |
453 |
> |
int i; |
454 |
> |
|
455 |
> |
amb.weight = AVGREFL; /* compute weight */ |
456 |
> |
for (i = al; i-- >= 0; ) |
457 |
> |
amb.weight *= AVGREFL; |
458 |
> |
awt = intens(ac)*r->rweight; |
459 |
> |
if (awt < 0.07*amb.weight) /* heuristic override */ |
460 |
> |
amb.weight = 1.2*awt; |
461 |
|
/* compute ambient */ |
462 |
|
amb.rad = doambient(acol, r, ac, amb.weight, gp, gd); |
463 |
|
if (amb.rad <= FTINY) |