17 |
|
#include "calcomp.h" |
18 |
|
#include "bsdfrep.h" |
19 |
|
#include "bsdf_m.h" |
20 |
+ |
/* assumed maximum # Klems patches */ |
21 |
+ |
#define MAXPATCHES 145 |
22 |
|
/* global argv[0] */ |
23 |
|
char *progname; |
24 |
|
/* selected basis function name */ |
174 |
|
sum = 0; /* average over patches */ |
175 |
|
for (n = npsamps; n-- > 0; ) { |
176 |
|
fo_getvec(vout, j+(n+frandom())/npsamps, abp); |
177 |
< |
fi_getvec(vin, i+(n+frandom())/npsamps, abp); |
177 |
> |
fi_getvec(vin, i+urand(n), abp); |
178 |
|
ec = SDevalBSDF(&sv, vout, vin, &bsd); |
179 |
|
if (ec != SDEnone) |
180 |
|
goto err; |
195 |
|
sum = 0; /* average over patches */ |
196 |
|
for (n = npsamps; n-- > 0; ) { |
197 |
|
bo_getvec(vout, j+(n+frandom())/npsamps, abp); |
198 |
< |
bi_getvec(vin, i+(n+frandom())/npsamps, abp); |
198 |
> |
bi_getvec(vin, i+urand(n), abp); |
199 |
|
ec = SDevalBSDF(&sv, vout, vin, &bsd); |
200 |
|
if (ec != SDEnone) |
201 |
|
goto err; |
216 |
|
sum = 0; /* average over patches */ |
217 |
|
for (n = npsamps; n-- > 0; ) { |
218 |
|
bo_getvec(vout, j+(n+frandom())/npsamps, abp); |
219 |
< |
fi_getvec(vin, i+(n+frandom())/npsamps, abp); |
219 |
> |
fi_getvec(vin, i+urand(n), abp); |
220 |
|
ec = SDevalBSDF(&sv, vout, vin, &bsd); |
221 |
|
if (ec != SDEnone) |
222 |
|
goto err; |
237 |
|
sum = 0; /* average over patches */ |
238 |
|
for (n = npsamps; n-- > 0; ) { |
239 |
|
fo_getvec(vout, j+(n+frandom())/npsamps, abp); |
240 |
< |
bi_getvec(vin, i+(n+frandom())/npsamps, abp); |
240 |
> |
bi_getvec(vin, i+urand(n), abp); |
241 |
|
ec = SDevalBSDF(&sv, vout, vin, &bsd); |
242 |
|
if (ec != SDEnone) |
243 |
|
goto err; |
265 |
|
double sum; |
266 |
|
int i, j, n; |
267 |
|
|
268 |
+ |
initurand(npsamps); |
269 |
|
data_prologue(); /* begin output */ |
270 |
|
for (j = 0; j < abp->nangles; j++) { /* run through directions */ |
271 |
|
for (i = 0; i < abp->nangles; i++) { |
277 |
|
bo_getvec(iovec+3, j+(n+frandom())/npsamps, abp); |
278 |
|
|
279 |
|
if (input_orient > 0) |
280 |
< |
fi_getvec(iovec, i+(n+frandom())/npsamps, abp); |
280 |
> |
fi_getvec(iovec, i+urand(n), abp); |
281 |
|
else |
282 |
< |
bi_getvec(iovec, i+(n+frandom())/npsamps, abp); |
282 |
> |
bi_getvec(iovec, i+urand(n), abp); |
283 |
|
|
284 |
|
sum += funvalue(funame, 6, iovec); |
285 |
|
} |
294 |
|
static void |
295 |
|
eval_rbf(void) |
296 |
|
{ |
294 |
– |
#define MAXPATCHES 145 |
297 |
|
ANGLE_BASIS *abp = get_basis(kbasis); |
298 |
|
float bsdfarr[MAXPATCHES*MAXPATCHES]; |
299 |
|
FVECT vin, vout; |
326 |
|
} |
327 |
|
bsdfarr[j*abp->nangles + i] = sum*output_orient/npsamps; |
328 |
|
} |
329 |
+ |
if (rbf != NULL) |
330 |
+ |
free(rbf); |
331 |
|
} |
332 |
|
n = 0; /* write out our matrix */ |
333 |
|
for (j = 0; j < abp->nangles; j++) { |
336 |
|
putchar('\n'); |
337 |
|
} |
338 |
|
data_epilogue(); /* finish output */ |
335 |
– |
#undef MAXPATCHES |
339 |
|
} |
340 |
|
|
341 |
|
/* Read in BSDF and interpolate as Klems matrix representation */ |