| 122 |
|
return(0); |
| 123 |
|
} |
| 124 |
|
sf = specjitter * ndp->pr->rweight; |
| 125 |
< |
if (25.*tomega <= omega) |
| 125 |
> |
if (tomega <= .0) |
| 126 |
> |
nsamp = 1; |
| 127 |
> |
else if (25.*tomega <= omega) |
| 128 |
|
nsamp = 100.*sf + .5; |
| 129 |
|
else |
| 130 |
|
nsamp = 4.*sf*omega/tomega + .5; |
| 159 |
|
return(ok); |
| 160 |
|
baderror: |
| 161 |
|
objerror(ndp->mp, USER, transSDError(ec)); |
| 162 |
+ |
return(0); /* gratis return */ |
| 163 |
|
} |
| 164 |
|
|
| 165 |
|
/* Compute source contribution for BSDF (reflected & transmitted) */ |
| 382 |
|
|
| 383 |
|
if (sflags == SDsampSpT) { |
| 384 |
|
unsc = ndp->tunsamp; |
| 385 |
< |
dfp = ndp->sd->tf; |
| 385 |
> |
if (ndp->pr->rod > 0) |
| 386 |
> |
dfp = (ndp->sd->tf != NULL) ? ndp->sd->tf : ndp->sd->tb; |
| 387 |
> |
else |
| 388 |
> |
dfp = (ndp->sd->tb != NULL) ? ndp->sd->tb : ndp->sd->tf; |
| 389 |
|
cvt_sdcolor(unsc, &ndp->sd->tLamb); |
| 390 |
|
} else /* sflags == SDsampSpR */ { |
| 391 |
|
unsc = ndp->runsamp; |
| 446 |
|
hitfront = (r->rod > 0); |
| 447 |
|
/* load cal file */ |
| 448 |
|
mf = getfunc(m, 5, 0x1d, 1); |
| 449 |
+ |
setfunc(m, r); |
| 450 |
|
/* get thickness */ |
| 451 |
|
nd.thick = evalue(mf->ep[0]); |
| 452 |
|
if ((-FTINY <= nd.thick) & (nd.thick <= FTINY)) |
| 457 |
|
raytrans(r); /* pass-through */ |
| 458 |
|
return(1); /* or shadow */ |
| 459 |
|
} |
| 460 |
+ |
/* check backface visibility */ |
| 461 |
+ |
if (!hitfront & !backvis) { |
| 462 |
+ |
raytrans(r); |
| 463 |
+ |
return(1); |
| 464 |
+ |
} |
| 465 |
|
/* check other rays to pass */ |
| 466 |
|
if (nd.thick != 0 && (!(r->crtype & (SPECULAR|AMBIENT)) || |
| 467 |
< |
nd.thick > 0 ^ hitfront)) { |
| 467 |
> |
(nd.thick > 0) ^ hitfront)) { |
| 468 |
|
raytrans(r); /* hide our proxy */ |
| 469 |
|
return(1); |
| 470 |
|
} |
| 479 |
|
m->oargs.farg[1], |
| 480 |
|
m->oargs.farg[2]); |
| 481 |
|
} else { |
| 482 |
< |
if (m->oargs.nfargs < 6) { /* check invisible backside */ |
| 471 |
< |
if (!backvis && (nd.sd->rb == NULL) & |
| 472 |
< |
(nd.sd->tf == NULL)) { |
| 473 |
< |
SDfreeCache(nd.sd); |
| 474 |
< |
raytrans(r); |
| 475 |
< |
return(1); |
| 476 |
< |
} |
| 482 |
> |
if (m->oargs.nfargs < 6) |
| 483 |
|
setcolor(nd.rdiff, .0, .0, .0); |
| 484 |
< |
} else |
| 484 |
> |
else |
| 485 |
|
setcolor(nd.rdiff, m->oargs.farg[3], |
| 486 |
|
m->oargs.farg[4], |
| 487 |
|
m->oargs.farg[5]); |
| 505 |
|
upvec[1] = evalue(mf->ep[2]); |
| 506 |
|
upvec[2] = evalue(mf->ep[3]); |
| 507 |
|
/* return to world coords */ |
| 508 |
< |
if (mf->f != &unitxf) { |
| 509 |
< |
multv3(upvec, upvec, mf->f->xfm); |
| 510 |
< |
nd.thick *= mf->f->sca; |
| 508 |
> |
if (mf->fxp != &unitxf) { |
| 509 |
> |
multv3(upvec, upvec, mf->fxp->xfm); |
| 510 |
> |
nd.thick *= mf->fxp->sca; |
| 511 |
|
} |
| 512 |
+ |
if (r->rox != NULL) { |
| 513 |
+ |
multv3(upvec, upvec, r->rox->f.xfm); |
| 514 |
+ |
nd.thick *= r->rox->f.sca; |
| 515 |
+ |
} |
| 516 |
|
raynormal(nd.pnorm, r); |
| 517 |
|
/* compute local BSDF xform */ |
| 518 |
|
ec = SDcompXform(nd.toloc, nd.pnorm, upvec); |
| 524 |
|
} |
| 525 |
|
if (!ec) |
| 526 |
|
ec = SDinvXform(nd.fromloc, nd.toloc); |
| 517 |
– |
/* determine BSDF resolution */ |
| 518 |
– |
if (!ec) |
| 519 |
– |
ec = SDsizeBSDF(nd.sr_vpsa, nd.vray, NULL, |
| 520 |
– |
SDqueryMin+SDqueryMax, nd.sd); |
| 527 |
|
if (ec) { |
| 528 |
< |
objerror(m, WARNING, transSDError(ec)); |
| 523 |
< |
SDfreeCache(nd.sd); |
| 528 |
> |
objerror(m, WARNING, "Illegal orientation vector"); |
| 529 |
|
return(1); |
| 530 |
|
} |
| 531 |
+ |
/* determine BSDF resolution */ |
| 532 |
+ |
ec = SDsizeBSDF(nd.sr_vpsa, nd.vray, NULL, SDqueryMin+SDqueryMax, nd.sd); |
| 533 |
+ |
if (ec) |
| 534 |
+ |
objerror(m, USER, transSDError(ec)); |
| 535 |
+ |
|
| 536 |
|
nd.sr_vpsa[0] = sqrt(nd.sr_vpsa[0]); |
| 537 |
|
nd.sr_vpsa[1] = sqrt(nd.sr_vpsa[1]); |
| 538 |
|
if (!hitfront) { /* perturb normal towards hit */ |
| 566 |
|
bnorm[2] = -nd.pnorm[2]; |
| 567 |
|
if (nd.thick != 0) { /* proxy with offset? */ |
| 568 |
|
VCOPY(vtmp, r->rop); |
| 569 |
< |
VSUM(r->rop, vtmp, r->ron, -nd.thick); |
| 569 |
> |
VSUM(r->rop, vtmp, r->ron, nd.thick); |
| 570 |
|
multambient(ctmp, r, bnorm); |
| 571 |
|
VCOPY(r->rop, vtmp); |
| 572 |
|
} else |
| 576 |
|
flipsurface(r); |
| 577 |
|
} |
| 578 |
|
/* add direct component */ |
| 579 |
< |
if ((bright(nd.tdiff) <= FTINY) & (nd.sd->tf == NULL)) { |
| 579 |
> |
if ((bright(nd.tdiff) <= FTINY) & (nd.sd->tf == NULL) & |
| 580 |
> |
(nd.sd->tb == NULL)) { |
| 581 |
|
direct(r, dir_brdf, &nd); /* reflection only */ |
| 582 |
|
} else if (nd.thick == 0) { |
| 583 |
|
direct(r, dir_bsdf, &nd); /* thin surface scattering */ |