ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cv/bsdfrep.c
(Generate patch)

Comparing ray/src/cv/bsdfrep.c (file contents):
Revision 2.29 by greg, Fri Jan 29 16:21:55 2016 UTC vs.
Revision 2.33 by greg, Sat Dec 28 18:05:14 2019 UTC

# Line 9 | Line 9 | static const char RCSid[] = "$Id$";
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"
# Line 42 | Line 41 | unsigned long          bsdf_hist[HISTLEN];
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 */
# Line 310 | Line 309 | eval_rbfcol(SDValue *sv, const RBFNODE *rp, const FVEC
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  
# Line 443 | Line 442 | def_rbf_spec(const FVECT invec)
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)
# Line 457 | Line 456 | def_rbf_spec(const FVECT invec)
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];
# Line 582 | Line 581 | clear_bsdf_rep(void)
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  
# Line 604 | Line 604 | save_bsdf_rep(FILE *ofp)
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);
# Line 658 | Line 658 | save_bsdf_rep(FILE *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)) {
# Line 698 | Line 698 | headline(char *s, void *p)
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))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines