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.37 by greg, Sun Apr 5 01:32:01 2015 UTC vs.
Revision 3.40 by greg, Mon Apr 6 18:28:35 2015 UTC

# 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 1241 | Line 1241 | adjust_utree(float uprime, const double *cmin, double
1241   {
1242          SDextRGBs       *mp = (SDextRGBs *)cptr;
1243          double          cmax[SD_MAXDIM];
1244 +        double          yval;
1245          float           rgb[3];
1246 <        int             ok;
1246 >        C_COLOR         clr;
1247  
1248          if (mp->stc[tt_Y]->ndim == 3) {
1249                  if (cmin[0] + .5*csiz >= .5)
# Line 1253 | Line 1254 | adjust_utree(float uprime, const double *cmin, double
1254          cmax[1] = cmin[1] + csiz;
1255          cmax[2] = cmin[2] + csiz;
1256                                          /* average RGB color over voxel */
1257 <        SDyuv2rgb(SDavgTreBox(mp->stc[tt_Y], cmin, cmax), uprime,
1257 >        SDyuv2rgb(yval=SDavgTreBox(mp->stc[tt_Y], cmin, cmax), uprime,
1258                          SDavgTreBox(mp->stc[tt_v], cmin, cmax), rgb);
1259 <                                        /* subtract minimum */
1260 <        ok = (rgb[0] -= mp->rgb[0]) > 1e-5;
1261 <        ok &= (rgb[1] -= mp->rgb[1]) > 1e-5;
1262 <        ok &= (rgb[2] -= mp->rgb[2]) > 1e-5;
1263 <        if (ok) {                       /* compute new u' for adj. RGB */
1264 <                C_COLOR clr;
1264 <                c_fromSharpRGB(rgb, &clr);
1265 <                uprime = 4.*clr.cx/(-2.*clr.cx + 12.*clr.cy + 3.);
1266 <        } else
1267 <                uprime = 4./3./(-2./3. + 12./3. + 3.);
1259 >                                        /* subtract minimum (& clamp) */
1260 >        if ((rgb[0] -= mp->rgb[0]) < 1e-5*yval) rgb[0] = 1e-5*yval;
1261 >        if ((rgb[1] -= mp->rgb[1]) < 1e-5*yval) rgb[1] = 1e-5*yval;
1262 >        if ((rgb[2] -= mp->rgb[2]) < 1e-5*yval) rgb[2] = 1e-5*yval;
1263 >        c_fromSharpRGB(rgb, &clr);      /* compute new u' for adj. RGB */
1264 >        uprime = 4.*clr.cx/(-2.*clr.cx + 12.*clr.cy + 3.);
1265                                          /* assign in new u' tree */
1266          mp->new_stu = SDsetVoxel(mp->new_stu, mp->stc[tt_Y]->ndim,
1267                                          cmin, csiz, uprime);
# Line 1277 | Line 1274 | adjust_vtree(float vprime, const double *cmin, double
1274   {
1275          SDextRGBs       *mp = (SDextRGBs *)cptr;
1276          double          cmax[SD_MAXDIM];
1277 +        double          yval;
1278          float           rgb[3];
1279 <        int             ok;
1279 >        C_COLOR         clr;
1280  
1281          if (mp->stc[tt_Y]->ndim == 3) {
1282                  if (cmin[0] + .5*csiz >= .5)
# Line 1289 | Line 1287 | adjust_vtree(float vprime, const double *cmin, double
1287          cmax[1] = cmin[1] + csiz;
1288          cmax[2] = cmin[2] + csiz;
1289                                          /* average RGB color over voxel */
1290 <        SDyuv2rgb(SDavgTreBox(mp->stc[tt_Y], cmin, cmax),
1290 >        SDyuv2rgb(yval=SDavgTreBox(mp->stc[tt_Y], cmin, cmax),
1291                          SDavgTreBox(mp->stc[tt_u], cmin, cmax),
1292                          vprime, rgb);
1293 <                                        /* subtract minimum */
1294 <        ok = (rgb[0] -= mp->rgb[0]) > 1e-5;
1295 <        ok &= (rgb[1] -= mp->rgb[1]) > 1e-5;
1296 <        ok &= (rgb[2] -= mp->rgb[2]) > 1e-5;
1297 <        if (ok) {                       /* compute new v' for adj. RGB */
1298 <                C_COLOR clr;
1301 <                c_fromSharpRGB(rgb, &clr);
1302 <                vprime = 9.*clr.cy/(-2.*clr.cx + 12.*clr.cy + 3.);
1303 <        } else
1304 <                vprime = 9./3./(-2./3. + 12./3. + 3.);
1293 >                                        /* subtract minimum (& clamp) */
1294 >        if ((rgb[0] -= mp->rgb[0]) < 1e-5*yval) rgb[0] = 1e-5*yval;
1295 >        if ((rgb[1] -= mp->rgb[1]) < 1e-5*yval) rgb[1] = 1e-5*yval;
1296 >        if ((rgb[2] -= mp->rgb[2]) < 1e-5*yval) rgb[2] = 1e-5*yval;
1297 >        c_fromSharpRGB(rgb, &clr);      /* compute new v' for adj. RGB */
1298 >        vprime = 9.*clr.cy/(-2.*clr.cx + 12.*clr.cy + 3.);
1299                                          /* assign in new v' tree */
1300          mp->new_stv = SDsetVoxel(mp->new_stv, mp->stc[tt_Y]->ndim,
1301                                          cmin, csiz, vprime);
# Line 1320 | 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;
1328 <                return .0;              /* not worth bothering about */
1329 <        }
1330 <                                        /* 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);
1340 <        return M_PI*ymin;
1329 >
1330 >        return M_PI * ymin;
1331   }
1332  
1333   /* Extract and separate diffuse portion of BSDF */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines