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

Comparing ray/src/common/spec_rgb.c (file contents):
Revision 2.32 by greg, Wed Jan 17 17:36:20 2024 UTC vs.
Revision 2.34 by greg, Wed Aug 14 20:05:23 2024 UTC

# Line 277 | Line 277 | int  e
277  
278   static double
279   spec_dot(                       /* spectrum dot-product with cumulative observer */
280 <        SCOLOR scol,
280 >        const SCOLOR scol,
281          int  ncs,
282          const float wlpt[4],
283          const unsigned short cumul[],
# Line 312 | Line 312 | spec_dot(                      /* spectrum dot-product with cumulative ob
312   void
313   scolor2cie(                     /* accurate conversion from spectrum to XYZ */
314          COLOR col,
315 <        SCOLOR scol,
315 >        const SCOLOR scol,
316          int ncs,
317          const float wlpt[4]
318   )
# Line 330 | Line 330 | scolor2cie(                    /* accurate conversion from spectrum to
330   void
331   scolor2rgb(                     /* accurate conversion from spectrum to RGB */
332          COLOR col,
333 <        SCOLOR scol,
333 >        const SCOLOR scol,
334          int ncs,
335          const float wlpt[4]
336   )
# Line 346 | Line 346 | scolor2rgb(                    /* accurate conversion from spectrum to
346   }
347  
348  
349 + void
350 + scolor_out(                     /* prepare (spectral) color for output */
351 +        COLORV *cout,
352 +        RGBPRIMS pr,
353 +        const SCOLOR cres
354 + )
355 + {
356 +        static COLORMAT xyz2myp;
357 +        static RGBPRIMP lastp = NULL;
358 +
359 +        if (!pr) {                      /* output is spectral */
360 +                copyscolor(cout, cres);
361 +        } else if (pr == stdprims) {    /* output is standard RGB */
362 +                scolor_rgb(cout, cres);
363 +        } else if (pr == xyzprims) {    /* output is XYZ */
364 +                scolor_cie(cout, cres);
365 +                scalecolor(cout, WHTEFFICACY);
366 +        } else if (NCSAMP > 3) {        /* spectral -> custom RGB */
367 +                COLOR   xyz;
368 +                if (lastp != pr)
369 +                        compxyz2rgbWBmat(xyz2myp, lastp=pr);
370 +                scolor_cie(xyz, cres);
371 +                colortrans(cout, xyz2myp, xyz);
372 +                clipgamut(cout, xyz[CIEY], CGAMUT_LOWER, cblack, cwhite);
373 +        } else {                        /* else copy unknown RGB */
374 +                copycolor(cout, cres);
375 +        }
376 + }
377 +
378 +
379   double
380   scolor2photopic(                /* compute scotopic integral for spectral color */
381 <        SCOLOR  scol,
381 >        const SCOLOR  scol,
382          int ncs,
383          const float wlpt[4]
384   )
# Line 362 | Line 392 | scolor2photopic(               /* compute scotopic integral for spe
392  
393   double
394   scolor2scotopic(                /* compute Y channel for spectral color */
395 <        SCOLOR  scol,
395 >        const SCOLOR  scol,
396          int ncs,
397          const float wlpt[4]
398   )
# Line 373 | Line 403 | scolor2scotopic(               /* compute Y channel for spectral co
403  
404   double
405   scolor2melanopic(               /* compute melanopic integral for spectral color */
406 <        SCOLOR  scol,
406 >        const SCOLOR  scol,
407          int ncs,
408          const float wlpt[4]
409   )
# Line 384 | Line 414 | scolor2melanopic(              /* compute melanopic integral for s
414  
415   double
416   scolor_photopic(                /* compute scotopic integral for spectral color */
417 <        SCOLOR  scol
417 >        const SCOLOR  scol
418   )
419   {
420          return(scolor2photopic(scol, NCSAMP, WLPART));
# Line 393 | Line 423 | scolor_photopic(               /* compute scotopic integral for spe
423  
424   double
425   scolor_scotopic(                /* compute Y channel for spectral color */
426 <        SCOLOR  scol
426 >        const SCOLOR  scol
427   )
428   {
429          return(scolor2scotopic(scol, NCSAMP, WLPART));
# Line 402 | Line 432 | scolor_scotopic(               /* compute Y channel for spectral co
432  
433   double
434   scolor_melanopic(               /* compute melanopic integral for spectral color */
435 <        SCOLOR  scol
435 >        const SCOLOR  scol
436   )
437   {
438          return(scolor2melanopic(scol, NCSAMP, WLPART));
# Line 439 | Line 469 | convertscolorcol(              /* any uniform spectrum to working
469   void
470   cie_rgb(                        /* convert CIE color to standard RGB */
471   COLOR   rgb,
472 < COLOR  xyz
472 > const COLOR  xyz
473   )
474   {
475          colortrans(rgb, xyz2rgbmat, xyz);
# Line 452 | Line 482 | clipgamut(                     /* clip to gamut cube */
482   COLOR  col,
483   double  brt,
484   int  gamut,
485 < COLOR  lower,
486 < COLOR  upper
485 > const COLOR  lower,
486 > const COLOR  upper
487   )
488   {
489          int  rflags = 0;
# Line 498 | Line 528 | COLOR  upper
528   void
529   colortrans(                     /* convert c1 by mat and put into c2 */
530   COLOR  c2,
531 < COLORMAT  mat,
532 < COLOR  c1
531 > const COLORMAT  mat,
532 > const COLOR  c1
533   )
534   {
535          COLOR   cout;
# Line 515 | Line 545 | COLOR  c1
545   void
546   multcolormat(                   /* multiply m1 by m2 and put into m3 */
547   COLORMAT  m3,                   /* m3 can be either m1 or m2 w/o harm */
548 < COLORMAT  m2,
549 < COLORMAT  m1
548 > const COLORMAT  m2,
549 > const COLORMAT  m1
550   )
551   {
552          COLORMAT  mt;
# Line 708 | Line 738 | RGBPRIMS  pr2
738   int
739   compxyzWBmat(                   /* CIE von Kries transform from wht1 to wht2 */
740   COLORMAT  mat,
741 < float  wht1[2],
742 < float  wht2[2]
741 > const float  wht1[2],
742 > const float  wht2[2]
743   )
744   {
745          COLOR   cw1, cw2;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines