| 34 |
|
|
| 35 |
|
/* BSDF value for boundary regions */ |
| 36 |
|
double bsdf_min = 0; |
| 37 |
< |
float bsdf_spec_peak = 0; |
| 38 |
< |
int bsdf_spec_crad = 0; |
| 37 |
> |
double bsdf_spec_peak = 0; |
| 38 |
> |
double bsdf_spec_rad = 0; |
| 39 |
|
|
| 40 |
|
/* processed incident DSF measurements */ |
| 41 |
|
RBFNODE *dsf_list = NULL; |
| 50 |
|
int |
| 51 |
|
new_input_direction(double new_theta, double new_phi) |
| 52 |
|
{ |
| 53 |
– |
if (!input_orient) /* check input orientation */ |
| 54 |
– |
input_orient = 1 - 2*(new_theta > 90.); |
| 55 |
– |
else if (input_orient > 0 ^ new_theta < 90.) { |
| 56 |
– |
fprintf(stderr, |
| 57 |
– |
"%s: Cannot handle input angles on both sides of surface\n", |
| 58 |
– |
progname); |
| 59 |
– |
return(0); |
| 60 |
– |
} |
| 53 |
|
/* normalize angle ranges */ |
| 54 |
|
while (new_theta < -180.) |
| 55 |
|
new_theta += 360.; |
| 59 |
|
new_theta = -new_theta; |
| 60 |
|
new_phi += 180.; |
| 61 |
|
} |
| 70 |
– |
if ((theta_in_deg = new_theta) < 1.0) |
| 71 |
– |
return(1); /* don't rely on phi near normal */ |
| 62 |
|
while (new_phi < 0) |
| 63 |
|
new_phi += 360.; |
| 64 |
|
while (new_phi >= 360.) |
| 65 |
|
new_phi -= 360.; |
| 66 |
+ |
/* check input orientation */ |
| 67 |
+ |
if (!input_orient) |
| 68 |
+ |
input_orient = 1 - 2*(new_theta > 90.); |
| 69 |
+ |
else if (input_orient > 0 ^ new_theta < 90.) { |
| 70 |
+ |
fprintf(stderr, |
| 71 |
+ |
"%s: Cannot handle input angles on both sides of surface\n", |
| 72 |
+ |
progname); |
| 73 |
+ |
return(0); |
| 74 |
+ |
} |
| 75 |
+ |
if ((theta_in_deg = new_theta) < 1.0) |
| 76 |
+ |
return(1); /* don't rely on phi near normal */ |
| 77 |
|
if (single_plane_incident > 0) /* check input coverage */ |
| 78 |
|
single_plane_incident = (round(new_phi) == round(phi_in_deg)); |
| 79 |
|
else if (single_plane_incident < 0) |
| 291 |
|
ovec_from_pos(odir, rbfp->gx, rbfp->gy); |
| 292 |
|
res += rbfp->peak * exp((DOT(odir,outvec) - 1.) / rad2); |
| 293 |
|
} |
| 294 |
< |
res /= output_orient*outvec[2]; |
| 294 |
> |
res /= COSF(outvec[2]); |
| 295 |
|
if (res < bsdf_min) /* never return less than bsdf_min */ |
| 296 |
|
return(bsdf_min); |
| 297 |
|
return(res); |
| 407 |
|
|
| 408 |
|
if (input_orient > 0 ^ invec[2] > 0) /* wrong side? */ |
| 409 |
|
return(NULL); |
| 410 |
< |
if ((bsdf_spec_peak <= bsdf_min) | (bsdf_spec_crad <= 0)) |
| 410 |
> |
if ((bsdf_spec_peak <= bsdf_min) | (bsdf_spec_rad <= 0)) |
| 411 |
|
return(NULL); /* nothing set */ |
| 412 |
|
rbf = (RBFNODE *)malloc(sizeof(RBFNODE)); |
| 413 |
|
if (rbf == NULL) |
| 422 |
|
VCOPY(rbf->invec, invec); |
| 423 |
|
rbf->nrbf = 1; |
| 424 |
|
rbf->rbfa[0].peak = bsdf_spec_peak * output_orient*ovec[2]; |
| 425 |
< |
rbf->rbfa[0].crad = bsdf_spec_crad; |
| 425 |
> |
rbf->rbfa[0].crad = ANG2R(bsdf_spec_rad); |
| 426 |
|
rbf->rbfa[0].gx = pos[0]; |
| 427 |
|
rbf->rbfa[0].gy = pos[1]; |
| 428 |
|
rbf->vtotal = rbf_volume(rbf->rbfa); |
| 537 |
|
grid_res = GRIDRES; |
| 538 |
|
bsdf_min = 0; |
| 539 |
|
bsdf_spec_peak = 0; |
| 540 |
< |
bsdf_spec_crad = 0; |
| 540 |
> |
bsdf_spec_rad = 0; |
| 541 |
|
} |
| 542 |
|
|
| 543 |
|
/* Write our BSDF mesh interpolant out to the given binary stream */ |
| 556 |
|
fprintf(ofp, "IO_SIDES= %d %d\n", input_orient, output_orient); |
| 557 |
|
fprintf(ofp, "GRIDRES=%d\n", grid_res); |
| 558 |
|
fprintf(ofp, "BSDFMIN=%g\n", bsdf_min); |
| 559 |
< |
if ((bsdf_spec_peak > bsdf_min) & (bsdf_spec_crad > 0)) |
| 560 |
< |
fprintf(ofp, "BSDFSPEC= %f %f\n", bsdf_spec_peak, |
| 560 |
< |
R2ANG(bsdf_spec_crad)); |
| 559 |
> |
if ((bsdf_spec_peak > bsdf_min) & (bsdf_spec_rad > 0)) |
| 560 |
> |
fprintf(ofp, "BSDFSPEC= %f %f\n", bsdf_spec_peak, bsdf_spec_rad); |
| 561 |
|
fputformat(BSDFREP_FMT, ofp); |
| 562 |
|
fputc('\n', ofp); |
| 563 |
|
/* write each DSF */ |
| 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); |
| 639 |
> |
sscanf(s+9, "%lf %lf", &bsdf_spec_peak, &bsdf_spec_rad); |
| 640 |
|
return(0); |
| 641 |
|
} |
| 642 |
|
if (formatval(fmt, s) && strcmp(fmt, BSDFREP_FMT)) |