129 |
|
double newa |
130 |
|
) |
131 |
|
{ |
132 |
< |
double ambdiff; |
133 |
< |
|
134 |
< |
if (newa < 0.0) |
135 |
< |
newa = 0.0; |
136 |
< |
ambdiff = fabs(newa - ambacc); |
137 |
< |
if (ambdiff >= .01 && (ambacc = newa) > FTINY) { |
138 |
< |
qambacc = sqrt(sqrt(ambacc)); |
132 |
> |
double olda = qambacc*qambacc*qambacc*qambacc; |
133 |
> |
|
134 |
> |
newa *= (newa > 0); |
135 |
> |
if (fabs(newa - olda) >= .05*(newa + olda)) { |
136 |
> |
qambacc = sqrt(sqrt(ambacc = newa)); |
137 |
|
if (nambvals > 0) |
138 |
|
sortambvals(1); /* rebuild tree */ |
139 |
|
} |
355 |
|
FVECT c0, |
356 |
|
double s |
357 |
|
) |
358 |
< |
{ /* initial limit is ambacc radians */ |
359 |
< |
const double maxangle = (ambacc-PI/2.)*pow(r->rweight,0.13) + PI/2.; |
358 |
> |
{ /* initial limit is 10 degrees plus ambacc radians */ |
359 |
> |
const double minangle = 10.0 * PI/180.; |
360 |
> |
const double maxangle = (minangle+ambacc-PI/2.)*pow(r->rweight,0.13) |
361 |
> |
+ PI/2.; |
362 |
|
double wsum = 0.0; |
363 |
|
FVECT ck0; |
364 |
|
int i, j; |
389 |
|
if (delta_r2 >= maxangle*maxangle) |
390 |
|
continue; |
391 |
|
/* |
392 |
+ |
* Modified ray behind test |
393 |
+ |
*/ |
394 |
+ |
VSUB(ck0, av->pos, r->rop); |
395 |
+ |
d = DOT(ck0, uvw[2]); |
396 |
+ |
if (d < -minarad*qambacc-.001) |
397 |
+ |
continue; |
398 |
+ |
d /= av->rad[0]; |
399 |
+ |
delta_t2 = d*d; |
400 |
+ |
if (delta_t2 >= qambacc*qambacc) |
401 |
+ |
continue; |
402 |
+ |
/* |
403 |
|
* Elliptical radii test based on Hessian |
404 |
|
*/ |
405 |
|
decodedir(uvw[0], av->udir); |
406 |
|
VCROSS(uvw[1], uvw[2], uvw[0]); |
396 |
– |
VSUB(ck0, av->pos, r->rop); |
407 |
|
d = DOT(ck0, uvw[0]) / av->rad[0]; |
408 |
< |
delta_t2 = d*d; |
408 |
> |
delta_t2 += d*d; |
409 |
|
d = DOT(ck0, uvw[1]) / av->rad[1]; |
410 |
|
delta_t2 += d*d; |
411 |
|
if (delta_t2 >= qambacc*qambacc) |
412 |
|
continue; |
413 |
|
/* |
404 |
– |
* Intersection behind test |
405 |
– |
*/ |
406 |
– |
d = 0.0; |
407 |
– |
for (j = 0; j < 3; j++) |
408 |
– |
d += (r->rop[j] - av->pos[j])*(uvw[2][j] + r->ron[j]); |
409 |
– |
if (d*0.5 < -minarad*ambacc-.001) |
410 |
– |
continue; |
411 |
– |
/* |
414 |
|
* Extrapolate value and compute final weight (hat function) |
415 |
|
*/ |
416 |
|
extambient(ct, av, r->rop, rn, uvw); |
463 |
|
/* compute ambient */ |
464 |
|
i = doambient(acol, r, amb.weight, uvw, amb.rad, amb.gpos, amb.gdir); |
465 |
|
scalecolor(acol, 1./AVGREFL); /* undo assumed reflectance */ |
466 |
< |
if (i <= 0) /* no Hessian => no storage */ |
466 |
> |
if (i <= 0 || amb.rad[0] <= FTINY) /* no Hessian or zero radius */ |
467 |
|
return(i); |
468 |
|
/* store value */ |
469 |
|
VCOPY(amb.pos, r->rop); |