10 |
|
#include <string.h> |
11 |
|
#include <stdlib.h> |
12 |
|
#include <math.h> |
13 |
+ |
#include "rtprocess.h" |
14 |
|
#include "bsdfrep.h" |
15 |
|
|
16 |
|
const float colarr[6][3] = { |
91 |
|
#ifdef DEBUG |
92 |
|
fprintf(stderr, "Minimum BSDF set to %.4f\n", bsdf_min); |
93 |
|
#endif |
94 |
< |
min_log = log(bsdf_min*.5); |
94 |
> |
min_log = log(bsdf_min*.5 + 1e-5); |
95 |
|
/* output BSDF rep. */ |
96 |
|
for (n = 0; (n < 6) & (2*n+3 < argc); n++) { |
97 |
|
double theta = atof(argv[2*n+2]); |
131 |
|
for (i = 0; i < rbf->nrbf; i++) { |
132 |
|
ovec_from_pos(odir, rbf->rbfa[i].gx, rbf->rbfa[i].gy); |
133 |
|
bsdf = eval_rbfrep(rbf, odir) / (output_orient*odir[2]); |
134 |
< |
bsdf = log(bsdf) - min_log; |
134 |
> |
bsdf = log(bsdf + 1e-5) - min_log; |
135 |
|
printf("pmat sphere p%d\n0\n0\n4 %f %f %f %f\n", |
136 |
|
i+1, odir[0]*bsdf, odir[1]*bsdf, odir[2]*bsdf, |
137 |
|
.007*bsdf); |
138 |
|
} |
139 |
|
} |
140 |
|
fflush(stdout); |
141 |
< |
sprintf(buf, "gensurf tmat bsdf - - - %d %d", GRIDRES-1, GRIDRES-1); |
141 |
> |
sprintf(buf, "gensurf tmat bsdf%d - - - %d %d", n+1, |
142 |
> |
GRIDRES-1, GRIDRES-1); |
143 |
|
fp = popen(buf, "w"); |
144 |
|
if (fp == NULL) { |
145 |
|
fprintf(stderr, "%s: cannot open '| %s'\n", progname, buf); |
157 |
|
} else |
158 |
|
bsdf = eval_rbfrep(rbf, odir) / |
159 |
|
(output_orient*odir[2]); |
160 |
< |
bsdf = log(bsdf) - min_log; |
160 |
> |
bsdf = log(bsdf + 1e-5) - min_log; |
161 |
|
fprintf(fp, "%.8e %.8e %.8e\n", |
162 |
|
odir[0]*bsdf, odir[1]*bsdf, odir[2]*bsdf); |
163 |
|
} |