-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCIE.inc
2574 lines (2340 loc) · 90.1 KB
/
CIE.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Persistence of Vision Ray Tracer Include File
COMMISSION INTERNATIONALE DE L'ECLAIRAGE
CIE XYZ Color Model for PoV-Ray, Version 1.8
This started as a simple replacement for the spectrum sample calculation
for Jaimes' lightsys but meanwhile it's a kind of multi purpose CIE color
transformation system.
-Ive 2003 email: [email protected]
-------------------------------------------------------------------------
update (version 1.71)
- corrected some pass-by-reference issue
- email address updated
-Ive 2012
-------------------------------------------------------------------------
update (version 1.8)
- added the XYZ2K() macro to calculate the correlated color temperature
from a given XYZ coordinate.
- corrected some errors in the comments.
-Ive 2016
-------------------------------------------------------------------------
Main features:
CIE observer
CIE 1931 2°observer, CIE 1964 10°observer, CIE 1978 Judd/Vos
CIE reference white
Illuminant A, B, C, D50, D55, D65, D75, E and all F-types are supported.
CIE color system and default illuminant
with 13 predifined color systems together with the illuminant and the
possibility to select also 'custom-made' systems.
CIE color system with custum illuminant
use any non-default illuminant for the predefined color system
already 20 CIE standard illuminants are defined and in addition you
can convert temperatures to whitepoints.
CIE color order systems and conversion utilities between
RGB, XYZ, xyY, Lab, Lch
Wavelength, blackbody, daylight(D illuminant), reflective-, emissive-
and line-spectrum color conversion tools
Gamut mapping with different functions (for xyz->RGB conversion)
Chromatic adaption with different functions
(used for Lab,Lch <-> xyz and reflectance spectrum -> xyz and
'reference rgb' conversion)
Grayscale feature
*/
// Standard include file beginning stuff
#ifndef (CIE_Inc_Temp)
#declare CIE_Inc_Temp = version;
#ifdef(View_POV_Include_Stack)
#debug "Including CIE.inc\n"
#end
// additional CIE.inc settings
#ifndef (CIE_Debug)
#declare CIE_Debug = false;
#end
#ifndef (CIE_MultiObserver)
#declare CIE_MultiObserver = false;
#end
#ifndef (CIE_IntegralStep)
#declare CIE_IntegralStep = 5; // step width for integral over spectra
#end
//=====================================================================
// first all the lookup tables and pre-definitions
//
/* CIE observer color matching function tables
* xyz spectral coordinates in steps of 5 nm.
* see also Fig. 13.24 in [Foley96 p.581]
* taken from http://cvision.ucsd.edu/cie.htm
* For consistence and easy access all tables are reduced to the
* range of 380 to 825 nanometers.
* The first column is the original 1931 2° observer CMF, the second
* the 1964 10° and the third is the 2° observer modified by Judd/Vos
*/
#if (CIE_MultiObserver)
#declare CMF_table = array[90][3] {
{<0.001368000000,0.000039000000,0.006450001000>,<0.000159952000,0.000017364000,0.000704776000>,<0.002689900000,0.000200000000,0.012260000000>},//380
{<0.002236000000,0.000064000000,0.010549990000>,<0.000662440000,0.000071560000,0.002927800000>,<0.005310500000,0.000395560000,0.024222000000>},//385
{<0.004243000000,0.000120000000,0.020050010000>,<0.002361600000,0.000253400000,0.010482200000>,<0.010781000000,0.000800000000,0.049250000000>},//390
{<0.007650000000,0.000217000000,0.036210000000>,<0.007242300000,0.000768500000,0.032344000000>,<0.020792000000,0.001545700000,0.095135000000>},//395
{<0.014310000000,0.000396000000,0.067850010000>,<0.019109700000,0.002004400000,0.086010900000>,<0.037981000000,0.002800000000,0.174090000000>},//400
{<0.023190000000,0.000640000000,0.110200000000>,<0.043400000000,0.004509000000,0.197120000000>,<0.063157000000,0.004656200000,0.290130000000>},//405
{<0.043510000000,0.001210000000,0.207400000000>,<0.084736000000,0.008756000000,0.389366000000>,<0.099941000000,0.007400000000,0.460530000000>},//410
{<0.077630000000,0.002180000000,0.371300000000>,<0.140638000000,0.014456000000,0.656760000000>,<0.158240000000,0.011779000000,0.731660000000>},//415
{<0.134380000000,0.004000000000,0.645600000000>,<0.204492000000,0.021391000000,0.972542000000>,<0.229480000000,0.017500000000,1.065800000000>},//420
{<0.214770000000,0.007300000000,1.039050100000>,<0.264737000000,0.029497000000,1.282500000000>,<0.281080000000,0.022678000000,1.314600000000>},//425
{<0.283900000000,0.011600000000,1.385600000000>,<0.314679000000,0.038676000000,1.553480000000>,<0.310950000000,0.027300000000,1.467200000000>},//430
{<0.328500000000,0.016840000000,1.622960000000>,<0.357719000000,0.049602000000,1.798500000000>,<0.330720000000,0.032584000000,1.579600000000>},//435
{<0.348280000000,0.023000000000,1.747060000000>,<0.383734000000,0.062077000000,1.967280000000>,<0.333360000000,0.037900000000,1.616600000000>},//440
{<0.348060000000,0.029800000000,1.782600000000>,<0.386726000000,0.074704000000,2.027300000000>,<0.316720000000,0.042391000000,1.568200000000>},//445
{<0.336200000000,0.038000000000,1.772110000000>,<0.370702000000,0.089456000000,1.994800000000>,<0.288820000000,0.046800000000,1.471700000000>},//450
{<0.318700000000,0.048000000000,1.744100000000>,<0.342957000000,0.106256000000,1.900700000000>,<0.259690000000,0.052122000000,1.374000000000>},//455
{<0.290800000000,0.060000000000,1.669200000000>,<0.302273000000,0.128201000000,1.745370000000>,<0.232760000000,0.060000000000,1.291700000000>},//460
{<0.251100000000,0.073900000000,1.528100000000>,<0.254085000000,0.152761000000,1.554900000000>,<0.209990000000,0.072942000000,1.235600000000>},//465
{<0.195360000000,0.090980000000,1.287640000000>,<0.195618000000,0.185190000000,1.317560000000>,<0.174760000000,0.090980000000,1.113800000000>},//470
{<0.142100000000,0.112600000000,1.041900000000>,<0.132349000000,0.219940000000,1.030200000000>,<0.132870000000,0.112840000000,0.942200000000>},//475
{<0.095640000000,0.139020000000,0.812950100000>,<0.080507000000,0.253589000000,0.772125000000>,<0.091944000000,0.139020000000,0.755960000000>},//480
{<0.057950010000,0.169300000000,0.616200000000>,<0.041072000000,0.297665000000,0.570600000000>,<0.056985000000,0.169870000000,0.586400000000>},//485
{<0.032010000000,0.208020000000,0.465180000000>,<0.016172000000,0.339133000000,0.415254000000>,<0.031731000000,0.208020000000,0.446690000000>},//490
{<0.014700000000,0.258600000000,0.353300000000>,<0.005132000000,0.395379000000,0.302356000000>,<0.014613000000,0.258080000000,0.341160000000>},//495
{<0.004900000000,0.323000000000,0.272000000000>,<0.003816000000,0.460777000000,0.218502000000>,<0.004849100000,0.323000000000,0.264370000000>},//500
{<0.002400000000,0.407300000000,0.212300000000>,<0.015444000000,0.531360000000,0.159249000000>,<0.002321500000,0.405400000000,0.205940000000>},//505
{<0.009300000000,0.503000000000,0.158200000000>,<0.037465000000,0.606741000000,0.112044000000>,<0.009289900000,0.503000000000,0.154450000000>},//510
{<0.029100000000,0.608200000000,0.111700000000>,<0.071358000000,0.685660000000,0.082248000000>,<0.029278000000,0.608110000000,0.109180000000>},//515
{<0.063270000000,0.710000000000,0.078249990000>,<0.117749000000,0.761757000000,0.060709000000>,<0.063791000000,0.710000000000,0.076585000000>},//520
{<0.109600000000,0.793200000000,0.057250010000>,<0.172953000000,0.823330000000,0.043050000000>,<0.110810000000,0.795100000000,0.056227000000>},//525
{<0.165500000000,0.862000000000,0.042160000000>,<0.236491000000,0.875211000000,0.030451000000>,<0.166920000000,0.862000000000,0.041366000000>},//530
{<0.225749900000,0.914850100000,0.029840000000>,<0.304213000000,0.923810000000,0.020584000000>,<0.227680000000,0.915050000000,0.029353000000>},//535
{<0.290400000000,0.954000000000,0.020300000000>,<0.376772000000,0.961988000000,0.013676000000>,<0.292690000000,0.954000000000,0.020042000000>},//540
{<0.359700000000,0.980300000000,0.013400000000>,<0.451584000000,0.982200000000,0.007918000000>,<0.362250000000,0.980040000000,0.013312000000>},//545
{<0.433449900000,0.994950100000,0.008749999000>,<0.529826000000,0.991761000000,0.003988000000>,<0.436350000000,0.994950000000,0.008782300000>},//550
{<0.512050100000,1.000000000000,0.005749999000>,<0.616053000000,0.999110000000,0.001091000000>,<0.515130000000,1.000100000000,0.005857300000>},//555
{<0.594500000000,0.995000000000,0.003900000000>,<0.705224000000,0.997340000000,0.000000000000>,<0.597480000000,0.995000000000,0.004049300000>},//560
{<0.678400000000,0.978600000000,0.002749999000>,<0.793832000000,0.982380000000,0.000000000000>,<0.681210000000,0.978750000000,0.002921700000>},//565
{<0.762100000000,0.952000000000,0.002100000000>,<0.878655000000,0.955552000000,0.000000000000>,<0.764250000000,0.952000000000,0.002277100000>},//570
{<0.842500000000,0.915400000000,0.001800000000>,<0.951162000000,0.915175000000,0.000000000000>,<0.843940000000,0.915580000000,0.001970600000>},//575
{<0.916300000000,0.870000000000,0.001650001000>,<1.014160000000,0.868934000000,0.000000000000>,<0.916350000000,0.870000000000,0.001806600000>},//580
{<0.978600000000,0.816300000000,0.001400000000>,<1.074300000000,0.825623000000,0.000000000000>,<0.977030000000,0.816230000000,0.001544900000>},//585
{<1.026300000000,0.757000000000,0.001100000000>,<1.118520000000,0.777405000000,0.000000000000>,<1.023000000000,0.757000000000,0.001234800000>},//590
{<1.056700000000,0.694900000000,0.001000000000>,<1.134300000000,0.720353000000,0.000000000000>,<1.051300000000,0.694830000000,0.001117700000>},//595
{<1.062200000000,0.631000000000,0.000800000000>,<1.123990000000,0.658341000000,0.000000000000>,<1.055000000000,0.631000000000,0.000905640000>},//600
{<1.045600000000,0.566800000000,0.000600000000>,<1.089100000000,0.593878000000,0.000000000000>,<1.036200000000,0.566540000000,0.000694670000>},//605
{<1.002600000000,0.503000000000,0.000340000000>,<1.030480000000,0.527963000000,0.000000000000>,<0.992390000000,0.503000000000,0.000428850000>},//610
{<0.938400000000,0.441200000000,0.000240000000>,<0.950740000000,0.461834000000,0.000000000000>,<0.928610000000,0.441720000000,0.000318170000>},//615
{<0.854449900000,0.381000000000,0.000190000000>,<0.856297000000,0.398057000000,0.000000000000>,<0.843460000000,0.381000000000,0.000255980000>},//620
{<0.751400000000,0.321000000000,0.000100000000>,<0.754930000000,0.339554000000,0.000000000000>,<0.739830000000,0.320520000000,0.000156790000>},//625
{<0.642400000000,0.265000000000,0.000049999990>,<0.647467000000,0.283493000000,0.000000000000>,<0.632890000000,0.265000000000,0.000097694000>},//630
{<0.541900000000,0.217000000000,0.000030000000>,<0.535110000000,0.228254000000,0.000000000000>,<0.533510000000,0.217020000000,0.000068944000>},//635
{<0.447900000000,0.175000000000,0.000020000000>,<0.431567000000,0.179828000000,0.000000000000>,<0.440620000000,0.175000000000,0.000051165000>},//640
{<0.360800000000,0.138200000000,0.000010000000>,<0.343690000000,0.140211000000,0.000000000000>,<0.354530000000,0.138120000000,0.000036016000>},//645
{<0.283500000000,0.107000000000,0.000000000000>,<0.268329000000,0.107633000000,0.000000000000>,<0.278620000000,0.107000000000,0.000024238000>},//650
{<0.218700000000,0.081600000000,0.000000000000>,<0.204300000000,0.081187000000,0.000000000000>,<0.214850000000,0.081652000000,0.000016915000>},//655
{<0.164900000000,0.061000000000,0.000000000000>,<0.152568000000,0.060281000000,0.000000000000>,<0.161610000000,0.061000000000,0.000011906000>},//660
{<0.121200000000,0.044580000000,0.000000000000>,<0.112210000000,0.044096000000,0.000000000000>,<0.118200000000,0.044327000000,0.000008148900>},//665
{<0.087400000000,0.032000000000,0.000000000000>,<0.081260600000,0.031800400000,0.000000000000>,<0.085753000000,0.032000000000,0.000005600600>},//670
{<0.063600000000,0.023200000000,0.000000000000>,<0.057930000000,0.022601700000,0.000000000000>,<0.063077000000,0.023454000000,0.000003954400>},//675
{<0.046770000000,0.017000000000,0.000000000000>,<0.040850800000,0.015905100000,0.000000000000>,<0.045834000000,0.017000000000,0.000002791200>},//680
{<0.032900000000,0.011920000000,0.000000000000>,<0.028623000000,0.011130300000,0.000000000000>,<0.032057000000,0.011872000000,0.000001917600>},//685
{<0.022700000000,0.008210000000,0.000000000000>,<0.019941300000,0.007748800000,0.000000000000>,<0.022187000000,0.008210000000,0.000001313500>},//690
{<0.015840000000,0.005723000000,0.000000000000>,<0.013842000000,0.005375100000,0.000000000000>,<0.015612000000,0.005772300000,0.000000915190>},//695
{<0.011359160000,0.004102000000,0.000000000000>,<0.009576880000,0.003717740000,0.000000000000>,<0.011098000000,0.004102000000,0.000000647670>},//700
{<0.008110916000,0.002929000000,0.000000000000>,<0.006605200000,0.002564560000,0.000000000000>,<0.007923300000,0.002929100000,0.000000463520>},//705
{<0.005790346000,0.002091000000,0.000000000000>,<0.004552630000,0.001768470000,0.000000000000>,<0.005653100000,0.002091000000,0.000000333040>},//710
{<0.004106457000,0.001484000000,0.000000000000>,<0.003144700000,0.001222390000,0.000000000000>,<0.004003900000,0.001482200000,0.000000238230>},//715
{<0.002899327000,0.001047000000,0.000000000000>,<0.002174960000,0.000846190000,0.000000000000>,<0.002825300000,0.001047000000,0.000000170260>},//720
{<0.002049190000,0.000740000000,0.000000000000>,<0.001505700000,0.000586440000,0.000000000000>,<0.001994700000,0.000740150000,0.000000122070>},//725
{<0.001439971000,0.000520000000,0.000000000000>,<0.001044760000,0.000407410000,0.000000000000>,<0.001399400000,0.000520000000,0.000000087107>},//730
{<0.000999949300,0.000361100000,0.000000000000>,<0.000727450000,0.000284041000,0.000000000000>,<0.000969800000,0.000360930000,0.000000061455>},//735
{<0.000690078600,0.000249200000,0.000000000000>,<0.000508258000,0.000198730000,0.000000000000>,<0.000668470000,0.000249200000,0.000000043162>},//740
{<0.000476021300,0.000171900000,0.000000000000>,<0.000356380000,0.000139550000,0.000000000000>,<0.000461410000,0.000172310000,0.000000030379>},//745
{<0.000332301100,0.000120000000,0.000000000000>,<0.000250969000,0.000098428000,0.000000000000>,<0.000320730000,0.000120000000,0.000000021554>},//750
{<0.000234826100,0.000084800000,0.000000000000>,<0.000177730000,0.000069819000,0.000000000000>,<0.000225730000,0.000084620000,0.000000015493>},//755
{<0.000166150500,0.000060000000,0.000000000000>,<0.000126390000,0.000049737000,0.000000000000>,<0.000159730000,0.000060000000,0.000000011204>},//760
{<0.000117413000,0.000042400000,0.000000000000>,<0.000090151000,0.000035540500,0.000000000000>,<0.000112750000,0.000042446000,0.000000008087>},//765
{<0.000083075270,0.000030000000,0.000000000000>,<0.000064525800,0.000025486000,0.000000000000>,<0.000079513000,0.000030000000,0.000000005834>},//770
{<0.000058706520,0.000021200000,0.000000000000>,<0.000046339000,0.000018338400,0.000000000000>,<0.000056087000,0.000021210000,0.000000004211>},//775
{<0.000041509940,0.000014990000,0.000000000000>,<0.000033411700,0.000013249000,0.000000000000>,<0.000039541000,0.000014989000,0.000000003038>},//780
{<0.000029353260,0.000010600000,0.000000000000>,<0.000024209000,0.000009619600,0.000000000000>,<0.000027852000,0.000010584000,0.000000002191>},//785
{<0.000020673830,0.000007465700,0.000000000000>,<0.000017611500,0.000007012800,0.000000000000>,<0.000019597000,0.000007465600,0.000000001578>},//790
{<0.000014559770,0.000005257800,0.000000000000>,<0.000012855000,0.000005129800,0.000000000000>,<0.000013770000,0.000005259200,0.000000001135>},//795
{<0.000010253980,0.000003702900,0.000000000000>,<0.000009413630,0.000003764730,0.000000000000>,<0.000009670000,0.000003702800,0.000000000816>},//800
{<0.000007221456,0.000002607800,0.000000000000>,<0.000006913000,0.000002770810,0.000000000000>,<0.000006791800,0.000002607600,0.000000000586>},//805
{<0.000005085868,0.000001836600,0.000000000000>,<0.000005093470,0.000002046130,0.000000000000>,<0.000004770600,0.000001836500,0.000000000421>},//810
{<0.000003581652,0.000001293400,0.000000000000>,<0.000003767100,0.000001516770,0.000000000000>,<0.000003355000,0.000001295000,0.000000000303>},//815
{<0.000002522525,0.000000910930,0.000000000000>,<0.000002795310,0.000001128090,0.000000000000>,<0.000002353400,0.000000910920,0.000000000218>},//820
{<0.000001776509,0.000000641530,0.000000000000>,<0.000002082000,0.000000842160,0.000000000000>,<0.000001637700,0.000000635640,0.000000000155>} //825
}
#end // if MultiObserver
/* CIE observer color matching function
* initialized for the 1931 2° standard observer.
* This spline is automatical reinitialized if
* any other CMF is selected.
* See the macro CIE_Observer for more details.
*/
#declare CMF_xyz = spline { cubic_spline
375, <0,0,0>
380, <0.001368000000, 0.000039000000, 0.006450001000>
385, <0.002236000000, 0.000064000000, 0.010549990000>
390, <0.004243000000, 0.000120000000, 0.020050010000>
395, <0.007650000000, 0.000217000000, 0.036210000000>
400, <0.014310000000, 0.000396000000, 0.067850010000>
405, <0.023190000000, 0.000640000000, 0.110200000000>
410, <0.043510000000, 0.001210000000, 0.207400000000>
415, <0.077630000000, 0.002180000000, 0.371300000000>
420, <0.134380000000, 0.004000000000, 0.645600000000>
425, <0.214770000000, 0.007300000000, 1.039050100000>
430, <0.283900000000, 0.011600000000, 1.385600000000>
435, <0.328500000000, 0.016840000000, 1.622960000000>
440, <0.348280000000, 0.023000000000, 1.747060000000>
445, <0.348060000000, 0.029800000000, 1.782600000000>
450, <0.336200000000, 0.038000000000, 1.772110000000>
455, <0.318700000000, 0.048000000000, 1.744100000000>
460, <0.290800000000, 0.060000000000, 1.669200000000>
465, <0.251100000000, 0.073900000000, 1.528100000000>
470, <0.195360000000, 0.090980000000, 1.287640000000>
475, <0.142100000000, 0.112600000000, 1.041900000000>
480, <0.095640000000, 0.139020000000, 0.812950100000>
485, <0.057950010000, 0.169300000000, 0.616200000000>
490, <0.032010000000, 0.208020000000, 0.465180000000>
495, <0.014700000000, 0.258600000000, 0.353300000000>
500, <0.004900000000, 0.323000000000, 0.272000000000>
505, <0.002400000000, 0.407300000000, 0.212300000000>
510, <0.009300000000, 0.503000000000, 0.158200000000>
515, <0.029100000000, 0.608200000000, 0.111700000000>
520, <0.063270000000, 0.710000000000, 0.078249990000>
525, <0.109600000000, 0.793200000000, 0.057250010000>
530, <0.165500000000, 0.862000000000, 0.042160000000>
535, <0.225749900000, 0.914850100000, 0.029840000000>
540, <0.290400000000, 0.954000000000, 0.020300000000>
545, <0.359700000000, 0.980300000000, 0.013400000000>
550, <0.433449900000, 0.994950100000, 0.008749999000>
555, <0.512050100000, 1.000000000000, 0.005749999000>
560, <0.594500000000, 0.995000000000, 0.003900000000>
565, <0.678400000000, 0.978600000000, 0.002749999000>
570, <0.762100000000, 0.952000000000, 0.002100000000>
575, <0.842500000000, 0.915400000000, 0.001800000000>
580, <0.916300000000, 0.870000000000, 0.001650001000>
585, <0.978600000000, 0.816300000000, 0.001400000000>
590, <1.026300000000, 0.757000000000, 0.001100000000>
595, <1.056700000000, 0.694900000000, 0.001000000000>
600, <1.062200000000, 0.631000000000, 0.000800000000>
605, <1.045600000000, 0.566800000000, 0.000600000000>
610, <1.002600000000, 0.503000000000, 0.000340000000>
615, <0.938400000000, 0.441200000000, 0.000240000000>
620, <0.854449900000, 0.381000000000, 0.000190000000>
625, <0.751400000000, 0.321000000000, 0.000100000000>
630, <0.642400000000, 0.265000000000, 0.000049999990>
635, <0.541900000000, 0.217000000000, 0.000030000000>
640, <0.447900000000, 0.175000000000, 0.000020000000>
645, <0.360800000000, 0.138200000000, 0.000010000000>
650, <0.283500000000, 0.107000000000, 0.000000000000>
655, <0.218700000000, 0.081600000000, 0.000000000000>
660, <0.164900000000, 0.061000000000, 0.000000000000>
665, <0.121200000000, 0.044580000000, 0.000000000000>
670, <0.087400000000, 0.032000000000, 0.000000000000>
675, <0.063600000000, 0.023200000000, 0.000000000000>
680, <0.046770000000, 0.017000000000, 0.000000000000>
685, <0.032900000000, 0.011920000000, 0.000000000000>
690, <0.022700000000, 0.008210000000, 0.000000000000>
695, <0.015840000000, 0.005723000000, 0.000000000000>
700, <0.011359160000, 0.004102000000, 0.000000000000>
705, <0.008110916000, 0.002929000000, 0.000000000000>
710, <0.005790346000, 0.002091000000, 0.000000000000>
715, <0.004106457000, 0.001484000000, 0.000000000000>
720, <0.002899327000, 0.001047000000, 0.000000000000>
725, <0.002049190000, 0.000740000000, 0.000000000000>
730, <0.001439971000, 0.000520000000, 0.000000000000>
735, <0.000999949300, 0.000361100000, 0.000000000000>
740, <0.000690078600, 0.000249200000, 0.000000000000>
745, <0.000476021300, 0.000171900000, 0.000000000000>
750, <0.000332301100, 0.000120000000, 0.000000000000>
755, <0.000234826100, 0.000084800000, 0.000000000000>
760, <0.000166150500, 0.000060000000, 0.000000000000>
765, <0.000117413000, 0.000042400000, 0.000000000000>
770, <0.000083075270, 0.000030000000, 0.000000000000>
775, <0.000058706520, 0.000021200000, 0.000000000000>
780, <0.000041509940, 0.000014990000, 0.000000000000>
785, <0.000029353260, 0.000010600000, 0.000000000000>
790, <0.000020673830, 0.000007465700, 0.000000000000>
795, <0.000014559770, 0.000005257800, 0.000000000000>
800, <0.000010253980, 0.000003702900, 0.000000000000>
805, <0.000007221456, 0.000002607800, 0.000000000000>
810, <0.000005085868, 0.000001836600, 0.000000000000>
815, <0.000003581652, 0.000001293400, 0.000000000000>
820, <0.000002522525, 0.000000910930, 0.000000000000>
825, <0.000001776509, 0.000000641530, 0.000000000000>
830, <0,0,0>
}
/* Lookup table containing S0, S1, S2 to calculate the spectra for the
* CIE D standard illuminants (D50, D55, D65, D75) and also custum D
* illuminants for color temperatures between 4000K and 25000K.
* See the macro Daylight for the formula and more details.
*/
#declare DS012 = array[90][3] {
{ 63.40, 38.50, 3.00},// 380
{ 64.60, 36.75, 2.10},// 385
{ 65.80, 35.00, 1.20},// 390
{ 80.30, 39.20, 0.05},// 395
{ 94.80, 43.40, -1.10},// 400
{ 99.80, 44.85, -0.80},// 405
{104.80, 46.30, -0.50},// 410
{105.35, 45.10, -0.60},// 415
{105.90, 43.90, -0.70},// 420
{101.35, 40.50, -0.95},// 425
{ 96.80, 37.10, -1.20},// 430
{105.35, 36.90, -1.90},// 435
{113.90, 36.70, -2.60},// 440
{119.75, 36.30, -2.75},// 445
{125.60, 35.90, -2.90},// 450
{125.55, 34.25, -2.85},// 455
{125.50, 32.60, -2.80},// 460
{123.40, 30.25, -2.70},// 465
{121.30, 27.90, -2.60},// 470
{121.30, 26.10, -2.60},// 475
{121.30, 24.30, -2.60},// 480
{117.40, 22.20, -2.20},// 485
{113.50, 20.10, -1.80},// 490
{113.30, 18.15, -1.65},// 495
{113.10, 16.20, -1.50},// 500
{111.95, 14.70, -1.40},// 505
{110.80, 13.20, -1.30},// 510
{108.65, 10.90, -1.25},// 515
{106.50, 8.60, -1.20},// 520
{107.65, 7.35, -1.10},// 525
{108.80, 6.10, -1.00},// 530
{107.05, 5.15, -0.75},// 535
{105.30, 4.20, -0.50},// 540
{104.85, 3.05, -0.40},// 545
{104.40, 1.90, -0.30},// 550
{102.20, 0.95, -0.15},// 555
{100.00, 0.00, 0.00},// 560
{ 98.00, -0.80, 0.10},// 565
{ 96.00, -1.60, 0.20},// 570
{ 95.55, -2.55, 0.35},// 575
{ 95.10, -3.50, 0.50},// 580
{ 92.10, -3.50, 1.30},// 585
{ 89.10, -3.50, 2.10},// 590
{ 89.80, -4.65, 2.65},// 595
{ 90.50, -5.80, 3.20},// 600
{ 90.40, -6.50, 3.65},// 605
{ 90.30, -7.20, 4.10},// 610
{ 89.35, -7.90, 4.40},// 615
{ 88.40, -8.60, 4.70},// 620
{ 86.20, -9.05, 4.90},// 625
{ 84.00, -9.50, 5.10},// 630
{ 84.55,-10.20, 5.90},// 635
{ 85.10,-10.90, 6.70},// 640
{ 83.50,-10.80, 7.00},// 645
{ 81.90,-10.70, 7.30},// 650
{ 82.25,-11.35, 7.95},// 655
{ 82.60,-12.00, 8.60},// 660
{ 83.75,-13.00, 9.20},// 665
{ 84.90,-14.00, 9.80},// 670
{ 83.10,-13.80, 10.00},// 675
{ 81.30,-13.60, 10.20},// 680
{ 76.60,-12.80, 9.25},// 685
{ 71.90,-12.00, 8.30},// 690
{ 73.10,-12.65, 8.95},// 695
{ 74.30,-13.30, 9.60},// 700
{ 75.35,-13.10, 9.05},// 705
{ 76.40,-12.90, 8.50},// 710
{ 69.85,-11.75, 7.75},// 715
{ 63.30,-10.60, 7.00},// 720
{ 67.50,-11.10, 7.30},// 725
{ 71.70,-11.60, 7.60},// 730
{ 74.35,-11.90, 7.80},// 735
{ 77.00,-12.20, 8.00},// 740
{ 71.10,-11.20, 7.35},// 745
{ 65.20,-10.20, 6.70},// 750
{ 56.45, -9.00, 5.95},// 755
{ 47.70, -7.80, 5.20},// 760
{ 58.15, -9.50, 6.30},// 765
{ 68.60,-11.20, 7.40},// 770
{ 66.80,-10.80, 7.10},// 775
{ 65.00,-10.40, 6.80},// 780
{ 65.50,-10.50, 6.90},// 785
{ 66.00,-10.60, 7.00},// 790
{ 63.50,-10.15, 6.70},// 795
{ 61.00, -9.70, 6.40},// 800
{ 57.15, -9.00, 5.95},// 805
{ 53.30, -8.30, 5.50},// 810
{ 56.10, -8.80, 5.80},// 815
{ 58.90, -9.30, 6.10},// 820
{ 60.40, -9.55, 6.30},// 825
}
/* RefWhiteSP is initialized to D50 and recalculated if
* any other D illuminant or the A illuminant is requested.
* In every other case it is set equal to the the CIE standard
* illuminants as stored in the file "espd_cie_standard.inc".
*/
#declare RefWhiteSP = spline{ linear_spline
380, 0.244992
385, 0.271905
390, 0.298818
395, 0.396023
400, 0.493228
405, 0.529255
410, 0.565283
415, 0.582884
420, 0.600485
425, 0.589394
430, 0.578302
435, 0.663340
440, 0.748379
445, 0.810490
450, 0.872601
455, 0.889420
460, 0.906239
465, 0.910011
470, 0.913782
475, 0.932478
480, 0.951174
485, 0.935437
490, 0.919700
495, 0.938498
500, 0.957296
505, 0.961738
510, 0.966181
515, 0.968752
520, 0.971323
525, 0.996169
530, 1.021015
535, 1.014289
540, 1.007563
545, 1.015370
550, 1.023177
555, 1.011589
560, 1.000000
565, 0.988672
570, 0.977344
575, 0.983255
580, 0.989167
585, 0.962068
590, 0.934969
595, 0.955909
600, 0.976848
605, 0.984751
610, 0.992653
615, 0.991512
620, 0.990371
625, 0.973770
630, 0.957169
635, 0.972841
640, 0.988513
645, 0.972562
650, 0.956612
655, 0.969220
660, 0.981829
665, 1.005892
670, 1.029954
675, 1.010602
680, 0.991250
685, 0.932496
690, 0.873741
695, 0.894850
700, 0.915958
705, 0.922386
710, 0.928814
715, 0.848650
720, 0.768485
725, 0.816766
730, 0.865048
735, 0.895389
740, 0.925730
745, 0.853986
750, 0.782242
755, 0.679558
760, 0.576875
}
/* xy reference values for perfect diffuse reflection used as
* predefined whitepoints for the 2° and the 10° observer.
* Whitepoint format:
* (x-white, y-white) for the 1931 2° observers
* (x-white, y-white) for the 1964 10° observer
* (x-white, y-white) for the Judd/Vos 2° observer
* You can also use kelvin temperatures to create custom-whitepoints
* by using the Blackbody2Whitepoint or Daylight2Whitepoint macros.
*
* Due to a revision of the Boltzmann constant we have the correlated
* Kelvin temperature for the daylight illuminants: (1.4388/1.4380)*D(K)
* D50 - 5002.78 K
* D55 - 5503.06 K
* D65 - 6503.62 K
* D75 - 7504.17 K
*/
#if (CIE_MultiObserver)
#declare Illuminant_A = array[3][2] { // blackbody 2856 K
{0.44753, 0.40744}, // 1931 2°observer
{0.45113, 0.40593}, // 1964 10°observer
{0.44927, 0.41273} // 1978 2°observer
}
#declare Illuminant_B = array[3][2] { // ca. blackbody 4871 K
{0.34849, 0.35173}, // 1931 2°observer
{0.34990, 0.35279}, // 1964 10°observer
{0.35189, 0.35853} // 1978 2°observer
}
#declare Illuminant_C = array[3][2] { // ca. blackbody 6774 K
{0.31006, 0.31616}, // 1931 2°observer
{0.31038, 0.31905}, // 1964 10°observer
{0.31373, 0.32291} // 1978 2°observer
}
#declare Illuminant_D50 = array[3][2] { // daylight 5002.78 K
{0.34566, 0.35850}, // 1931 2°observer
{0.34771, 0.35951}, // 1964 10°observer
{0.34919, 0.36560} // 1978 2°observer
}
#declare Illuminant_D55 = array[3][2] { // daylight 5503.06 K
{0.33242, 0.34744}, // 1931 2°observer
{0.33411, 0.34876}, // 1964 10°observer
{0.33587, 0.35417} // 1978 2°observer
}
#declare Illuminant_D65 = array[3][2] { // daylight 6503.62 K
{0.31271, 0.32902}, // 1931 2°observer
{0.31379, 0.33096}, // 1964 10°observer
{0.31598, 0.33502} // 1978 2°observer
}
#declare Illuminant_D75 = array[3][2] { // daylight 7504.17 K
{0.29903, 0.31487}, // 1931 2°observer
{0.29967, 0.31739}, // 1964 10°observer
{0.30216, 0.32027} // 1978 2°observer
}
#declare Illuminant_E = array[3][2] { // equal energy 5469 K
{1/3, 1/3}, // 1931 2°observer
{1/3, 1/3} // 1964 10°observer
{1/3, 1/3} // 1978 2°observer
}
#declare Illuminant_F1 = array[3][2] { // fluorescent 6430 K
{0.31306, 0.33711}, // 2°observer
{0.31810, 0.33549}, // 10°observer
{0.31690, 0.34431} // 2°observer
}
#declare Illuminant_F2 = array[3][2] { // fluorescent 4230 K
{0.37207, 0.37512}, // 2°observer
{0.37927, 0.36723}, // 10°observer
{0.37463, 0.38025} // 2°observer
}
#declare Illuminant_F3 = array[3][2] { // fluorescent 3450 K
{0.40909, 0.39412}, // 2°observer
{0.41764, 0.38312}, // 10°observer
{0.41055, 0.39782} // 2°observer
}
#declare Illuminant_F4 = array[3][2] { // fluorescent 2940 K
{0.43987, 0.40314}, // 2°observer
{0.44895, 0.39064}, // 10°observer
{0.44035, 0.40579} // 2°observer
}
#declare Illuminant_F5 = array[3][2] { // fluorescent 6350 K
{0.31376, 0.34516}, // 2°observer
{0.31974, 0.34236}, // 10°observer
{0.31749, 0.35215} // 2°observer
}
#declare Illuminant_F6 = array[3][2] { // fluorescent 4150 K
{0.37788, 0.38819}, // 2°observer
{0.38662, 0.37837}, // 10°observer
{0.38016, 0.39285} // 2°observer
}
#declare Illuminant_F7 = array[3][2] { // broad band fluorescent 6500 K
{0.31285, 0.32917}, // 2°observer
{0.31564, 0.32951}, // 10°observer
{0.31646, 0.33629} // 2°observer
}
#declare Illuminant_F8 = array[3][2] { // broad band fluorescent 5000 K
{0.34581, 0.35862}, // 2°observer
{0.34896, 0.35931}, // 10°observer
{0.34975, 0.36697} // 2°observer
}
#declare Illuminant_F9 = array[3][2] { // broad band fluorescent 4150 K
{0.37410, 0.37267}, // 2°observer
{0.37826, 0.37037}, // 10°observer
{0.37738, 0.37978} // 2°observer
}
#declare Illuminant_F10 = array[3][2] { // narrow band fluorescent 5000 K
{0.34579, 0.35876}, // 2°observer
{0.35061, 0.35430}, // 10°observer
{0.35014, 0.36779} // 2°observer
}
#declare Illuminant_F11 = array[3][2] { // narrow band fluorescent 4000 K
{0.38054, 0.37692}, // 2°observer
{0.38543, 0.37109}, // 10°observer
{0.38363, 0.38392} // 2°observer
}
#declare Illuminant_F12 = array[3][2] { // narrow band fluorescent 3000 K
{0.43702, 0.40421}, // 2°observer
{0.44265, 0.39706}, // 10°observer
{0.43752, 0.40780} // 2°observer
}
#else
#declare Illuminant_A = array[2] {0.44753,0.40744} // blackbody 2856 K
#declare Illuminant_B = array[2] {0.34849,0.35173} // ca. blackbody 4871 K
#declare Illuminant_C = array[2] {0.31006,0.31616} // ca. blackbody 6774 K
#declare Illuminant_D50 = array[2] {0.34566,0.35850} // daylight 5002.78 K
#declare Illuminant_D55 = array[2] {0.33242,0.34744} // daylight 5503.06 K
#declare Illuminant_D65 = array[2] {0.31271,0.32902} // daylight 6503.62 K
#declare Illuminant_D75 = array[2] {0.29903,0.31487} // daylight 7504.17 K
#declare Illuminant_E = array[2] {1/3, 1/3} // equal energy 5469 K
#declare Illuminant_F1 = array[2] {0.31306,0.33711} // fluorescent 6430 K
#declare Illuminant_F2 = array[2] {0.37207,0.37512} // fluorescent 4230 K
#declare Illuminant_F3 = array[2] {0.40909,0.39412} // fluorescent 3450 K
#declare Illuminant_F4 = array[2] {0.43987,0.40314} // fluorescent 2940 K
#declare Illuminant_F5 = array[2] {0.31376,0.34516} // fluorescent 6350 K
#declare Illuminant_F6 = array[2] {0.37788,0.38819} // fluorescent 4150 K
#declare Illuminant_F7 = array[2] {0.31285,0.32917} // broad band fluorescent 6500 K
#declare Illuminant_F8 = array[2] {0.34581,0.35862} // broad band fluorescent 5000 K
#declare Illuminant_F9 = array[2] {0.37410,0.37267} // broad band fluorescent 4150 K
#declare Illuminant_F10 = array[2] {0.34579,0.35876} // narrow band fluorescent 5000 K
#declare Illuminant_F11 = array[2] {0.38054,0.37692} // narrow band fluorescent 4000 K
#declare Illuminant_F12 = array[2] {0.43702,0.40421} // narrow band fluorescent 3000 K
#end
/* Color System xy coordinates and whitepoints
* sRGB: CCIR Recommendation 709 (used by HP, Microsoft)
* CIE: CIE 'ideal' gamut where the corners are on the contour of the horseshoe
* ITU: CCIR Report 476-1 (YUV color order, Pal Secam, european tv)
* NTSC: CCIR Recommendation 601-1 (YIQ color order, american tv)
* SMPTE: CIE D65
* Adobe: Adobe (Photoshop ICM)
* Match: Adobe ColorMatch (Photoshop ICM)
* Apple: Apple Monitor (Photoshop ICM)
* Beta: RGB working space created by Bruce Lindbloom
http://www.brucelindbloom.com/BetaRGB.html
* Dell phosphors: Dell data sheet
* Short-persistence phosphors: [Foley96, p.583]
* Long-persistence phosphors: [Foley96, p.583]
* HOT: Hydrogen, Oxygen, Thermal color space uses primaries found in deep space
* see http://www.nightscapes.net/techniques/HOTcolors/HOTColorSpace.html
*
* Color System format:
* (x-red, y-red),
* (x-green, y-green),
* (x-blue, y-blue),
* (x-white, y-white), whitepoint for 1931 2°observer
* (x-white, y-white), whitepoint for 1964 10°observer
* (x-white, y-white) whitepoint for 1978 2°observer (Judd/Vos)
*/
#if (CIE_MultiObserver)
#declare sRGB_ColSys = array[6][2] { // <- initialized as default
{0.640, 0.330}, // red
{0.300, 0.600}, // green
{0.150, 0.060}, // blue
{0.31271,0.32902},// Illuminant D65 1931 observer
{0.31379,0.33096},// Illuminant D65 1964
{0.31598,0.33502} // Illuminant D65 1978
}
#declare CIE_ColSys = array[6][2] {
{0.7347, 0.2653}, // red
{0.2738, 0.7174}, // green
{0.1666, 0.0088}, // blue
{1/3, 1/3}, // Illuminant E 1931 observer
{1/3, 1/3}, // Illuminant E 1964
{1/3, 1/3} // Illuminant E 1978
}
#declare ITU_ColSys = array[6][2] {
{0.640, 0.330}, // red
{0.290, 0.600}, // green
{0.150, 0.060}, // blue
{0.31271,0.32902},// Illuminant D65 1931 observer
{0.31379,0.33096},// Illuminant D65 1964
{0.31598,0.33502} // Illuminant D65 1978
}
#declare NTSC_ColSys = array[6][2] {
{0.670, 0.330}, // red
{0.210, 0.710}, // green
{0.140, 0.080}, // blue
{0.31006,0.31616},// Illuminant C 1931 observer
{0.31038,0.31905},// Illuminant C 1964
{0.31373,0.32291} // Illuminant C 1978
}
#declare SMPTE_ColSys = array[6][2] {
{0.630, 0.340}, // red
{0.310, 0.595}, // green
{0.155, 0.070}, // blue
{0.31271,0.32902},// Illuminant D65 1931 observer
{0.31379,0.33096},// Illuminant D65 1964
{0.31598,0.33502} // Illuminant D65 1978
}
#declare Adobe_ColSys = array[6][2] {
{0.640, 0.330}, // red
{0.210, 0.710}, // green
{0.150, 0.060}, // blue
{0.31271,0.32902},// Illuminant D65 1931 observer
{0.31379,0.33096},// Illuminant D65 1964
{0.31598,0.33502} // Illuminant D65 1978
}
#declare Match_ColSys = array[6][2] {
{0.630, 0.340}, // red
{0.290, 0.610}, // green
{0.150, 0.075}, // blue
{0.34566,0.35850},// Illuminant D50 1931 observer
{0.34771,0.35951},// Illuminant D50 1964
{0.34919,0.36560} // Illuminant D50 1978
}
#declare Apple_ColSys = array[6][2] {
{0.630, 0.340}, // red
{0.280, 0.600}, // green
{0.160, 0.070}, // blue
{0.31271,0.32902},// Illuminant D65 1931 observer
{0.31379,0.33096},// Illuminant D65 1964
{0.31598,0.33502} // Illuminant D65 1978
}
#declare Beta_ColSys = array[6][2] {
{0.6888, 0.3112}, // red
{0.1986, 0.7551}, // green
{0.1265, 0.0352}, // blue
{0.34566,0.35850},// Illuminant D50 1931 observer
{0.34771,0.35951},// Illuminant D50 1964
{0.34919,0.36560} // Illuminant D50 1978
}
#declare Dell_ColSys = array[6][2] {
{0.625, 0.340}, // red
{0.275, 0.605}, // green
{0.150, 0.065}, // blue
{0.31271,0.32902},// Illuminant D65 1931 observer
{0.31379,0.33096},// Illuminant D65 1964
{0.31598,0.33502} // Illuminant D65 1978
}
#declare ShortPersistence_ColSys = array[6][2] {
{0.610, 0.350}, // red
{0.290, 0.590}, // green
{0.150, 0.063}, // blue
{0.31006,0.31616},// Illuminant C 1931 observer
{0.31038,0.31905},// Illuminant C 1964
{0.31373,0.32291} // Illuminant C 1978
}
#declare LongPersistence_ColSys = array[6][2] {
{0.620, 0.330}, // red
{0.210, 0.685}, // green
{0.150, 0.063}, // blue
{0.31006,0.31616},// Illuminant C 1931 observer
{0.31038,0.31905},// Illuminant C 1964
{0.31373,0.32291} // Illuminant C 1978
}
#declare HOT_ColSys = array[6][2] {
{0.7287, 0.2713}, // red
{0.0082, 0.5384}, // green
{0.1491, 0.0544}, // blue
{0.23991,0.23414},// infinite temperature 1931 observer
{0.23855,0.23873},// infinite temperature 1964
{0.24141,0.23253} // infinite temperature 1978
}
#else //no MultiObserver
/* Simplified version without the possibility to change the observer
* Color System format:
* (x-red, y-red),
* (x-green, y-green),
* (x-blue, y-blue),
* (x-white, y-white) whitepoint for 1931 2°observer
*/
#declare sRGB_ColSys = array[4][2] { // <- initialized as default
{0.640, 0.330}, // red
{0.300, 0.600}, // green
{0.150, 0.060}, // blue
{0.31271,0.32902} // Illuminant D65
}
#declare CIE_ColSys = array[4][2] {
{0.7347, 0.2653}, // red
{0.2738, 0.7174}, // green
{0.1666, 0.0088}, // blue
{1/3, 1/3} // Illuminant E
}
#declare ITU_ColSys = array[4][2] {
{0.640, 0.330}, // red
{0.290, 0.600}, // green
{0.150, 0.060}, // blue
{0.31271,0.32902} // Illuminant D65
}
#declare NTSC_ColSys = array[4][2] {
{0.670, 0.330}, // red
{0.210, 0.710}, // green
{0.140, 0.080}, // blue
{0.31006,0.31616} // Illuminant C
}
#declare SMPTE_ColSys = array[4][2] {
{0.630, 0.340}, // red
{0.310, 0.595}, // green
{0.155, 0.070}, // blue
{0.31271,0.32902} // Illuminant D65
}
#declare Adobe_ColSys = array[4][2] {
{0.640, 0.330}, // red
{0.210, 0.710}, // green
{0.150, 0.060}, // blue
{0.31271,0.32902} // Illuminant D65
}
#declare Match_ColSys = array[4][2] {
{0.630, 0.340}, // red
{0.290, 0.610}, // green
{0.150, 0.075}, // blue
{0.34566,0.35850} // Illuminant D50
}
#declare Apple_ColSys = array[4][2] {
{0.630, 0.340}, // red
{0.280, 0.600}, // green
{0.160, 0.070}, // blue
{0.31271,0.32902} // Illuminant D65
}
#declare Beta_ColSys = array[4][2] {
{0.6888, 0.3112}, // red
{0.1986, 0.7551}, // green
{0.1265, 0.0352}, // blue
{0.34566,0.35850} // Illuminant D50
}
#declare Dell_ColSys = array[4][2] {
{0.625, 0.340}, // red
{0.275, 0.605}, // green
{0.150, 0.065}, // blue
{0.31271,0.32902} // Illuminant D65
}
#declare ShortPersistence_ColSys = array[4][2] {
{0.610, 0.350}, // red
{0.290, 0.590}, // green
{0.150, 0.063}, // blue
{0.31006,0.31616} // Illuminant C
}
#declare LongPersistence_ColSys = array[4][2] {
{0.620, 0.330}, // red
{0.210, 0.685}, // green
{0.150, 0.063}, // blue
{0.31096,0.31616} // Illuminant C
}
#declare HOT_ColSys = array[4][2] {
{0.7287, 0.2713}, // red
{0.0082, 0.5384}, // green
{0.1491, 0.0544}, // blue
{0.23991,0.23414} // infinite temperature
}
#end //if MultiObserver
/* Chroma adaption matrices
* Scaling
* Von Kries
* Bradford
*/
#declare Scaling_MM = array[3][3] { // XYZ Scaling Chroma Match
{1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{0.0, 0.0, 1.0}
}
#declare VonKries_MM = array[3][3] { // Von Kries Chroma Match
{ 0.40024, 0.70760, -0.08081},
{-0.22630, 1.16532, 0.04570},
{ 0.00000, 0.00000, 0.91822}
}
#declare Bradford_MM = array[3][3] { // Bradford Chroma Match
{ 0.8951, 0.2664, -0.1614},
{-0.7502, 1.7135, 0.0367},
{ 0.0389, -0.0685, 1.0296}
}
//=====================================================================
// CIE color system default settings
//=====================================================================
/* definition for the color matching functions CMF
*/
#ifdef (CIE_MultiObserver)
#declare CIE_1931 = 0;
#declare CIE_1964 = 1;
#declare CIE_1978 = 2;
#end
/* definition for chromatic adaption functions
*/
#declare Scaling_ChromaMatch = 1;
#declare VonKries_ChromaMatch = 2;
#declare Bradford_ChromaMatch = 3;
/* hard coded and precalculated values
* these values are *local* so do not change them, if necessary they are
* automatical recalculated by using the appropriate macros
*/
#declare CIE_Spectrum = 0; // 1931 2° Observer
#declare xy_ColSys = sRGB_ColSys; // Color system
#declare ReferenceWhiteXY = Illuminant_D50; // reference white
#declare ReferenceWhiteXYZ = <0.96418, 1.0, 0.82522>;// XYZ for D50 CMF 1931 2° observer
#declare ChromaMatchFunction = Bradford_ChromaMatch; // chroma adaption function
#declare GamutMapFunction = 1; // clipping
/* Color system dependent matrix for rgb->xyz and xyz->rgb
* conversion. Hard coded and pre-calculated for the sRGB
* color system, illuminant D65 and CIE 1931 2°standard
* observer (the default setting).
* CCIR recommendation 709
*/
#declare csMatXYZ = array[3][3] {
{ 0.48499, 0.34891, 0.13029},
{ 0.25007, 0.69781, 0.05211},
{ 0.02273, 0.11630, 0.68618}
}
#declare csMatRGB = array[3][3] {
{ 3.24102,-1.53740,-0.49862},
{-0.96922, 1.87593, 0.04155},
{ 0.05564,-0.20401, 1.05714}
}
/* Adaption function dependent matrix for chroma matching
* Hard coded and pre-calculated for the Bradford match,
* reference white D50, 2° observer and sRGB color system
* with D65
*/
#declare ChromaMatS = array[3][3] {
{ 0.955565, -0.023045, 0.063180},
{-0.028296, 1.009942, 0.021013},
{ 0.012301, -0.020488, 1.329995}
}
#declare ChromaMatD = array[3][3] {
{ 1.047825, 0.022892, -0.050137},
{ 0.029550, 0.990484, -0.017053},
{-0.009236, 0.015047, 0.752084}
}
//=====================================================================
// internal helper macros
//=====================================================================
// convert a color component from the active color system to xyz
// where: z = 1 - x - y
// as the whitepoint depends on the CIE observer, it is also
// checked for the requested illuminant
#macro ColSys2xyz(Idx)
#if ((Idx>3)|(Idx<0)) #error "CIE.inc: Invalid ColSys index" #end
#if (CIE_MultiObserver & (Idx=3))
#local Idx=Idx+CIE_Spectrum;
#end
#local X = xy_ColSys[Idx][0];
#local Y = xy_ColSys[Idx][1];
(<X, Y, 1.0-X-Y>)
#end
// chroma match matrix calculation: M * [Xd/Xs Yd/Ys Zd/Zs] * Mi
#macro ApplyMatchMat(M, Vd, Vs)
#local V = ApplyMat(M,Vd)/ApplyMat(M,Vs);
#local D = array[3][3] {
{V.x, 0, 0},
{0, V.y, 0},
{0, 0, V.z}}
MultMat33(InvertMat33(M), MultMat33(D,M))
#end
#macro CreateChromaMat()
#local S = ReferenceWhiteXYZ;
#local D = xyz2XYZ(ColSys2xyz(3));
#switch (ChromaMatchFunction)
#case (Scaling_ChromaMatch)
#declare ChromaMatS = ApplyMatchMat(Scaling_MM, D,S);
#declare ChromaMatD = InvertMat33(ChromaMatS);
#break
#case (VonKries_ChromaMatch)
#declare ChromaMatS = ApplyMatchMat(VonKries_MM, D,S);
#declare ChromaMatD = InvertMat33(ChromaMatS);
#break
#case (Bradford_ChromaMatch)
#declare ChromaMatS = ApplyMatchMat(Bradford_MM, D,S);
#declare ChromaMatD = InvertMat33(ChromaMatS);
#break
#else
#declare ChromaMatS = Scaling_MM;
#declare ChromaMatD = Scaling_MM;
#end
#if (CIE_Debug)
#debug "\n"
#debug "Source White\n"
#debug concat(str(S.x,2,5),", ",str(S.y,2,5),", ",str(S.z,2,5),"\n")
#debug "Destination White\n"
#debug concat(str(D.x,2,5),", ",str(D.y,2,5),", ",str(D.z,2,5),"\n")
#debug "\n"
#debug "Chroma Source Matrix\n"
#debug concat(str(ChromaMatS[0][0],2,6),", ",str(ChromaMatS[0][1],2,6),", ",str(ChromaMatS[0][2],2,6),"\n")
#debug concat(str(ChromaMatS[1][0],2,6),", ",str(ChromaMatS[1][1],2,6),", ",str(ChromaMatS[1][2],2,6),"\n")
#debug concat(str(ChromaMatS[2][0],2,6),", ",str(ChromaMatS[2][1],2,6),", ",str(ChromaMatS[2][2],2,6),"\n")
#debug "\n"
#debug "Chroma Destination Matrix\n"
#debug concat(str(ChromaMatD[0][0],2,6),", ",str(ChromaMatD[0][1],2,6),", ",str(ChromaMatD[0][2],2,6),"\n")
#debug concat(str(ChromaMatD[1][0],2,6),", ",str(ChromaMatD[1][1],2,6),", ",str(ChromaMatD[1][2],2,6),"\n")
#debug concat(str(ChromaMatD[2][0],2,6),", ",str(ChromaMatD[2][1],2,6),", ",str(ChromaMatD[2][2],2,6),"\n")
#end