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.38 by greg, Sun Apr 5 06:02:43 2015 UTC

# 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);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines