511 |
|
if (ec) |
512 |
|
return ec; |
513 |
|
/* get BSDF color */ |
514 |
< |
n = (*sdc->func->getBSDFs)(coef, ioVec, inVec, sdc); |
514 |
> |
n = (*sdc->func->getBSDFs)(coef, inVec, ioVec, sdc); |
515 |
|
if (n <= 0) { |
516 |
|
strcpy(SDerrorDetail, "BSDF sample value error"); |
517 |
|
return SDEinternal; |
530 |
|
|
531 |
|
/* Convert 1-dimensional random variable to N-dimensional */ |
532 |
|
void |
533 |
< |
SDmultiSamp(double t[], int n, double randX) |
533 |
> |
SDmultiSamp(RREAL t[], int n, double randX) |
534 |
|
{ |
535 |
|
unsigned nBits; |
536 |
|
double scale; |
560 |
|
|
561 |
|
/* Generate diffuse hemispherical sample */ |
562 |
|
static void |
563 |
< |
SDdiffuseSamp(FVECT outVec, int outFront, double randX) |
563 |
> |
SDdiffuseSamp(FVECT ioVec, int outFront, double randX) |
564 |
|
{ |
565 |
|
/* convert to position on hemisphere */ |
566 |
< |
SDmultiSamp(outVec, 2, randX); |
567 |
< |
SDsquare2disk(outVec, outVec[0], outVec[1]); |
568 |
< |
outVec[2] = 1. - outVec[0]*outVec[0] - outVec[1]*outVec[1]; |
569 |
< |
outVec[2] = sqrt(outVec[2]*(outVec[2]>0)); |
566 |
> |
SDmultiSamp(ioVec, 2, randX); |
567 |
> |
square2disk(ioVec, ioVec[0], ioVec[1]); |
568 |
> |
ioVec[2] = 1. - ioVec[0]*ioVec[0] - ioVec[1]*ioVec[1]; |
569 |
> |
ioVec[2] = sqrt(ioVec[2]*(ioVec[2]>0)); |
570 |
|
if (!outFront) /* going out back? */ |
571 |
< |
outVec[2] = -outVec[2]; |
571 |
> |
ioVec[2] = -ioVec[2]; |
572 |
|
} |
573 |
|
|
574 |
|
/* Query projected solid angle coverage for non-diffuse BSDF direction */ |
633 |
|
|
634 |
|
/* Return BSDF for the given incident and scattered ray vectors */ |
635 |
|
SDError |
636 |
< |
SDevalBSDF(SDValue *sv, const FVECT outVec, const FVECT inVec, const SDData *sd) |
636 |
> |
SDevalBSDF(SDValue *sv, const FVECT inVec, const FVECT outVec, const SDData *sd) |
637 |
|
{ |
638 |
|
int inFront, outFront; |
639 |
|
SDSpectralDF *sdf; |
663 |
|
/* add non-diffuse components */ |
664 |
|
i = (sdf != NULL) ? sdf->ncomp : 0; |
665 |
|
while (i-- > 0) { |
666 |
< |
nch = (*sdf->comp[i].func->getBSDFs)(coef, outVec, inVec, |
666 |
> |
nch = (*sdf->comp[i].func->getBSDFs)(coef, inVec, outVec, |
667 |
|
&sdf->comp[i]); |
668 |
|
while (nch-- > 0) { |
669 |
|
c_cmix(&sv->spec, sv->cieY, &sv->spec, |
808 |
|
if (ec) |
809 |
|
return ec; |
810 |
|
/* compute color */ |
811 |
< |
j = (*sdc->func->getBSDFs)(coef, ioVec, inVec, sdc); |
811 |
> |
j = (*sdc->func->getBSDFs)(coef, inVec, ioVec, sdc); |
812 |
|
if (j <= 0) { |
813 |
|
sprintf(SDerrorDetail, "BSDF \"%s\" sampling value error", |
814 |
|
sd->name); |