34 |
|
|
35 |
|
/* BSDF value for boundary regions */ |
36 |
|
double bsdf_min = 0; |
37 |
+ |
float bsdf_spec_peak = 0; |
38 |
+ |
int bsdf_spec_crad = 0; |
39 |
|
|
40 |
|
/* processed incident DSF measurements */ |
41 |
|
RBFNODE *dsf_list = NULL; |
259 |
|
return(integ); |
260 |
|
} |
261 |
|
|
262 |
< |
/* Evaluate RBF for DSF at the given normalized outgoing direction */ |
262 |
> |
/* Evaluate BSDF at the given normalized outgoing direction */ |
263 |
|
double |
264 |
|
eval_rbfrep(const RBFNODE *rp, const FVECT outvec) |
265 |
|
{ |
266 |
|
const double rfact2 = (38./M_PI/M_PI)*(grid_res*grid_res); |
265 |
– |
double minval = bsdf_min*output_orient*outvec[2]; |
267 |
|
int pos[2]; |
268 |
|
double res = 0; |
269 |
|
const RBFVAL *rbfp; |
275 |
|
return(.0); |
276 |
|
/* use minimum if no information avail. */ |
277 |
|
if (rp == NULL) |
278 |
< |
return(minval); |
278 |
> |
return(bsdf_min); |
279 |
|
/* optimization for fast lobe culling */ |
280 |
|
pos_from_vec(pos, outvec); |
281 |
|
/* sum radial basis function */ |
290 |
|
ovec_from_pos(odir, rbfp->gx, rbfp->gy); |
291 |
|
res += rbfp->peak * exp((DOT(odir,outvec) - 1.) / rad2); |
292 |
|
} |
293 |
< |
if (res < minval) /* never return less than minval */ |
294 |
< |
return(minval); |
293 |
> |
res /= output_orient*outvec[2]; |
294 |
> |
if (res < bsdf_min) /* never return less than bsdf_min */ |
295 |
> |
return(bsdf_min); |
296 |
|
return(res); |
297 |
|
} |
298 |
|
|
396 |
|
return((rbfv[0] != NULL) + (rbfv[1] != NULL)); |
397 |
|
} |
398 |
|
|
399 |
+ |
/* Return single-lobe specular RBF for the given incident direction */ |
400 |
+ |
RBFNODE * |
401 |
+ |
def_rbf_spec(const FVECT invec) |
402 |
+ |
{ |
403 |
+ |
RBFNODE *rbf; |
404 |
+ |
FVECT ovec; |
405 |
+ |
int pos[2]; |
406 |
+ |
|
407 |
+ |
if (input_orient > 0 ^ invec[2] > 0) /* wrong side? */ |
408 |
+ |
return(NULL); |
409 |
+ |
if ((bsdf_spec_peak <= bsdf_min) | (bsdf_spec_crad <= 0)) |
410 |
+ |
return(NULL); /* nothing set */ |
411 |
+ |
rbf = (RBFNODE *)malloc(sizeof(RBFNODE)); |
412 |
+ |
if (rbf == NULL) |
413 |
+ |
return(NULL); |
414 |
+ |
ovec[0] = -invec[0]; |
415 |
+ |
ovec[1] = -invec[1]; |
416 |
+ |
ovec[2] = invec[2]*(2*(input_orient==output_orient) - 1); |
417 |
+ |
pos_from_vec(pos, ovec); |
418 |
+ |
rbf->ord = 0; |
419 |
+ |
rbf->next = NULL; |
420 |
+ |
rbf->ejl = NULL; |
421 |
+ |
VCOPY(rbf->invec, invec); |
422 |
+ |
rbf->nrbf = 1; |
423 |
+ |
rbf->rbfa[0].peak = bsdf_spec_peak * output_orient*ovec[2]; |
424 |
+ |
rbf->rbfa[0].crad = bsdf_spec_crad; |
425 |
+ |
rbf->rbfa[0].gx = pos[0]; |
426 |
+ |
rbf->rbfa[0].gy = pos[1]; |
427 |
+ |
rbf->vtotal = rbf_volume(rbf->rbfa); |
428 |
+ |
return(rbf); |
429 |
+ |
} |
430 |
+ |
|
431 |
|
/* Advect and allocate new RBF along edge (internal call) */ |
432 |
|
RBFNODE * |
433 |
|
e_advect_rbf(const MIGRATION *mig, const FVECT invec, int lobe_lim) |
534 |
|
single_plane_incident = -1; |
535 |
|
input_orient = output_orient = 0; |
536 |
|
grid_res = GRIDRES; |
537 |
+ |
bsdf_min = 0; |
538 |
+ |
bsdf_spec_peak = 0; |
539 |
+ |
bsdf_spec_crad = 0; |
540 |
|
} |
541 |
|
|
542 |
|
/* Write our BSDF mesh interpolant out to the given binary stream */ |
555 |
|
fprintf(ofp, "IO_SIDES= %d %d\n", input_orient, output_orient); |
556 |
|
fprintf(ofp, "GRIDRES=%d\n", grid_res); |
557 |
|
fprintf(ofp, "BSDFMIN=%g\n", bsdf_min); |
558 |
+ |
if ((bsdf_spec_peak > bsdf_min) & (bsdf_spec_crad > 0)) |
559 |
+ |
fprintf(ofp, "BSDFSPEC= %f %f\n", bsdf_spec_peak, |
560 |
+ |
R2ANG(bsdf_spec_crad)); |
561 |
|
fputformat(BSDFREP_FMT, ofp); |
562 |
|
fputc('\n', ofp); |
563 |
|
/* write each DSF */ |
633 |
|
} |
634 |
|
if (!strncmp(s, "BSDFMIN=", 8)) { |
635 |
|
sscanf(s+8, "%lf", &bsdf_min); |
636 |
+ |
return(0); |
637 |
+ |
} |
638 |
+ |
if (!strncmp(s, "BSDFSPEC=", 9)) { |
639 |
+ |
float bsdf_spec_rad = 0; |
640 |
+ |
sscanf(s+9, "%f %f", &bsdf_spec_peak, &bsdf_spec_rad); |
641 |
+ |
bsdf_spec_crad = ANG2R(bsdf_spec_rad); |
642 |
|
return(0); |
643 |
|
} |
644 |
|
if (formatval(fmt, s) && strcmp(fmt, BSDFREP_FMT)) |