| 47 |
|
/* Cache of loaded BSDFs */ |
| 48 |
|
struct SDCache_s *SDcacheList = NULL; |
| 49 |
|
|
| 50 |
< |
/* Retain BSDFs in cache list */ |
| 50 |
> |
/* Retain BSDFs in cache list? */ |
| 51 |
|
int SDretainSet = SDretainNone; |
| 52 |
|
|
| 53 |
+ |
/* Maximum cache size for any given BSDF? */ |
| 54 |
+ |
unsigned long SDmaxCache = 0; /* 0 == unlimited */ |
| 55 |
+ |
|
| 56 |
|
/* Report any error to the indicated stream */ |
| 57 |
|
SDError |
| 58 |
|
SDreportError(SDError ec, FILE *fp) |
| 381 |
|
sd->rLambFront.spec.flags = 0; |
| 382 |
|
sd->rLambBack.cieY = .0; |
| 383 |
|
sd->rLambBack.spec.flags = 0; |
| 384 |
< |
sd->tLamb.cieY = .0; |
| 385 |
< |
sd->tLamb.spec.flags = 0; |
| 384 |
> |
sd->tLambFront.cieY = .0; |
| 385 |
> |
sd->tLambFront.spec.flags = 0; |
| 386 |
> |
sd->tLambBack.cieY = .0; |
| 387 |
> |
sd->tLambBack.spec.flags = 0; |
| 388 |
|
} |
| 389 |
|
|
| 390 |
|
/* Find writeable BSDF by name, or allocate new cache entry if absent */ |
| 520 |
|
c_cmix(&sv->spec, d, &sv->spec, coef[n], &sdc->cspec[n]); |
| 521 |
|
d += coef[n]; |
| 522 |
|
} |
| 523 |
< |
/* make sure everything is set */ |
| 519 |
< |
c_ccvt(&sv->spec, C_CSXY+C_CSSPEC); |
| 523 |
> |
c_ccvt(&sv->spec, C_CSXY); /* make sure (x,y) is set */ |
| 524 |
|
return SDEnone; |
| 525 |
|
} |
| 526 |
|
|
| 650 |
|
} else if (!(inFront | outFront)) { |
| 651 |
|
*sv = sd->rLambBack; |
| 652 |
|
sdf = sd->rb; |
| 653 |
< |
} else if (outFront) { |
| 654 |
< |
*sv = sd->tLamb; |
| 653 |
> |
} else if (inFront) { |
| 654 |
> |
*sv = sd->tLambFront; |
| 655 |
|
sdf = (sd->tf != NULL) ? sd->tf : sd->tb; |
| 656 |
< |
} else /* inFront & !outFront */ { |
| 657 |
< |
*sv = sd->tLamb; |
| 656 |
> |
} else /* outFront & !inFront */ { |
| 657 |
> |
*sv = sd->tLambBack; |
| 658 |
|
sdf = (sd->tb != NULL) ? sd->tb : sd->tf; |
| 659 |
|
} |
| 660 |
|
sv->cieY *= 1./M_PI; |
| 669 |
|
sv->cieY += coef[nch]; |
| 670 |
|
} |
| 671 |
|
} |
| 672 |
< |
/* make sure everything is set */ |
| 669 |
< |
c_ccvt(&sv->spec, C_CSXY+C_CSSPEC); |
| 672 |
> |
c_ccvt(&sv->spec, C_CSXY); /* make sure (x,y) is set */ |
| 673 |
|
return SDEnone; |
| 674 |
|
} |
| 675 |
|
|
| 697 |
|
if ((sflags & SDsampDf+SDsampR) != SDsampDf+SDsampR) |
| 698 |
|
hsum = .0; |
| 699 |
|
if ((sflags & SDsampDf+SDsampT) == SDsampDf+SDsampT) |
| 700 |
< |
hsum += sd->tLamb.cieY; |
| 700 |
> |
hsum += (inVec[2] > 0) ? |
| 701 |
> |
sd->tLambFront.cieY : sd->tLambBack.cieY; |
| 702 |
|
/* gather non-diffuse components */ |
| 703 |
|
i = (((sflags & SDsampSp+SDsampR) == SDsampSp+SDsampR) & |
| 704 |
|
(rdf != NULL)) ? rdf->ncomp : 0; |
| 751 |
|
sv->cieY = .0; |
| 752 |
|
rdiff = sv->cieY; |
| 753 |
|
if ((sflags & SDsampDf+SDsampT) == SDsampDf+SDsampT) |
| 754 |
< |
sv->cieY += sd->tLamb.cieY; |
| 754 |
> |
sv->cieY += inFront ? sd->tLambFront.cieY : sd->tLambBack.cieY; |
| 755 |
|
/* gather non-diffuse components */ |
| 756 |
|
i = nr = (((sflags & SDsampSp+SDsampR) == SDsampSp+SDsampR) & |
| 757 |
|
(rdf != NULL)) ? rdf->ncomp : 0; |
| 787 |
|
randX -= rdiff; |
| 788 |
|
/* diffuse transmission? */ |
| 789 |
|
if ((sflags & SDsampDf+SDsampT) == SDsampDf+SDsampT) { |
| 790 |
< |
if (randX < sd->tLamb.cieY) { |
| 791 |
< |
sv->spec = sd->tLamb.spec; |
| 792 |
< |
SDdiffuseSamp(ioVec, !inFront, randX/sd->tLamb.cieY); |
| 790 |
> |
const SDValue *sdt = inFront ? &sd->tLambFront : &sd->tLambBack; |
| 791 |
> |
if (randX < sdt->cieY) { |
| 792 |
> |
sv->spec = sdt->spec; |
| 793 |
> |
SDdiffuseSamp(ioVec, !inFront, randX/sdt->cieY); |
| 794 |
|
goto done; |
| 795 |
|
} |
| 796 |
< |
randX -= sd->tLamb.cieY; |
| 796 |
> |
randX -= sdt->cieY; |
| 797 |
|
} |
| 798 |
|
/* else one of cumulative dist. */ |
| 799 |
< |
for (i = 0; i < n && randX > cdarr[i]->cTotal; i++) |
| 799 |
> |
for (i = 0; i < n && randX >= cdarr[i]->cTotal; i++) |
| 800 |
|
randX -= cdarr[i]->cTotal; |
| 801 |
|
if (i >= n) |
| 802 |
|
return SDEinternal; |
| 821 |
|
done: |
| 822 |
|
if (cdarr != NULL) |
| 823 |
|
free(cdarr); |
| 824 |
< |
/* make sure everything is set */ |
| 820 |
< |
c_ccvt(&sv->spec, C_CSXY+C_CSSPEC); |
| 824 |
> |
c_ccvt(&sv->spec, C_CSXY); /* make sure (x,y) is set */ |
| 825 |
|
return SDEnone; |
| 826 |
|
} |
| 827 |
|
|