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

Comparing ray/src/common/bsdf_m.c (file contents):
Revision 3.29 by greg, Thu Apr 2 16:40:32 2015 UTC vs.
Revision 3.31 by greg, Mon Apr 6 16:00:15 2015 UTC

# Line 64 | Line 64 | ANGLE_BASIS    abase_list[MAXABASES] = {
64  
65   int             nabases = 3;            /* current number of defined bases */
66  
67 < C_COLOR mtx_RGB_prim[3];                /* our RGB primaries  */
68 < float   mtx_RGB_coef[3];                /* corresponding Y coefficients */
67 > C_COLOR         mtx_RGB_prim[3];        /* our RGB primaries  */
68 > float           mtx_RGB_coef[3];        /* corresponding Y coefficients */
69  
70   enum {mtx_Y, mtx_X, mtx_Z};             /* matrix components (mtx_Y==0) */
71  
# Line 591 | Line 591 | static double
591   subtract_min(C_COLOR *cs, SDMat *sm)
592   {
593          const int       ncomp = 1 + 2*(sm->chroma != NULL);
594 <        float           min_coef[3], coef[3];
594 >        float           min_coef[3], ymin, coef[3];
595          int             i, o, c;
596          
597          min_coef[0] = min_coef[1] = min_coef[2] = FHUGE;
# Line 602 | Line 602 | subtract_min(C_COLOR *cs, SDMat *sm)
602                                  if (coef[c] < min_coef[c])
603                                          min_coef[c] = coef[c];
604                  }
605 +        ymin = 0;
606          for (c = ncomp; c--; )
607 <                if (min_coef[c] > FTINY)
608 <                        break;
608 <        if (c < 0)
607 >                ymin += min_coef[c];
608 >        if (ymin <= .01/M_PI)           /* not worth bothering about? */
609                  return .0;
610          if (ncomp == 1) {               /* subtract grayscale minimum */
611                  for (i = sm->ninc*sm->nout; i--; )
612 <                        sm->bsdf[i] -= min_coef[0];
612 >                        sm->bsdf[i] -= ymin;
613                  *cs = c_dfcolor;
614 <                return min_coef[0]*M_PI;
614 >                return M_PI*ymin;
615          }
616                                          /* else subtract colored minimum */
617          for (i = 0; i < sm->ninc; i++)
# Line 621 | Line 621 | subtract_min(C_COLOR *cs, SDMat *sm)
621                          while (c--)
622                                  coef[c] = (coef[c] - min_coef[c]) /
623                                                  mtx_RGB_coef[c];
624 <                        c_fromSharpRGB(coef, &cxy);
625 <                        sm->chroma[o*sm->ninc + i] = c_encodeChroma(&cxy);
626 <                        mBSDF_value(sm,i,o) -= min_coef[0]+min_coef[1]+min_coef[2];
624 >                        if (c_fromSharpRGB(coef, &cxy) > 1e-5)
625 >                                sm->chroma[o*sm->ninc + i] = c_encodeChroma(&cxy);
626 >                        mBSDF_value(sm,i,o) -= ymin;
627                  }
628
628                                          /* return colored minimum */
629 <        c_cmix(cs, min_coef[0], &mtx_RGB_prim[0], min_coef[1], &mtx_RGB_prim[1]);
630 <        c_cmix(cs, min_coef[0]+min_coef[1], cs, min_coef[2], &mtx_RGB_prim[2]);
629 >        for (i = 3; i--; )
630 >                coef[i] = min_coef[i]/mtx_RGB_coef[i];
631 >        c_fromSharpRGB(coef, cs);
632  
633 <        return (min_coef[0]+min_coef[1]+min_coef[2])*M_PI;
633 >        return M_PI*ymin;
634   }
635  
636   /* Extract and separate diffuse portion of BSDF & convert color */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines