79 |
|
COLOR cthru; /* "through" component multiplier */ |
80 |
|
SDData *sd; /* loaded BSDF data */ |
81 |
|
COLOR rdiff; /* diffuse reflection */ |
82 |
+ |
COLOR runsamp; /* BSDF hemispherical reflection */ |
83 |
|
COLOR tdiff; /* diffuse transmission */ |
84 |
+ |
COLOR tunsamp; /* BSDF hemispherical transmission */ |
85 |
|
} BSDFDAT; /* BSDF material data */ |
86 |
|
|
87 |
|
#define cvt_sdcolor(cv, svp) ccy2rgb(&(svp)->spec, (svp)->cieY, cv) |
317 |
|
|
318 |
|
if (ldot > 0 && bright(np->rdiff) > FTINY) { |
319 |
|
/* |
320 |
< |
* Compute added diffuse reflected component. |
320 |
> |
* Compute diffuse reflected component |
321 |
|
*/ |
322 |
|
copycolor(ctmp, np->rdiff); |
323 |
|
dtmp = ldot * omega * (1./PI); |
326 |
|
} |
327 |
|
if (ldot < 0 && bright(np->tdiff) > FTINY) { |
328 |
|
/* |
329 |
< |
* Compute added diffuse transmission. |
329 |
> |
* Compute diffuse transmission |
330 |
|
*/ |
331 |
|
copycolor(ctmp, np->tdiff); |
332 |
|
dtmp = -ldot * omega * (1.0/PI); |
336 |
|
if (ambRayInPmap(np->pr)) |
337 |
|
return; /* specular already in photon map */ |
338 |
|
/* |
339 |
< |
* Compute specular scattering coefficient using BSDF. |
339 |
> |
* Compute specular scattering coefficient using BSDF |
340 |
|
*/ |
341 |
|
if (!direct_specular_OK(ctmp, ldir, omega, np)) |
342 |
|
return; |
372 |
|
|
373 |
|
if (bright(np->rdiff) > FTINY) { |
374 |
|
/* |
375 |
< |
* Compute added diffuse reflected component. |
375 |
> |
* Compute diffuse reflected component |
376 |
|
*/ |
377 |
|
copycolor(ctmp, np->rdiff); |
378 |
|
dtmp = ldot * omega * (1./PI); |
382 |
|
if (ambRayInPmap(np->pr)) |
383 |
|
return; /* specular already in photon map */ |
384 |
|
/* |
385 |
< |
* Compute specular reflection coefficient using BSDF. |
385 |
> |
* Compute specular reflection coefficient using BSDF |
386 |
|
*/ |
387 |
|
if (!direct_specular_OK(ctmp, ldir, omega, np)) |
388 |
|
return; |
414 |
|
|
415 |
|
if (bright(np->tdiff) > FTINY) { |
416 |
|
/* |
417 |
< |
* Compute added diffuse transmission. |
417 |
> |
* Compute diffuse transmission |
418 |
|
*/ |
419 |
|
copycolor(ctmp, np->tdiff); |
420 |
|
dtmp = -ldot * omega * (1.0/PI); |
424 |
|
if (ambRayInPmap(np->pr)) |
425 |
|
return; /* specular already in photon map */ |
426 |
|
/* |
427 |
< |
* Compute specular scattering coefficient using BSDF. |
427 |
> |
* Compute specular scattering coefficient using BSDF |
428 |
|
*/ |
429 |
|
if (!direct_specular_OK(ctmp, ldir, omega, np)) |
430 |
|
return; |
500 |
|
COLORV *unsc; |
501 |
|
|
502 |
|
if (sflags == SDsampSpT) { |
503 |
< |
unsc = ndp->tdiff; |
503 |
> |
unsc = ndp->tunsamp; |
504 |
|
if (ndp->pr->rod > 0) |
505 |
|
dfp = (ndp->sd->tf != NULL) ? ndp->sd->tf : ndp->sd->tb; |
506 |
|
else |
507 |
|
dfp = (ndp->sd->tb != NULL) ? ndp->sd->tb : ndp->sd->tf; |
508 |
|
} else /* sflags == SDsampSpR */ { |
509 |
< |
unsc = ndp->rdiff; |
509 |
> |
unsc = ndp->runsamp; |
510 |
|
if (ndp->pr->rod > 0) |
511 |
|
dfp = ndp->sd->rf; |
512 |
|
else |
513 |
|
dfp = ndp->sd->rb; |
514 |
|
} |
515 |
+ |
setcolor(unsc, 0., 0., 0.); |
516 |
|
if (dfp == NULL) /* no specular component? */ |
517 |
|
return(0); |
518 |
|
/* below sampling threshold? */ |
520 |
|
if (dfp->maxHemi > FTINY) { /* XXX no color from BSDF */ |
521 |
|
FVECT vjit; |
522 |
|
double d; |
520 |
– |
COLOR ctmp; |
523 |
|
bsdf_jitter(vjit, ndp, ndp->sr_vpsa[1]); |
524 |
|
d = SDdirectHemi(vjit, sflags, ndp->sd); |
525 |
|
if (sflags == SDsampSpT) { |
526 |
< |
copycolor(ctmp, ndp->pr->pcol); |
527 |
< |
scalecolor(ctmp, d); |
526 |
> |
copycolor(unsc, ndp->pr->pcol); |
527 |
> |
scalecolor(unsc, d); |
528 |
|
} else /* no pattern on reflection */ |
529 |
< |
setcolor(ctmp, d, d, d); |
528 |
< |
addcolor(unsc, ctmp); |
529 |
> |
setcolor(unsc, d, d, d); |
530 |
|
} |
531 |
|
return(0); |
532 |
|
} |
670 |
|
/* sample transmission */ |
671 |
|
sample_sdf(&nd, SDsampSpT); |
672 |
|
/* compute indirect diffuse */ |
673 |
< |
if (bright(nd.rdiff) > FTINY) { /* ambient from reflection */ |
673 |
> |
copycolor(ctmp, nd.rdiff); |
674 |
> |
addcolor(ctmp, nd.runsamp); |
675 |
> |
if (bright(ctmp) > FTINY) { /* ambient from reflection */ |
676 |
|
if (!hitfront) |
677 |
|
flipsurface(r); |
675 |
– |
copycolor(ctmp, nd.rdiff); |
678 |
|
multambient(ctmp, r, nd.pnorm); |
679 |
|
addcolor(r->rcol, ctmp); |
680 |
|
if (!hitfront) |
681 |
|
flipsurface(r); |
682 |
|
} |
683 |
< |
if (bright(nd.tdiff) > FTINY) { /* ambient from other side */ |
683 |
> |
copycolor(ctmp, nd.tdiff); |
684 |
> |
addcolor(ctmp, nd.tunsamp); |
685 |
> |
if (bright(ctmp) > FTINY) { /* ambient from other side */ |
686 |
|
FVECT bnorm; |
687 |
|
if (hitfront) |
688 |
|
flipsurface(r); |
689 |
|
bnorm[0] = -nd.pnorm[0]; |
690 |
|
bnorm[1] = -nd.pnorm[1]; |
691 |
|
bnorm[2] = -nd.pnorm[2]; |
688 |
– |
copycolor(ctmp, nd.tdiff); |
692 |
|
if (nd.thick != 0) { /* proxy with offset? */ |
693 |
|
VCOPY(vtmp, r->rop); |
694 |
|
VSUM(r->rop, vtmp, r->ron, nd.thick); |