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

Comparing ray/src/common/ccolor.c (file contents):
Revision 3.4 by greg, Fri May 18 20:43:13 2012 UTC vs.
Revision 3.5 by greg, Tue Jun 26 17:59:16 2012 UTC

# Line 22 | Line 22 | float  XYZfromSharp[3][3] = {
22          {-0.0123,  0.0167,  0.9955}
23   };
24  
25 < C_COLOR         c_dfcolor = C_DEFCOLOR;
25 > const C_COLOR   c_dfcolor = C_DEFCOLOR;
26  
27                                  /* CIE 1931 Standard Observer curves */
28 < static const C_COLOR    cie_xf = { 1, NULL, C_CDSPEC|C_CSSPEC|C_CSXY|C_CSEFF,
28 > const C_COLOR   c_x31 = { 1, NULL, C_CDSPEC|C_CSSPEC|C_CSXY|C_CSEFF,
29                          {14,42,143,435,1344,2839,3483,3362,2908,1954,956,
30                          320,49,93,633,1655,2904,4334,5945,7621,9163,10263,
31                          10622,10026,8544,6424,4479,2835,1649,874,468,227,
32                          114,58,29,14,7,3,2,1,0}, 106836L, .467, .368, 362.230
33                          };
34 < static const C_COLOR    cie_yf = { 1, NULL, C_CDSPEC|C_CSSPEC|C_CSXY|C_CSEFF,
34 > const C_COLOR   c_y31 = { 1, NULL, C_CDSPEC|C_CSSPEC|C_CSXY|C_CSEFF,
35                          {0,1,4,12,40,116,230,380,600,910,1390,2080,3230,
36                          5030,7100,8620,9540,9950,9950,9520,8700,7570,6310,
37                          5030,3810,2650,1750,1070,610,320,170,82,41,21,10,
38                          5,2,1,1,0,0}, 106856L, .398, .542, 493.525
39                          };
40 < static const C_COLOR    cie_zf = { 1, NULL, C_CDSPEC|C_CSSPEC|C_CSXY|C_CSEFF,
40 > const C_COLOR   c_z31 = { 1, NULL, C_CDSPEC|C_CSSPEC|C_CSXY|C_CSEFF,
41                          {65,201,679,2074,6456,13856,17471,17721,16692,
42                          12876,8130,4652,2720,1582,782,422,203,87,39,21,17,
43                          11,8,3,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
# Line 159 | Line 159 | c_sset(C_COLOR *clr, double wlmin, double wlmax, const
159                          scale = va[i];
160                  else if (va[i] < -scale)
161                          scale = -va[i];
162 <                yval += va[i] * cie_yf.ssamp[i];
162 >                yval += va[i] * c_y31.ssamp[i];
163          }
164          if (scale <= 1e-7)
165                  return(0.);
166 <        yval /= (double)cie_yf.ssum;
166 >        yval /= (double)c_y31.ssum;
167          scale = C_CMAXV / scale;
168          clr->ssum = 0;                  /* convert to our spacing */
169          wl0 = wlmin;
# Line 218 | Line 218 | c_ccvt(C_COLOR *clr, int fl)
218          if (fl & C_CSXY) {              /* cspec -> cxy */
219                  x = y = z = 0.;
220                  for (i = 0; i < C_CNSS; i++) {
221 <                        x += cie_xf.ssamp[i] * clr->ssamp[i];
222 <                        y += cie_yf.ssamp[i] * clr->ssamp[i];
223 <                        z += cie_zf.ssamp[i] * clr->ssamp[i];
221 >                        x += c_x31.ssamp[i] * clr->ssamp[i];
222 >                        y += c_y31.ssamp[i] * clr->ssamp[i];
223 >                        z += c_z31.ssamp[i] * clr->ssamp[i];
224                  }
225 <                x /= (double)cie_xf.ssum;
226 <                y /= (double)cie_yf.ssum;
227 <                z /= (double)cie_zf.ssum;
225 >                x /= (double)c_x31.ssum;
226 >                y /= (double)c_y31.ssum;
227 >                z /= (double)c_z31.ssum;
228                  z += x + y;
229                  clr->cx = x / z;
230                  clr->cy = y / z;
# Line 248 | Line 248 | c_ccvt(C_COLOR *clr, int fl)
248                  if (clr->flags & C_CSSPEC) {            /* from spectrum */
249                          y = 0.;
250                          for (i = 0; i < C_CNSS; i++)
251 <                                y += cie_yf.ssamp[i] * clr->ssamp[i];
251 >                                y += c_y31.ssamp[i] * clr->ssamp[i];
252                          clr->eff = C_CLPWM * y / clr->ssum;
253                  } else /* clr->flags & C_CSXY */ {      /* from (x,y) */
254 <                        clr->eff = clr->cx*cie_xf.eff + clr->cy*cie_yf.eff +
255 <                                        (1. - clr->cx - clr->cy)*cie_zf.eff;
254 >                        clr->eff = clr->cx*c_x31.eff + clr->cy*c_y31.eff +
255 >                                        (1. - clr->cx - clr->cy)*c_z31.eff;
256                  }
257                  clr->flags |= C_CSEFF;
258          }
# Line 331 | Line 331 | c_cmult(C_COLOR *cres, C_COLOR *c1, double y1, C_COLOR
331                          cres->ssum += cres->ssamp[i] = cmix[i] / cmax;
332                  cres->flags = C_CDSPEC|C_CSSPEC;
333  
334 <                c_ccvt(cres, C_CSEFF);                  /* nasty, but true */
335 <                yres = y1 * y2 * cie_yf.ssum * C_CLPWM /
334 >                c_ccvt(cres, C_CSEFF);                  /* don't touch below */
335 >                yres = y1 * y2 * c_y31.ssum * C_CLPWM /
336                          (c1->eff*c1->ssum * c2->eff*c2->ssum) *
337                          cres->eff*( cres->ssum*(double)cmax +
338                                                  C_CNSS/2.0*(cmax-1) );

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines