28 |
|
nbadohm += (dom <= 0); |
29 |
|
|
30 |
|
for (r = 0; r < cm->nrows; r++) { |
31 |
< |
float f = mBSDF_value(bsdf,c,r); |
31 |
> |
float f = mBSDF_value(bsdf,r,c); |
32 |
|
COLORV *mp = cm_lval(cm,r,c); |
33 |
|
/* check BSDF value */ |
34 |
|
if ((f <= 0) | (dom <= 0)) { |
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]); |
39 |
> |
c_decodeChroma(&cxy, mBSDF_chroma(bsdf,r,c)); |
40 |
|
ccy2rgb(&cxy, f, mp); |
41 |
|
} else |
42 |
|
setcolor(mp, f, f, f); |
94 |
|
|
95 |
|
for (r = 0; r < cm->nrows; r++) { |
96 |
|
const int ri = recip_in_from_out(bsdf,r); |
97 |
< |
float f = mBSDF_value(bsdf,ri,ro); |
97 |
> |
float f = mBSDF_value(bsdf,ro,ri); |
98 |
|
COLORV *mp = cm_lval(cm,r,c); |
99 |
|
/* check BSDF value */ |
100 |
|
if ((f <= 0) | (dom <= 0)) { |
102 |
|
setcolor(mp, .0f, .0f, .0f); |
103 |
|
} else if (bsdf->chroma != NULL) { |
104 |
|
C_COLOR cxy; |
105 |
< |
c_decodeChroma(&cxy, |
107 |
< |
bsdf->chroma[ro*bsdf->ninc + ri]); |
105 |
> |
c_decodeChroma(&cxy, mBSDF_chroma(bsdf,ro,ri)); |
106 |
|
ccy2rgb(&cxy, f, mp); |
107 |
|
} else |
108 |
|
setcolor(mp, f, f, f); |
123 |
|
static CMATRIX * |
124 |
|
cm_bsdf_Lamb(const COLOR diffBSDF) |
125 |
|
{ |
126 |
< |
CMATRIX *cm = cm_alloc(145, 145); /* this is a hack */ |
127 |
< |
int r, c; |
126 |
> |
CMATRIX *cm = cm_alloc(145, 145); /* this is a hack */ |
127 |
> |
ANGLE_BASIS *abase = abase_list; |
128 |
> |
int r, c; |
129 |
|
|
130 |
< |
for (c = 0; c < cm->ncols; c++) |
130 |
> |
while (abase->nangles != cm->nrows) |
131 |
> |
if (++abase >= abase_list+nabases) |
132 |
> |
error(INTERNAL, "Code error in cm_bsdf_Lamb()"); |
133 |
> |
|
134 |
> |
for (c = 0; c < cm->ncols; c++) { |
135 |
> |
const double dom = io_getohm(c,abase); |
136 |
|
for (r = 0; r < cm->nrows; r++) { |
137 |
|
COLORV *mp = cm_lval(cm,r,c); |
138 |
|
copycolor(mp, diffBSDF); |
139 |
+ |
scalecolor(mp, dom); |
140 |
|
} |
141 |
+ |
} |
142 |
|
return(cm); |
143 |
|
} |
144 |
|
|
147 |
|
cm_loadBTDF(char *fname) |
148 |
|
{ |
149 |
|
CMATRIX *Tmat; |
144 |
– |
char *fpath; |
150 |
|
int recip; |
151 |
|
SDError ec; |
152 |
|
SDData myBSDF; |
153 |
|
SDSpectralDF *tdf; |
154 |
|
COLOR diffBSDF; |
155 |
< |
/* find path to BSDF file */ |
151 |
< |
fpath = getpath(fname, getrlibpath(), R_OK); |
152 |
< |
if (fpath == NULL) { |
153 |
< |
sprintf(errmsg, "cannot find BSDF file '%s'", fname); |
154 |
< |
error(USER, errmsg); |
155 |
< |
} |
155 |
> |
|
156 |
|
SDclearBSDF(&myBSDF, fname); /* load XML and check type */ |
157 |
< |
ec = SDloadFile(&myBSDF, fpath); |
157 |
> |
ec = SDloadFile(&myBSDF, fname); |
158 |
|
if (ec) |
159 |
|
error(USER, transSDError(ec)); |
160 |
|
ccy2rgb(&myBSDF.tLamb.spec, myBSDF.tLamb.cieY/PI, diffBSDF); |
165 |
|
return(cm_bsdf_Lamb(diffBSDF)); |
166 |
|
} |
167 |
|
if (tdf->ncomp != 1 || tdf->comp[0].func != &SDhandleMtx) { |
168 |
< |
sprintf(errmsg, "unsupported BSDF '%s'", fpath); |
168 |
> |
sprintf(errmsg, "unsupported BSDF '%s'", fname); |
169 |
|
error(USER, errmsg); |
170 |
|
} |
171 |
|
/* convert BTDF to matrix */ |