112 |
|
{ |
113 |
|
const int sqres = 1<<samp_order; |
114 |
|
FILE *ofp = NULL; |
115 |
+ |
int assignD = 0; |
116 |
|
char cmd[128]; |
117 |
|
int ix, ox, oy; |
118 |
|
double iovec[6]; |
132 |
|
SET_FILE_BINARY(ofp); |
133 |
|
} else |
134 |
|
fputs("{\n", stdout); |
135 |
+ |
/* need to assign Dx, Dy, Dz? */ |
136 |
+ |
if (funame != NULL) |
137 |
+ |
assignD = (fundefined(funame) < 6); |
138 |
|
/* run through directions */ |
139 |
|
for (ix = 0; ix < sqres/2; ix++) { |
140 |
|
RBFNODE *rbf = NULL; |
153 |
|
bsdf = eval_rbfrep(rbf, iovec+3) * |
154 |
|
output_orient/iovec[5]; |
155 |
|
else { |
156 |
< |
double ssa[3], ssvec[6]; |
156 |
> |
double ssa[3], ssvec[6], sum; |
157 |
|
int ssi; |
158 |
+ |
if (assignD) { |
159 |
+ |
varset("Dx", '=', -iovec[3]); |
160 |
+ |
varset("Dy", '=', -iovec[4]); |
161 |
+ |
varset("Dz", '=', -iovec[5]); |
162 |
+ |
++eclock; |
163 |
+ |
} |
164 |
|
bsdf = funvalue(funame, 6, iovec); |
165 |
|
if (abs_diff(bsdf, last_bsdf) > ssamp_thresh) { |
166 |
< |
bsdf = 0; /* super-sample voxel */ |
166 |
> |
sum = 0; /* super-sample voxel */ |
167 |
|
for (ssi = nssamp; ssi--; ) { |
168 |
|
SDmultiSamp(ssa, 3, (ssi+drand48())/nssamp); |
169 |
|
ssvec[0] = 2.*(ix+ssa[0])/sqres - 1.; |
175 |
|
ssvec[5] = output_orient * |
176 |
|
sqrt(1. - ssvec[3]*ssvec[3] - |
177 |
|
ssvec[4]*ssvec[4]); |
178 |
< |
bsdf += funvalue(funame, 6, ssvec); |
178 |
> |
if (assignD) { |
179 |
> |
varset("Dx", '=', -iovec[3]); |
180 |
> |
varset("Dy", '=', -iovec[4]); |
181 |
> |
varset("Dz", '=', -iovec[5]); |
182 |
> |
++eclock; |
183 |
> |
} |
184 |
> |
sum += funvalue(funame, 6, ssvec); |
185 |
|
} |
186 |
< |
bsdf /= (float)nssamp; |
186 |
> |
bsdf = sum/nssamp; |
187 |
|
} |
188 |
|
} |
189 |
|
if (pctcull >= 0) |
216 |
|
{ |
217 |
|
const int sqres = 1<<samp_order; |
218 |
|
FILE *ofp = NULL; |
219 |
+ |
int assignD = 0; |
220 |
|
char cmd[128]; |
221 |
|
int ix, iy, ox, oy; |
222 |
|
double iovec[6]; |
235 |
|
} |
236 |
|
} else |
237 |
|
fputs("{\n", stdout); |
238 |
+ |
/* need to assign Dx, Dy, Dz? */ |
239 |
+ |
if (funame != NULL) |
240 |
+ |
assignD = (fundefined(funame) < 6); |
241 |
|
/* run through directions */ |
242 |
|
for (ix = 0; ix < sqres; ix++) |
243 |
|
for (iy = 0; iy < sqres; iy++) { |
257 |
|
bsdf = eval_rbfrep(rbf, iovec+3) * |
258 |
|
output_orient/iovec[5]; |
259 |
|
else { |
260 |
< |
double ssa[4], ssvec[6]; |
260 |
> |
double ssa[4], ssvec[6], sum; |
261 |
|
int ssi; |
262 |
+ |
if (assignD) { |
263 |
+ |
varset("Dx", '=', -iovec[3]); |
264 |
+ |
varset("Dy", '=', -iovec[4]); |
265 |
+ |
varset("Dz", '=', -iovec[5]); |
266 |
+ |
++eclock; |
267 |
+ |
} |
268 |
|
bsdf = funvalue(funame, 6, iovec); |
269 |
|
if (abs_diff(bsdf, last_bsdf) > ssamp_thresh) { |
270 |
< |
bsdf = 0; /* super-sample voxel */ |
270 |
> |
sum = 0; /* super-sample voxel */ |
271 |
|
for (ssi = nssamp; ssi--; ) { |
272 |
|
SDmultiSamp(ssa, 4, (ssi+drand48())/nssamp); |
273 |
|
SDsquare2disk(ssvec, 1.-(ix+ssa[0])/sqres, |
280 |
|
ssvec[5] = output_orient * |
281 |
|
sqrt(1. - ssvec[3]*ssvec[3] - |
282 |
|
ssvec[4]*ssvec[4]); |
283 |
< |
bsdf += funvalue(funame, 6, ssvec); |
283 |
> |
if (assignD) { |
284 |
> |
varset("Dx", '=', -iovec[3]); |
285 |
> |
varset("Dy", '=', -iovec[4]); |
286 |
> |
varset("Dz", '=', -iovec[5]); |
287 |
> |
++eclock; |
288 |
> |
} |
289 |
> |
sum += funvalue(funame, 6, ssvec); |
290 |
|
} |
291 |
< |
bsdf /= (float)nssamp; |
291 |
> |
bsdf = sum/nssamp; |
292 |
|
} |
293 |
|
} |
294 |
|
if (pctcull >= 0) |
362 |
|
if (single_plane_incident >= 0) { /* function-based BSDF? */ |
363 |
|
void (*evf)(char *s) = single_plane_incident ? |
364 |
|
&eval_isotropic : &eval_anisotropic; |
365 |
< |
if (i != argc-1 || fundefined(argv[i]) != 6) { |
365 |
> |
if (i != argc-1 || fundefined(argv[i]) < 3) { |
366 |
|
fprintf(stderr, |
367 |
|
"%s: need single function with 6 arguments: bsdf(ix,iy,iz,ox,oy,oz)\n", |
368 |
|
progname); |
369 |
+ |
fprintf(stderr, "\tor 3 arguments using Dx,Dy,Dz: bsdf(ix,iy,iz)\n", |
370 |
+ |
progname); |
371 |
|
goto userr; |
372 |
|
} |
373 |
+ |
++eclock; |
374 |
|
xml_prologue(argc, argv); /* start XML output */ |
375 |
|
if (dofwd) { |
376 |
|
input_orient = -1; |