9 |
|
|
10 |
|
#define _USE_MATH_DEFINES |
11 |
|
#include <stdlib.h> |
12 |
– |
#include <string.h> |
12 |
|
#include <math.h> |
13 |
|
#include "rtio.h" |
14 |
|
#include "resolu.h" |
41 |
|
|
42 |
|
/* BSDF value for boundary regions */ |
43 |
|
double bsdf_min = 0; |
44 |
< |
double bsdf_spec_peak = 0; |
44 |
> |
double bsdf_spec_val = 0; |
45 |
|
double bsdf_spec_rad = 0; |
46 |
|
|
47 |
|
/* processed incident DSF measurements */ |
309 |
|
} |
310 |
|
res += val; |
311 |
|
} |
312 |
< |
if ((rbf_colorimetry == RBCtristimulus) & (res > 1e-6)) { |
312 |
> |
sv->cieY = res / COSF(outvec[2]); |
313 |
> |
if (sv->cieY < bsdf_min) { /* never return less than bsdf_min */ |
314 |
> |
sv->cieY = bsdf_min; |
315 |
> |
} else if (rbf_colorimetry == RBCtristimulus) { |
316 |
|
C_CHROMA cres = (int)(usum/res + frandom()); |
317 |
|
cres |= (int)(vsum/res + frandom()) << 8; |
318 |
|
c_decodeChroma(&sv->spec, cres); |
319 |
|
} |
318 |
– |
sv->cieY = res / COSF(outvec[2]); |
319 |
– |
if (sv->cieY < bsdf_min) /* never return less than bsdf_min */ |
320 |
– |
sv->cieY = bsdf_min; |
320 |
|
return(SDEnone); |
321 |
|
} |
322 |
|
|
442 |
|
|
443 |
|
if (input_orient > 0 ^ invec[2] > 0) /* wrong side? */ |
444 |
|
return(NULL); |
445 |
< |
if ((bsdf_spec_peak <= bsdf_min) | (bsdf_spec_rad <= 0)) |
445 |
> |
if ((bsdf_spec_val <= bsdf_min) | (bsdf_spec_rad <= 0)) |
446 |
|
return(NULL); /* nothing set */ |
447 |
|
rbf = (RBFNODE *)malloc(sizeof(RBFNODE)); |
448 |
|
if (rbf == NULL) |
456 |
|
rbf->ejl = NULL; |
457 |
|
VCOPY(rbf->invec, invec); |
458 |
|
rbf->nrbf = 1; |
459 |
< |
rbf->rbfa[0].peak = bsdf_spec_peak * output_orient*ovec[2]; |
459 |
> |
rbf->rbfa[0].peak = bsdf_spec_val * COSF(ovec[2]); |
460 |
|
rbf->rbfa[0].chroma = c_dfchroma; |
461 |
|
rbf->rbfa[0].crad = ANG2R(bsdf_spec_rad); |
462 |
|
rbf->rbfa[0].gx = pos[0]; |
581 |
|
input_orient = output_orient = 0; |
582 |
|
rbf_colorimetry = RBCunknown; |
583 |
|
grid_res = GRIDRES; |
584 |
+ |
memset(bsdf_hist, 0, sizeof(bsdf_hist)); |
585 |
|
bsdf_min = 0; |
586 |
< |
bsdf_spec_peak = 0; |
586 |
> |
bsdf_spec_val = 0; |
587 |
|
bsdf_spec_rad = 0; |
588 |
|
} |
589 |
|
|
604 |
|
fprintf(ofp, "COLORIMETRY=%s\n", RBCident[rbf_colorimetry]); |
605 |
|
fprintf(ofp, "GRIDRES=%d\n", grid_res); |
606 |
|
fprintf(ofp, "BSDFMIN=%g\n", bsdf_min); |
607 |
< |
if ((bsdf_spec_peak > bsdf_min) & (bsdf_spec_rad > 0)) |
608 |
< |
fprintf(ofp, "BSDFSPEC= %f %f\n", bsdf_spec_peak, bsdf_spec_rad); |
607 |
> |
if ((bsdf_spec_val > bsdf_min) & (bsdf_spec_rad > 0)) |
608 |
> |
fprintf(ofp, "BSDFSPEC= %f %f\n", bsdf_spec_val, bsdf_spec_rad); |
609 |
|
fputformat(BSDFREP_FMT, ofp); |
610 |
|
fputc('\n', ofp); |
611 |
|
putint(BSDFREP_MAGIC, 2, ofp); |
658 |
|
static int |
659 |
|
headline(char *s, void *p) |
660 |
|
{ |
661 |
< |
char fmt[64]; |
661 |
> |
char fmt[MAXFMTLEN]; |
662 |
|
int i; |
663 |
|
|
664 |
|
if (!strncmp(s, "NAME=", 5)) { |
698 |
|
return(0); |
699 |
|
} |
700 |
|
if (!strncmp(s, "BSDFSPEC=", 9)) { |
701 |
< |
sscanf(s+9, "%lf %lf", &bsdf_spec_peak, &bsdf_spec_rad); |
701 |
> |
sscanf(s+9, "%lf %lf", &bsdf_spec_val, &bsdf_spec_rad); |
702 |
|
return(0); |
703 |
|
} |
704 |
|
if (formatval(fmt, s) && strcmp(fmt, BSDFREP_FMT)) |