| 14 |
|
#include "rtio.h" |
| 15 |
|
#include "resolu.h" |
| 16 |
|
#include "bsdfrep.h" |
| 17 |
+ |
/* active grid resolution */ |
| 18 |
+ |
int grid_res = GRIDRES; |
| 19 |
+ |
|
| 20 |
|
/* coverage/symmetry using INP_QUAD? flags */ |
| 21 |
|
int inp_coverage = 0; |
| 22 |
|
/* all incident angles in-plane so far? */ |
| 171 |
|
rev_symmetry(rbf->invec, sym); |
| 172 |
|
if (sym & MIRROR_X) |
| 173 |
|
for (n = rbf->nrbf; n-- > 0; ) |
| 174 |
< |
rbf->rbfa[n].gx = GRIDRES-1 - rbf->rbfa[n].gx; |
| 174 |
> |
rbf->rbfa[n].gx = grid_res-1 - rbf->rbfa[n].gx; |
| 175 |
|
if (sym & MIRROR_Y) |
| 176 |
|
for (n = rbf->nrbf; n-- > 0; ) |
| 177 |
< |
rbf->rbfa[n].gy = GRIDRES-1 - rbf->rbfa[n].gy; |
| 177 |
> |
rbf->rbfa[n].gy = grid_res-1 - rbf->rbfa[n].gy; |
| 178 |
|
} |
| 179 |
|
|
| 180 |
|
/* Compute volume associated with Gaussian lobe */ |
| 193 |
|
double uv[2]; |
| 194 |
|
double r2; |
| 195 |
|
|
| 196 |
< |
SDsquare2disk(uv, (1./GRIDRES)*(xpos+.5), (1./GRIDRES)*(ypos+.5)); |
| 196 |
> |
SDsquare2disk(uv, (1./grid_res)*(xpos+.5), (1./grid_res)*(ypos+.5)); |
| 197 |
|
/* uniform hemispherical projection */ |
| 198 |
|
r2 = uv[0]*uv[0] + uv[1]*uv[1]; |
| 199 |
|
vec[0] = vec[1] = sqrt(2. - r2); |
| 211 |
|
|
| 212 |
|
SDdisk2square(sq, vec[0]*norm, vec[1]*norm); |
| 213 |
|
|
| 214 |
< |
pos[0] = (int)(sq[0]*GRIDRES); |
| 215 |
< |
pos[1] = (int)(sq[1]*GRIDRES); |
| 214 |
> |
pos[0] = (int)(sq[0]*grid_res); |
| 215 |
> |
pos[1] = (int)(sq[1]*grid_res); |
| 216 |
|
} |
| 217 |
|
|
| 218 |
|
/* Evaluate RBF for DSF at the given normalized outgoing direction */ |
| 354 |
|
inp_coverage = 0; |
| 355 |
|
single_plane_incident = -1; |
| 356 |
|
input_orient = output_orient = 0; |
| 357 |
+ |
grid_res = GRIDRES; |
| 358 |
|
} |
| 359 |
|
|
| 360 |
|
/* Write our BSDF mesh interpolant out to the given binary stream */ |
| 367 |
|
/* finish header */ |
| 368 |
|
fprintf(ofp, "SYMMETRY=%d\n", !single_plane_incident * inp_coverage); |
| 369 |
|
fprintf(ofp, "IO_SIDES= %d %d\n", input_orient, output_orient); |
| 370 |
+ |
fprintf(ofp, "GRIDRES=%d\n", grid_res); |
| 371 |
|
fputformat(BSDFREP_FMT, ofp); |
| 372 |
|
fputc('\n', ofp); |
| 373 |
|
/* write each DSF */ |
| 429 |
|
sscanf(s+9, "%d %d", &input_orient, &output_orient); |
| 430 |
|
return(0); |
| 431 |
|
} |
| 432 |
+ |
if (!strncmp(s, "GRIDRES=", 8)) { |
| 433 |
+ |
sscanf(s+8, "%d", &grid_res); |
| 434 |
+ |
return(0); |
| 435 |
+ |
} |
| 436 |
|
if (formatval(fmt, s) && strcmp(fmt, BSDFREP_FMT)) |
| 437 |
|
return(-1); |
| 438 |
|
return(0); |
| 447 |
|
int i; |
| 448 |
|
|
| 449 |
|
clear_bsdf_rep(); |
| 450 |
+ |
if (ifp == NULL) |
| 451 |
+ |
return(0); |
| 452 |
|
if (getheader(ifp, headline, NULL) < 0 || single_plane_incident < 0 | |
| 453 |
|
!input_orient | !output_orient) { |
| 454 |
|
fprintf(stderr, "%s: missing/bad format for BSDF interpolant\n", |