152 |
|
ambdone(); |
153 |
|
/* init ambient limits */ |
154 |
|
setambres(ambres); |
155 |
< |
setambacc(ambacc); |
155 |
> |
qambacc = sqrt(sqrt(ambacc *= (ambacc > FTINY))); |
156 |
|
if (ambfile == NULL || !ambfile[0]) |
157 |
|
return; |
158 |
|
if (ambacc <= FTINY) { |
357 |
|
FVECT c0, |
358 |
|
double s |
359 |
|
) |
360 |
< |
{ /* initial limit is ambacc radians */ |
361 |
< |
const double maxangle = (ambacc-PI/2.)*pow(r->rweight,0.13) + PI/2.; |
360 |
> |
{ /* initial limit is 10 degrees plus ambacc radians */ |
361 |
> |
const double minangle = 10.0 * PI/180.; |
362 |
> |
const double maxangle = (minangle+ambacc-PI/2.)*pow(r->rweight,0.13) |
363 |
> |
+ PI/2.; |
364 |
|
double wsum = 0.0; |
365 |
|
FVECT ck0; |
366 |
|
int i, j; |
400 |
|
delta_t2 = d*d; |
401 |
|
d = DOT(ck0, uvw[1]) / av->rad[1]; |
402 |
|
delta_t2 += d*d; |
403 |
+ |
d = DOT(ck0, uvw[2]) / av->rad[0]; |
404 |
+ |
delta_t2 += d*d; |
405 |
|
if (delta_t2 >= qambacc*qambacc) |
406 |
|
continue; |
407 |
|
/* |
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 |
– |
/* |
408 |
|
* Extrapolate value and compute final weight (hat function) |
409 |
|
*/ |
410 |
|
extambient(ct, av, r->rop, rn, uvw); |
457 |
|
/* compute ambient */ |
458 |
|
i = doambient(acol, r, amb.weight, uvw, amb.rad, amb.gpos, amb.gdir); |
459 |
|
scalecolor(acol, 1./AVGREFL); /* undo assumed reflectance */ |
460 |
< |
if (i <= 0) /* no Hessian => no storage */ |
460 |
> |
if (i <= 0 || amb.rad[0] <= FTINY) /* no Hessian or zero radius */ |
461 |
|
return(i); |
462 |
|
/* store value */ |
463 |
|
VCOPY(amb.pos, r->rop); |