15 |
|
|
16 |
|
/* Convert a BSDF to our matrix representation */ |
17 |
|
static CMATRIX * |
18 |
< |
cm_bsdf(const COLOR diffBSDF, const COLOR specCol, const SDMat *bsdf) |
18 |
> |
cm_bsdf(const COLOR diffBSDF, const SDMat *bsdf) |
19 |
|
{ |
20 |
|
CMATRIX *cm = cm_alloc(bsdf->nout, bsdf->ninc); |
21 |
|
int nbadohm = 0; |
33 |
|
/* check BSDF value */ |
34 |
|
if ((f <= 0) | (dom <= 0)) { |
35 |
|
nneg += (f < -FTINY); |
36 |
< |
f = .0f; |
37 |
< |
} |
38 |
< |
copycolor(mp, specCol); |
39 |
< |
scalecolor(mp, f); |
36 |
> |
setcolor(mp, .0f, .0f, .0f); |
37 |
> |
} else if (bsdf->chroma != NULL) { |
38 |
> |
C_COLOR cxy; |
39 |
> |
c_decodeChroma(&cxy, |
40 |
> |
bsdf->chroma[r*bsdf->ninc + c]); |
41 |
> |
ccy2rgb(&cxy, f, mp); |
42 |
> |
} else |
43 |
> |
setcolor(mp, f, f, f); |
44 |
|
addcolor(mp, diffBSDF); |
45 |
|
scalecolor(mp, dom); |
46 |
|
} |
80 |
|
|
81 |
|
/* Convert a BSDF to our matrix representation, applying reciprocity */ |
82 |
|
static CMATRIX * |
83 |
< |
cm_bsdf_recip(const COLOR diffBSDF, const COLOR specCol, const SDMat *bsdf) |
83 |
> |
cm_bsdf_recip(const COLOR diffBSDF, const SDMat *bsdf) |
84 |
|
{ |
85 |
|
CMATRIX *cm = cm_alloc(bsdf->ninc, bsdf->nout); |
86 |
|
int nbadohm = 0; |
100 |
|
/* check BSDF value */ |
101 |
|
if ((f <= 0) | (dom <= 0)) { |
102 |
|
nneg += (f < -FTINY); |
103 |
< |
f = .0f; |
104 |
< |
} |
105 |
< |
copycolor(mp, specCol); |
106 |
< |
scalecolor(mp, f); |
103 |
> |
setcolor(mp, .0f, .0f, .0f); |
104 |
> |
} else if (bsdf->chroma != NULL) { |
105 |
> |
C_COLOR cxy; |
106 |
> |
c_decodeChroma(&cxy, |
107 |
> |
bsdf->chroma[ro*bsdf->ninc + ri]); |
108 |
> |
ccy2rgb(&cxy, f, mp); |
109 |
> |
} else |
110 |
> |
setcolor(mp, f, f, f); |
111 |
|
addcolor(mp, diffBSDF); |
112 |
|
scalecolor(mp, dom); |
113 |
|
} |
146 |
|
SDError ec; |
147 |
|
SDData myBSDF; |
148 |
|
SDSpectralDF *tdf; |
149 |
< |
COLOR diffBSDF, specCol; |
149 |
> |
COLOR diffBSDF; |
150 |
|
/* find path to BSDF file */ |
151 |
|
fpath = getpath(fname, getrlibpath(), R_OK); |
152 |
|
if (fpath == NULL) { |
169 |
|
error(USER, errmsg); |
170 |
|
} |
171 |
|
/* convert BTDF to matrix */ |
172 |
< |
ccy2rgb(&tdf->comp[0].cspec[0], 1., specCol); |
173 |
< |
Tmat = recip ? cm_bsdf_recip(diffBSDF, specCol, (SDMat *)tdf->comp[0].dist) |
166 |
< |
: cm_bsdf(diffBSDF, specCol, (SDMat *)tdf->comp[0].dist); |
172 |
> |
Tmat = recip ? cm_bsdf_recip(diffBSDF, (SDMat *)tdf->comp[0].dist) |
173 |
> |
: cm_bsdf(diffBSDF, (SDMat *)tdf->comp[0].dist); |
174 |
|
/* free BSDF and return */ |
175 |
|
SDfreeBSDF(&myBSDF); |
176 |
|
return(Tmat); |