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

Comparing ray/src/common/bsdf_t.c (file contents):
Revision 3.38 by greg, Sun Apr 5 06:02:43 2015 UTC vs.
Revision 3.42 by greg, Sat Apr 25 19:08:29 2015 UTC

# Line 569 | Line 569 | SDqueryTre(const SDTre *sdt, float *coef,
569                  return 0;               /* should be internal error */
570                                          /* get BSDF value */
571          yval = SDlookupTre(sdt->stc[tt_Y], gridPos, hc);
572 +        if (coef == NULL)               /* just getting hypercube? */
573 +                return 1;
574          if (sdt->stc[tt_u] == NULL || sdt->stc[tt_v] == NULL) {
575 <                if (coef != NULL) *coef = yval;
575 >                *coef = yval;
576                  return 1;               /* no color */
577          }
576        if (coef == NULL)               /* just getting hypercube? */
577                return 1;
578                                          /* else decode color */
579          SDyuv2rgb(yval, SDlookupTre(sdt->stc[tt_u], gridPos, NULL),
580                          SDlookupTre(sdt->stc[tt_v], gridPos, NULL), coef);
# Line 1194 | Line 1194 | subtract_min_Y(SDNode *st)
1194          } else                          /* anisotropic covers entire tree */
1195                  vmin = SDgetTreMin(st);
1196  
1197 <        if (vmin <= FTINY)
1198 <                return .0;
1197 >        if (vmin <= .01/M_PI)
1198 >                return .0;              /* not worth bothering about */
1199  
1200          SDsubtractTreVal(st, vmin);
1201  
# Line 1314 | Line 1314 | subtract_min_RGB(C_COLOR *cs, SDNode *stc[])
1314          my_min.new_stu = my_min.new_stv = NULL;
1315                                          /* get minimum RGB value */
1316          SDtraverseTre(stc[tt_Y], NULL, 0, get_min_RGB, &my_min);
1317 <        ymin = tt_RGB_coef[0]*my_min.rgb[0] +
1318 <                        tt_RGB_coef[1]*my_min.rgb[1] +
1319 <                                        tt_RGB_coef[2]*my_min.rgb[2];
1320 <        if (ymin <= 1e-5) {
1321 <                *cs = c_dfcolor;
1322 <                return .0;              /* not worth bothering about */
1323 <        }
1324 <                                        /* adjust u' & v' values */
1317 >                                        /* convert to C_COLOR */
1318 >        ymin =  c_fromSharpRGB(my_min.rgb, cs);
1319 >        if (ymin <= .01/M_PI)           /* not worth bothering about? */
1320 >                return .0;
1321 >                                        /* adjust u' & v' trees */
1322          SDtraverseTre(stc[tt_u], NULL, 0, adjust_utree, &my_min);
1323          SDtraverseTre(stc[tt_v], NULL, 0, adjust_vtree, &my_min);
1324          SDfreeTre(stc[tt_u]); SDfreeTre(stc[tt_v]);
1325          stc[tt_u] = SDsimplifyTre(my_min.new_stu);
1326          stc[tt_v] = SDsimplifyTre(my_min.new_stv);
1327 <                                        /* finally, subtract Y value */
1327 >                                        /* subtract Y & return hemispherical */
1328          SDsubtractTreVal(stc[tt_Y], ymin);
1329 <                                        /* return color and Y */
1330 <        c_fromSharpRGB(my_min.rgb, cs);
1334 <        return M_PI*ymin;
1329 >
1330 >        return M_PI * ymin;
1331   }
1332  
1333   /* Extract and separate diffuse portion of BSDF */
# Line 1358 | Line 1354 | extract_diffuse(SDValue *dv, SDSpectralDF *df)
1354                  memcpy(df->comp[0].cspec, tt_RGB_prim, sizeof(tt_RGB_prim));
1355                  dv->cieY = subtract_min_RGB(&dv->spec, sdt->stc);
1356          } else {
1357 <                df->comp[0].cspec[0] = c_dfcolor;
1357 >                df->comp[0].cspec[0] = dv->spec = c_dfcolor;
1358                  dv->cieY = subtract_min_Y(sdt->stc[tt_Y]);
1359          }
1360          df->maxHemi -= dv->cieY;        /* adjust maximum hemispherical */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines