-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCAM_DRT_v026.nk
3231 lines (3231 loc) · 328 KB
/
CAM_DRT_v026.nk
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
set cut_paste_input [stack 0]
version 13.2 v3
push $cut_paste_input
Group {
name DRT_CAM_Blink4
label "Input: \[value encoding_in] / \[value primaries_in]\nLimit: \[value primaries_limit] / \[value ssts_luminance.2]nits\nOutput: \[value encoding_out] / \[value primaries_out]\n\[value toneScaleMode]\n\[value camMode] \[if \{\[value DRT_CAM_Kernel_HK_mode_in]==true\} \{return HK\\ mode\\ in\}]"
note_font "Bitstream Vera Sans"
selected true
xpos 112
ypos 117
addUserKnob {20 User}
addUserKnob {26 input_div l Input}
addUserKnob {4 encoding_in l encoding t "the input log or gamma encoding" M {Linear ACEScct sRGB BT.1886 "Gamma 2.6" ST2084 "" ""}}
addUserKnob {4 primaries_in l primaries t "the input primaries and white point" -STARTLINE M {AP0-ACES AP1-ACES sRGB/Rec.709-D65 Rec.2020-D65 P3-D65 P3-DCI "" ""}}
addUserKnob {6 D60toD65CAT l "D60 to D65 CAT" -STARTLINE}
addUserKnob {4 camMode M {ZCAM "Hellwig 2022"}}
camMode "Hellwig 2022"
addUserKnob {26 ""}
addUserKnob {41 DRT_CAM_Kernel_HK_mode_in l HK_mode_in T BlinkScript1.DRT_CAM_Kernel_HK_mode_in}
addUserKnob {41 DRT_CAM_Kernel_discountIlluminant_in l discountIlluminant_in -STARTLINE T BlinkScript1.DRT_CAM_Kernel_discountIlluminant_in}
addUserKnob {41 DRT_CAM_Kernel_HK_mode_mid l HK_mode_mid T BlinkScript1.DRT_CAM_Kernel_HK_mode_mid}
addUserKnob {41 DRT_CAM_Kernel_discountIlluminant_mid l discountIlluminant_mid -STARTLINE T BlinkScript1.DRT_CAM_Kernel_discountIlluminant_mid}
addUserKnob {41 DRT_CAM_Kernel_HK_mode_out l HK_mode_out T BlinkScript1.DRT_CAM_Kernel_HK_mode_out}
addUserKnob {41 DRT_CAM_Kernel_discountIlluminant_out l discountIlluminant_out -STARTLINE T BlinkScript1.DRT_CAM_Kernel_discountIlluminant_out}
addUserKnob {26 ""}
addUserKnob {41 DRT_CAM_Kernel_linear_extension l linear_extension T BlinkScript1.DRT_CAM_Kernel_linear_extension}
addUserKnob {41 DRT_CAM_Kernel_compressMode l compressMode T BlinkScript1.DRT_CAM_Kernel_compressMode}
addUserKnob {4 HellwigCam16Data l "Hellwig Cam16 Data" M {Stock Thomas "Live from params"}}
addUserKnob {4 inputViewingConditions l "Input Viewing Conditions" M {dark dim average}}
inputViewingConditions average
addUserKnob {26 ""}
addUserKnob {4 cat_type l "CAT Type" t "the chromatic adaptation transform to use for converting between white points" M {None "XYZ Scaling" Bradford CAT02 Zhai2018 ""}}
cat_type CAT02
addUserKnob {26 tonescale_div l Tonescale}
addUserKnob {4 toneScaleMode l "ToneScale Mode" M {SSTS MMSDC "Daniele Compression Curve" "Mult 0.5" "Daniele Evo Curve" "" ""}}
toneScaleMode "Daniele Evo Curve"
addUserKnob {6 applyTonecurve l "apply Tonecurve" t "toggle the SingleStageToneScale transform" +STARTLINE}
applyTonecurve true
addUserKnob {13 ssts_luminance l "SSTS luminance" t "min, mid & peak luminance values in Cd/sqm as parameters for the SSTS"}
ssts_luminance {1e-06 10 100}
addUserKnob {26 ssts_luminance_label l " " -STARTLINE T "min / mid / peak"}
addUserKnob {6 apply_highlight_desat l "apply highlight desat" t "toggle de-saturating the highlights above SSTS mid luminance based on how much the SSTS has compressed them" +STARTLINE}
apply_highlight_desat true
addUserKnob {7 desat_highlights l "desat highlights" t "the amount of desaturation applied to the highlights" R 0 5}
desat_highlights 1
addUserKnob {26 gamut_mapping_div l "Gamut Mapping"}
addUserKnob {6 apply_gamut_compression l "apply gamut compression " t "toggle the gamut compression towards the limiting primaries" +STARTLINE}
apply_gamut_compression true
addUserKnob {4 primaries_limit l primaries t "the limiting primaries of the gamut to which to compress to" M {AP0-ACES AP1-ACES sRGB/Rec.709-D65 Rec.2020-D65 P3-D65 P3-DCI ""}}
primaries_limit sRGB/Rec.709-D65
addUserKnob {6 discount_illuminant l "discount illuminant (Zhai2018 only)" t "disable the degree of adaptation model for the Zhai2018 CAT\nthis is only effective if the limiting primaries do not use a D65 white point" -STARTLINE}
discount_illuminant true
addUserKnob {7 cusp_mid_blend l "cusp to mid blend" t "blend the lightness (J) of the focal point of the compression between the lightness of the gamut cusp at the given hue (0.0) and the mid luminance of the SSTS (1.0)"}
cusp_mid_blend 0.5
addUserKnob {26 cusp_mid_blend_label l " " -STARTLINE T "gamut cusp (0) to SSTS mid (1)"}
addUserKnob {7 focus_distance l "focus distance" t "the distance from the achromatic axis of the focal point of the compression where 0.0 is at the achromatic axis and 1.0 the distance of the gamut cusp at the given hue but on the opposite side of the achomatic axis" R 0 2}
focus_distance 0.5
addUserKnob {26 focus_depth_label l " " -STARTLINE T "achromatic (0) to cusp opposite (1)"}
addUserKnob {13 compression_params l compression t "the threshold, limit and power parameters for the PowerP compression function\nvalues below the threshold will not be compressed and values at the limit will be compressed towards the gamut boundary while the power values defines the shape of the curve"}
compression_params {0.75 1.2 1.2}
addUserKnob {26 compression_params_label l " " -STARTLINE T "threshold / limit / power"}
addUserKnob {7 smooth_cusps l "smooth cusps" t "the amount by how much to smooth the edges and corners of the limiting gamut cube, except the black & white corners."}
addUserKnob {6 applyChromaCompression +STARTLINE}
applyChromaCompression true
addUserKnob {7 chromaCompression R 0 1.5}
chromaCompression 1
addUserKnob {7 saturation t "Global saturation" R 0 1.5}
saturation 1
addUserKnob {41 DRT_CAM_Kernel_focusJbypass l focusJbypass T BlinkScript1.DRT_CAM_Kernel_focusJbypass}
addUserKnob {26 ""}
addUserKnob {8 BlinkScript1_DRT_CAM_Kernel_compressionMix l compressionMix t "This is really just a trouble shooting tool"}
addUserKnob {3 solve_precision l "solve precision" t "the number of iterations used for finding the gamut boundary using the interval bisection method"}
solve_precision 10
addUserKnob {3 inverse_solver_iterations l "inverse solver iterations" t "the number of iterations used for finding the original J & M values when applying the inverse gamut compression"}
inverse_solver_iterations 10
addUserKnob {26 output_div l Output}
addUserKnob {4 encoding_out l encoding t "the output log or gamma encoding" M {Linear ACEScct sRGB BT.1886 "Gamma 2.6" ST2084 ""}}
encoding_out BT.1886
addUserKnob {4 primaries_out l primaries t "the output primaries and white point" -STARTLINE M {AP0-ACES AP1-ACES sRGB/Rec.709-D65 Rec.2020-D65 P3-D65 P3-DCI "" ""}}
primaries_out sRGB/Rec.709-D65
addUserKnob {4 viewing_conditions l "viewing conditions" t "the ZCAM viewing conditions" M {dark dim average ""}}
viewing_conditions average
addUserKnob {7 reference_luminance l "reference luminance" t "the ZCAM reference luminance in Cd/sqm" R 0 200}
reference_luminance 100
addUserKnob {7 background_luminance l "background luminance" t "the ZCAM background luminance in Cd/sqm" R 0 100}
background_luminance 10
addUserKnob {6 clamp_output l "clamp output" t "clamp the output values between 0,0 and 1.0" +STARTLINE}
clamp_output true
addUserKnob {26 ""}
addUserKnob {26 HellwigParams l "Hellwig Params"}
addUserKnob {8 BlinkScript1_DRT_CAM_Kernel_L_A l "Input Adapting field" t " // L_A\n // Adapting field *luminance* :math:`L_A` in :math:`cd/m^2`, (often taken\n // to be 20% of the luminance of a white object in the scene)."}
BlinkScript1_DRT_CAM_Kernel_L_A 100
addUserKnob {8 BlinkScript1_DRT_CAM_Kernel_Y_b l "Input background" t " // Y_b\n // Luminous factor of background :math:`Y_b` such as\n // :math:`Y_b = 100 x L_b / L_w` where :math:`L_w` is the luminance of the\n // light source and :math:`L_b` is the luminance of the background. For\n // viewing images, :math:`Y_b` can be the average :math:`Y` value for the\n // pixels in the entire image, or frequently, a :math:`Y` value of 20,\n // approximate an :math:`L^*` of 50 is used."}
BlinkScript1_DRT_CAM_Kernel_Y_b 20
addUserKnob {8 BlinkScript1_DRT_CAM_Kernel_L_A_out l "Output Adapting field" t " // L_A\n // Adapting field *luminance* :math:`L_A` in :math:`cd/m^2`, (often taken\n // to be 20% of the luminance of a white object in the scene)."}
BlinkScript1_DRT_CAM_Kernel_L_A_out 100
addUserKnob {8 BlinkScript1_DRT_CAM_Kernel_Y_b_out l "Output background" t " // Y_b\n // Luminous factor of background :math:`Y_b` such as\n // :math:`Y_b = 100 x L_b / L_w` where :math:`L_w` is the luminance of the\n // light source and :math:`L_b` is the luminance of the background. For\n // viewing images, :math:`Y_b` can be the average :math:`Y` value for the\n // pixels in the entire image, or frequently, a :math:`Y` value of 20,\n // approximate an :math:`L^*` of 50 is used."}
BlinkScript1_DRT_CAM_Kernel_Y_b_out 20
addUserKnob {26 ""}
addUserKnob {26 _1 l "" +STARTLINE T "Daniele Curve Params"}
addUserKnob {41 DRT_CAM_Kernel_n l n T BlinkScript1.DRT_CAM_Kernel_n}
addUserKnob {41 DRT_CAM_Kernel_nr l nr T BlinkScript1.DRT_CAM_Kernel_nr}
addUserKnob {41 DRT_CAM_Kernel_g l g T BlinkScript1.DRT_CAM_Kernel_g}
addUserKnob {41 DRT_CAM_Kernel_w l w T BlinkScript1.DRT_CAM_Kernel_w}
addUserKnob {41 DRT_CAM_Kernel_t_1 l t_1 T BlinkScript1.DRT_CAM_Kernel_t_1}
addUserKnob {26 _2 l "" +STARTLINE T "Custom CAM 16 style prims"}
addUserKnob {41 DRT_CAM_Kernel_rxy l rxy T BlinkScript1.DRT_CAM_Kernel_rxy}
addUserKnob {41 DRT_CAM_Kernel_gxy l gxy T BlinkScript1.DRT_CAM_Kernel_gxy}
addUserKnob {41 DRT_CAM_Kernel_bxy l bxy T BlinkScript1.DRT_CAM_Kernel_bxy}
addUserKnob {41 DRT_CAM_Kernel_wxy l wxy T BlinkScript1.DRT_CAM_Kernel_wxy}
addUserKnob {26 _3 l "Linear Extension breakpoint"}
addUserKnob {41 DRT_CAM_Kernel_L_B l L_B T BlinkScript1.DRT_CAM_Kernel_L_B}
addUserKnob {26 ""}
addUserKnob {26 direction_div l Direction}
addUserKnob {6 invert t "apply the pseudo-inverse transform" +STARTLINE}
addUserKnob {41 DRT_CAM_Kernel_diagnosticMode l diagnosticMode T BlinkScript1.DRT_CAM_Kernel_diagnosticMode}
addUserKnob {26 blink_kernel_div l "Blink Kernel"}
addUserKnob {6 use_gpu l "Use GPU if available" +STARTLINE}
use_gpu true
addUserKnob {26 ""}
}
Input {
inputs 0
name Input1
xpos -908
ypos -292
}
set Nac0b4c00 [stack 0]
Colorspace {
colorspace_out CIE-XYZ
name Colorspace2
xpos -1067
ypos -213
}
push $Nac0b4c00
BlinkScript {
kernelSourceFile output-transforms-dev/display-transforms/nuke/CAM_DRT_v026.blink
recompileCount 681
ProgramGroup 1
KernelDescription "2 \"DRT_CAM_Kernel\" iterate pixelWise 1dd9a2e7625ba0a8b53e616d8acbb0f55c3a6e38e6f3fbbac530d5da76d34449 2 \"src\" Read Point \"dst\" Write Point 92 \"encodingIn\" Int 1 AAAAAA== \"primariesIn\" Int 1 AAAAAA== \"toneScaleMode\" Int 1 AAAAAA== \"camMode\" Int 1 AAAAAA== \"catType\" Int 1 AAAAAA== \"discountIlluminant_in\" Bool 1 AA== \"discountIlluminant_mid\" Bool 1 AA== \"discountIlluminant_out\" Bool 1 AA== \"HK_mode_in\" Bool 1 AA== \"HK_mode_mid\" Bool 1 AA== \"HK_mode_out\" Bool 1 AA== \"linear_extension\" Bool 1 AA== \"compressMode\" Bool 1 AA== \"referenceLuminance\" Float 1 AAAAAA== \"backgroundLuminance\" Float 1 AAAAAA== \"viewingConditions\" Int 1 AAAAAA== \"outputViewingConditions\" Int 1 AAAAAA== \"applyTonecurve\" Bool 1 AA== \"sstsLuminance\" Float 3 AAAAAAAAAAAAAAAAAAAAAA== \"applyHighlightDesat\" Bool 1 AA== \"applyChromaCompression\" Bool 1 AA== \"desatHighlights\" Float 1 AAAAAA== \"chromaCompress\" Float 1 AAAAAA== \"chromaCompressParams\" Float 3 AAAAAAAAAAAAAAAAAAAAAA== \"sat\" Float 1 AAAAAA== \"shadow_boost\" Float 1 AAAAAA== \"rfM\" Float 1 AAAAAA== \"gfM\" Float 1 AAAAAA== \"bfM\" Float 1 AAAAAA== \"cfM\" Float 1 AAAAAA== \"mfM\" Float 1 AAAAAA== \"yofM\" Float 1 AAAAAA== \"primariesLimit\" Int 1 AAAAAA== \"applyGamutCompression\" Bool 1 AA== \"cuspMidBlend\" Float 1 AAAAAA== \"focusDistance\" Float 1 AAAAAA== \"compressionFuncParams\" Float 3 AAAAAAAAAAAAAAAAAAAAAA== \"compressionMix\" Float 1 AAAAAA== \"smoothCusps\" Float 1 AAAAAA== \"boundarySolvePrecision\" Int 1 AAAAAA== \"inverseSolverIterations\" Int 1 AAAAAA== \"encodingOut\" Int 1 AAAAAA== \"primariesOut\" Int 1 AAAAAA== \"clampOutput\" Bool 1 AA== \"invert\" Bool 1 AA== \"diagnosticMode\" Int 1 AAAAAA== \"XYZ_to_LMS_ZCAM\" Float 9 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA \"zcam_rho\" Float 1 AAAAAA== \"Lp\" Float 1 AAAAAA== \"su\" Float 1 AAAAAA== \"c0\" Float 1 AAAAAA== \"cs\" Float 1 AAAAAA== \"c1\" Float 1 AAAAAA== \"p\" Float 1 AAAAAA== \"w1\" Float 1 AAAAAA== \"s1\" Float 1 AAAAAA== \"ex\" Float 1 AAAAAA== \"eb\" Float 1 AAAAAA== \"e0\" Float 1 AAAAAA== \"s0\" Float 1 AAAAAA== \"fl\" Float 1 AAAAAA== \"dch\" Float 1 AAAAAA== \"mmScaleFactor\" Float 1 AAAAAA== \"n\" Float 1 AAAAAA== \"nr\" Float 1 AAAAAA== \"g\" Float 1 AAAAAA== \"w\" Float 1 AAAAAA== \"t_1\" Float 1 AAAAAA== \"daniele_n\" Float 1 AAAAAA== \"daniele_n_r\" Float 1 AAAAAA== \"daniele_g\" Float 1 AAAAAA== \"daniele_c\" Float 1 AAAAAA== \"daniele_c_d\" Float 1 AAAAAA== \"daniele_w_g\" Float 1 AAAAAA== \"daniele_t_1\" Float 1 AAAAAA== \"daniele_r_hit_min\" Float 1 AAAAAA== \"daniele_r_hit_max\" Float 1 AAAAAA== \"catDataSelection\" Int 1 AAAAAA== \"rxy\" Float 2 AAAAAAAAAAA= \"gxy\" Float 2 AAAAAAAAAAA= \"bxy\" Float 2 AAAAAAAAAAA= \"wxy\" Float 2 AAAAAAAAAAA= \"XYZ_w\" Float 3 AAAAAAAAAAAAAAAAAAAAAA== \"XYZ_w_scaler\" Float 1 AAAAAA== \"L_A\" Float 1 AAAAAA== \"Y_b\" Float 1 AAAAAA== \"L_B\" Float 3 AAAAAAAAAAAAAAAAAAAAAA== \"userSurround\" Float 3 AAAAAAAAAAAAAAAAAAAAAA== \"discount_illuminant\" Bool 1 AA== \"L_A_out\" Float 1 AAAAAA== \"Y_b_out\" Float 1 AAAAAA== \"focusJbypass\" Bool 1 AA== 92 \"encodingIn\" 1 1 \"primariesIn\" 1 1 \"toneScaleMode\" 1 1 \"camMode\" 1 1 \"catType\" 1 1 \"discountIlluminant_in\" 1 1 \"discountIlluminant_mid\" 1 1 \"discountIlluminant_out\" 1 1 \"HK_mode_in\" 1 1 \"HK_mode_mid\" 1 1 \"HK_mode_out\" 1 1 \"linear_extension\" 1 1 \"compressMode\" 1 1 \"referenceLuminance\" 1 1 \"backgroundLuminance\" 1 1 \"viewingConditions\" 1 1 \"outputViewingConditions\" 1 1 \"applyTonecurve\" 1 1 \"sstsLuminance\" 3 1 \"applyHighlightDesat\" 1 1 \"applyChromaCompression\" 1 1 \"desatHighlights\" 1 1 \"chromaCompress\" 1 1 \"chromaCompressParams\" 3 1 \"sat\" 1 1 \"shadow_boost\" 1 1 \"rfM\" 1 1 \"gfM\" 1 1 \"bfM\" 1 1 \"cfM\" 1 1 \"mfM\" 1 1 \"yofM\" 1 1 \"primariesLimit\" 1 1 \"applyGamutCompression\" 1 1 \"cuspMidBlend\" 1 1 \"focusDistance\" 1 1 \"compressionFuncParams\" 3 1 \"compressionMix\" 1 1 \"smoothCusps\" 1 1 \"boundarySolvePrecision\" 1 1 \"inverseSolverIterations\" 1 1 \"encodingOut\" 1 1 \"primariesOut\" 1 1 \"clampOutput\" 1 1 \"invert\" 1 1 \"diagnosticMode\" 1 1 \"XYZ_to_LMS_ZCAM\" 9 1 \"zcam_rho\" 1 1 \"Lp\" 1 1 \"su\" 1 1 \"c0\" 1 1 \"cs\" 1 1 \"c1\" 1 1 \"p\" 1 1 \"w1\" 1 1 \"s1\" 1 1 \"ex\" 1 1 \"eb\" 1 1 \"e0\" 1 1 \"s0\" 1 1 \"fl\" 1 1 \"dch\" 1 1 \"mmScaleFactor\" 1 1 \"n\" 1 1 \"nr\" 1 1 \"g\" 1 1 \"w\" 1 1 \"t_1\" 1 1 \"daniele_n\" 1 1 \"daniele_n_r\" 1 1 \"daniele_g\" 1 1 \"daniele_c\" 1 1 \"daniele_c_d\" 1 1 \"daniele_w_g\" 1 1 \"daniele_t_1\" 1 1 \"daniele_r_hit_min\" 1 1 \"daniele_r_hit_max\" 1 1 \"catDataSelection\" 1 1 \"rxy\" 2 1 \"gxy\" 2 1 \"bxy\" 2 1 \"wxy\" 2 1 \"XYZ_w\" 3 1 \"XYZ_w_scaler\" 1 1 \"L_A\" 1 1 \"Y_b\" 1 1 \"L_B\" 3 1 \"userSurround\" 3 1 \"discount_illuminant\" 1 1 \"L_A_out\" 1 1 \"Y_b_out\" 1 1 \"focusJbypass\" 1 1 59 \"HALF_MIN\" Float 1 1 AAAAAA== \"HALF_MAX\" Float 1 1 AAAAAA== \"CAT_CAT16\" Float 9 1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA \"panlrcm\" Float 9 1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA \"zcam_L_A\" Float 1 1 AAAAAA== \"zcam_F_b\" Float 1 1 AAAAAA== \"zcam_F_L\" Float 1 1 AAAAAA== \"zcam_cb\" Float 1 1 AAAAAA== \"zcam_cg\" Float 1 1 AAAAAA== \"zcam_c1\" Float 1 1 AAAAAA== \"zcam_c2\" Float 1 1 AAAAAA== \"zcam_c3\" Float 1 1 AAAAAA== \"zcam_eta\" Float 1 1 AAAAAA== \"zcam_luminance_shift\" Float 1 1 AAAAAA== \"zcam_viewing_conditions_coeff\" Float 1 1 AAAAAA== \"daniele_r_hit\" Float 1 1 AAAAAA== \"daniele_m_0\" Float 1 1 AAAAAA== \"daniele_m_1\" Float 1 1 AAAAAA== \"daniele_u\" Float 1 1 AAAAAA== \"daniele_m\" Float 1 1 AAAAAA== \"daniele_w_i\" Float 1 1 AAAAAA== \"daniele_c_t\" Float 1 1 AAAAAA== \"daniele_g_ip\" Float 1 1 AAAAAA== \"daniele_g_ipp2\" Float 1 1 AAAAAA== \"daniele_w_2\" Float 1 1 AAAAAA== \"daniele_s_2\" Float 1 1 AAAAAA== \"daniele_u_2\" Float 1 1 AAAAAA== \"daniele_m_2\" Float 1 1 AAAAAA== \"cat_adaptDegree\" Float 1 1 AAAAAA== \"st2084_m_1\" Float 1 1 AAAAAA== \"st2084_m_2\" Float 1 1 AAAAAA== \"st2084_c_1\" Float 1 1 AAAAAA== \"st2084_c_2\" Float 1 1 AAAAAA== \"st2084_c_3\" Float 1 1 AAAAAA== \"st2084_m_1_d\" Float 1 1 AAAAAA== \"st2084_m_2_d\" Float 1 1 AAAAAA== \"st2084_L_p\" Float 1 1 AAAAAA== \"identity_matrix\" Float 9 1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA \"XYZ_to_LMS_Bradford\" Float 9 1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA \"XYZ_to_LMS_CAT02\" Float 9 1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA \"LMS_to_Izazbz\" Float 9 1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA \"XYZ_to_RGB_input\" Float 9 1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA \"XYZ_to_RGB_limit\" Float 9 1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA \"XYZ_to_RGB_output\" Float 9 1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA \"RGB_to_XYZ_input\" Float 9 1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA \"RGB_to_XYZ_limit\" Float 9 1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA \"RGB_to_XYZ_output\" Float 9 1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA \"d65White\" Float 3 1 AAAAAAAAAAAAAAAAAAAAAA== \"inWhite\" Float 3 1 AAAAAAAAAAAAAAAAAAAAAA== \"outWhite\" Float 3 1 AAAAAAAAAAAAAAAAAAAAAA== \"refWhite\" Float 3 1 AAAAAAAAAAAAAAAAAAAAAA== \"limitWhite\" Float 3 1 AAAAAAAAAAAAAAAAAAAAAA== \"boundaryRGB\" Float 1 1 AAAAAA== \"limitJmax\" Float 1 1 AAAAAA== \"limitMmax\" Float 1 1 AAAAAA== \"gamutCuspTableSize\" Int 1 1 AAAAAA== \"gamutCuspTableUnsorted\" Float 3 360 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA \"focusDistanceClamped\" Float 1 1 AAAAAA=="
kernelSource "\nkernel DRT_CAM_Kernel : ImageComputationKernel<ePixelWise>\n\{\n Image<eRead, eAccessPoint, eEdgeClamped> src; // the input image\n Image<eWrite> dst; // the output image\n\n param:\n //\n // Input Parameters\n //\n\n // Encoding of the Input Image\n // 0: Linear\n // 1: ACEScct\n // 2: sRGB\n // 3: BT.1886 (Gamma 2.4)\n // 4: Gamma 2.6\n // 5: ST2084\n int encodingIn;\n\n // Primaries of the Input Image\n // 0: AP0-ACES\n // 1: AP1-ACES\n // 2: sRGB/Rec.709-D65\n // 3: Rec.2020-D65\n // 4: P3-D65\n // 5: P3-DCI\n int primariesIn;\n\n\n // Tonescale mode\n // 0: SSTS\n // 1: MMSDC\n // 2: Daniele Compression Curve\n // 3: Mult 0.5?\n // 4: Daniele Evo Curve\n int toneScaleMode;\n\n // CAM mode\n // 0: ZCAM\n // 1: Hellwig 2022 / Now uses toggles to switch between linear extension etc.\n int camMode;\n\n \n\n //\n // ZCAM Paramters\n //\n\n // Chomatic Adaptation Transform to Use\n // 0: None\n // 1: XYZ Scaling\n // 2: Bradford\n // 3: CAT02\n // 4: Zhai2018 (two-step)\n int catType;\n\n // Disable Degree of Adaptation Model for Zhai2018 CAT\n // This is only effective if the limit primaries have a non-D65 white point\n // since the input conversion is assumed to be fully adapted\n // and the output conversion does not apply a CAT\n bool discountIlluminant_in;\n bool discountIlluminant_mid;\n bool discountIlluminant_out;\n\n // Toggles for Hellwig 2022 specific params\n bool HK_mode_in;\n bool HK_mode_mid;\n bool HK_mode_out;\n bool linear_extension;\n bool compressMode;\n\n // Reference Luminance in Cd/sqm\n float referenceLuminance;\n\n // Background Luminance in Cd/sqm\n float backgroundLuminance;\n\n // Viewing Conditions (for output)\n // 0: Dark\n // 1: Dim\n // 2: Average\n int viewingConditions;\n int outputViewingConditions;\n\n\n\n // Toggle Tone Mapping\n bool applyTonecurve;\n \n // SSTS Luminances Min/Mid/Peak\n float3 sstsLuminance;\n\n // Toggle Highlight De-Saturation\n bool applyHighlightDesat;\n\n // Toggle chroma compression (replacement for higlight desat)\n bool applyChromaCompression;\n\n // Scale the De-Saturation Applied to the Highlights\n float desatHighlights;\n\n // Chroma compression\n float chromaCompress;\n float3 chromaCompressParams;\n float sat;\n float shadow_boost;\n float rfM;\n float gfM;\n float bfM;\n float cfM;\n float mfM;\n float yofM;\n\n //\n // Gamut Mapping Parameters\n //\n\n // Primaries of the Target Gamut\n // 0: AP0-ACES\n // 1: AP1-ACES\n // 2: sRGB/Rec.709-D65\n // 3: Rec.2020-D65\n // 4: P3-D65\n // 5: P3-DCI\n int primariesLimit;\n\n\n // Toggle Gamut Compression\n bool applyGamutCompression;\n\n // Blend Between Compressing towards\n // Target Gamut Cusp Luminance (0.0)\n // and SSTS Mid Luminance (1.0)\n float cuspMidBlend;\n\n // the distance of the compression focal point\n // from the achromatic axis\n // normalised to the distance of the gamut cusp\n float focusDistance;\n\n // Gamut Compression Fuction Parameters\n // Threshold / Limit / Power\n float3 compressionFuncParams;\n float compressionMix;\n\n // How much the edges of the target RGB cube are smoothed when finding the gamut boundary \n // in order to reduce visible contours at the gamut cusps\n float smoothCusps;\n\n // When solving for the target gamut boundary\n // how many search interval halving steps to perform\n int boundarySolvePrecision;\n\n // Number of iterations to converge on the uncompressed J value \n // Because of the compression focus point changes depending on the J value of the uncompressed sample\n // we cannot perfectly invert it since the original J value has now been changed by the forward compression\n // we can converge on a reasonable approximation of the original J value by iterating the inverse compression\n // although this is quite an expensive operation\n int inverseSolverIterations;\n\n //\n // Output Parameters\n //\n\n // Encoding of the Output Image\n // 0: Linear\n // 1: ACEScct\n // 2: sRGB\n // 3: BT.1886 (Gamma 2.4)\n // 4: Gamma 2.6\n // 5: ST2084\n int encodingOut;\n\n // Primaries of the Output Image\n // 0: AP0-ACES\n // 1: AP1-ACES\n // 2: sRGB/Rec.709-D65\n // 3: Rec.2020-D65\n // 4: P3-D65\n // 5: P3-DCI\n int primariesOut;\n\n // Clamp output values to 0.0 - 1.0\n bool clampOutput;\n\n //\n // Extra Parameters\n //\n\n // Toggle Inverse Transform\n bool invert;\n // Diagnostic path modes\n int diagnosticMode;\n\n float3x3 XYZ_to_LMS_ZCAM;\n float zcam_rho;\n\n\n // Tonescale select\n // bool mmTonescaleMode;\n // OpenDRT tonescale parameters\n float Lp;\n float su;\n float c0;\n float cs;\n float c1;\n float p;\n float w1;\n float s1;\n float ex;\n float eb;\n float e0;\n float s0;\n float fl;\n float dch;\n float mmScaleFactor;\n\n // DanieleCompressionCurve tonescale parameters\n float n;\n float nr;\n float g;\n float w;\n float t_1;\n\n // DanieleEvoCurve parameters\n float daniele_n; // peak white \n float daniele_n_r; // Normalized white in nits (what 1.0 should be)\n float daniele_g; // surround / contrast\n float daniele_c; // scene-referred grey\n float daniele_c_d; // display-referred grey (in nits)\n float daniele_w_g; // grey change between different peak luminance\n float daniele_t_1; // shadow toe, flare/glare compensation - how ever you want to call it\n float daniele_r_hit_min; // Scene-referred value \"hitting the roof\" at 100 nits\n float daniele_r_hit_max; // Scene-referred value \"hitting the roof\" at 10,000 nits\n\n // Hellwig 2022 CAM params\n // the kernel parameters\n\n // 0 = Stock CAT16\n // 1 = Thomas's custom primaries\n // 2 = live from params below\n int catDataSelection; // original vs modified CAT16 matrix\n // xy coordintes for custom CAT matrix\n float2 rxy;\n float2 gxy;\n float2 bxy;\n float2 wxy;\n \n // Input vars\n float3 XYZ_w;\n float XYZ_w_scaler;\n float L_A;\n float Y_b;\n float3 L_B;\n float3 userSurround;\n bool discount_illuminant;\n\n // Output vars\n float L_A_out;\n float Y_b_out;\n\n // Troubleshooting toggle\n bool focusJbypass;\n\n\n\n\n local:\n\n // constants\n float HALF_MIN;\n float HALF_MAX;\n\n // Hellwig 2022 constants\n float3x3 CAT_CAT16;\n float3x3 panlrcm;\n\n // ZCAM vars\n float zcam_L_A;\n float zcam_F_b;\n float zcam_F_L;\n float zcam_cb;\n float zcam_cg;\n float zcam_c1;\n float zcam_c2;\n float zcam_c3;\n float zcam_eta;\n // float zcam_rho;\n float zcam_luminance_shift;\n float zcam_viewing_conditions_coeff;\n\n float daniele_r_hit;\n float daniele_m_0;\n float daniele_m_1;\n float daniele_u;\n float daniele_m;\n float daniele_w_i;\n float daniele_c_t;\n float daniele_g_ip;\n float daniele_g_ipp2;\n float daniele_w_2;\n float daniele_s_2;\n float daniele_u_2;\n float daniele_m_2;\n\n // CAT vars\n float cat_adaptDegree;\n\n\n // ST2084 vars\n float st2084_m_1;\n float st2084_m_2;\n float st2084_c_1;\n float st2084_c_2;\n float st2084_c_3;\n float st2084_m_1_d;\n float st2084_m_2_d;\n float st2084_L_p;\n\n // using the float3x3 type to store the array of 6 coefficients\n // because Blink does not support generic array assignments\n\n // matrix vars\n float3x3 identity_matrix;\n float3x3 XYZ_to_LMS_Bradford;\n float3x3 XYZ_to_LMS_CAT02;\n\n // float3x3 XYZ_to_LMS_ZCAM;\n float3x3 LMS_to_Izazbz;\n\n float3x3 XYZ_to_RGB_input;\n float3x3 XYZ_to_RGB_limit;\n float3x3 XYZ_to_RGB_output;\n\n float3x3 RGB_to_XYZ_input;\n float3x3 RGB_to_XYZ_limit;\n float3x3 RGB_to_XYZ_output;\n\n // white points\n float3 d65White;\n float3 inWhite;\n float3 outWhite;\n float3 refWhite;\n float3 limitWhite;\n\n // the maximum RGB value of the limiting gamut\n float boundaryRGB;\n\n // the maximum lightness value of the limiting gamut\n float limitJmax;\n\n // the maximum colorfulness value of the limiting gamut\n float limitMmax;\n\n // the 1D LUT used for quickly findig the approximate limiting gamut cusp JMh coordinates\n // the samples are spaced by HSV hue increments of the limiting RGB gamut\n // so to find the correct entry for a given ZCAM hue (h) value \n // one must search the table entries for the matching entry.z component\n int gamutCuspTableSize;\n\n // the 'gamutCuspTableUnsorted' table is populated\n // in increments of H of the limiting gamut HSV space starting at H=0.0\n // since it is unlikely that HSV.H=0 and JMh.h=0 line up\n // the entries are then wrap-around shifted\n // so that the 'gamutCuspTable' starts with the lowest JMh.h value\n // both tables need to be declared here since temporary array variables\n // in the init() fuction seem to crash Nuke on some systems\n float3 gamutCuspTableUnsorted\[360];\n float3 gamutCuspTable\[360];\n\n // local version of the public focusDistance parameter\n // this one will be clamped to a value > 0.0\n float focusDistanceClamped;\n\n void define()\n \{\n\n \}\n\n // multiplies a 3D vector with a 3x3 matrix\n float3 vector_dot( float3x3 m, float3 v)\n \{\n float3 r = 1.0f;\n for(int c = 0; c<3; c++)\n \{\n r\[c] = m\[c]\[0]*v.x + m\[c]\[1]*v.y + m\[c]\[2]*v.z;\n \}\n\n return r;\n \}\n\n // linear interpolation between two values a & b with the bias t\n float lerp(float a, float b, float t)\n \{\n return a + t * (b - a);\n \}\n\n // get the y value of f(x) where the fuction is defined as a line between two points\n // the two points as passed as an array \[a.x, a.y, b.x, b.y]\n float lerp1D( float4 table, float x)\n \{\n float m = (table.w-table.y) / (table.z-table.x);\n float c = table.y - (m*table.x);\n float y = x*m+c;\n return y;\n \}\n\n\n // \"safe\" power function to avoid NANs or INFs when taking a fractional power of a negative base\n // this one initially returned -pow(abs(b), e) for negative b\n // but this ended up producing undesirable results in some cases\n // so now it just returns 0.0 instead\n float spow( float base, float exponent )\n \{\n\n\n // a = np.atleast_1d(a)\n float a = base;\n float b = exponent;\n // // p = as_float_array(p)\n\n // float a_p = sign(a) * pow( fabs(a) ,p) ; \n\n // // a_p\[np.isnan(a_p)] = 0\n\n // return a_p;\n\n // np.sign(a) * pow(np.abs(a) , b) \n\n // float a_p = sign(a) * pow(fabs(a) , b) ;\n // if ( isnan(a_p) )\n // \{\n // a_p = a_p;\n // \}\n // else \n // \{\n // a_p = 0.0;\n // \}\n // return a_p;\n\n if(base < 0.0f && exponent != floor(exponent) )\n \{\n return 0.0f;\n \}\n else\n \{\n return pow(base, exponent); \n \}\n \}\n\n\n // clamp the components of a 3D vector between a min & max value\n float3 clamp3(float3 v, float min, float max)\n \{\n v.x = clamp(v.x, min, max);\n v.y = clamp(v.y, min, max);\n v.z = clamp(v.z, min, max);\n return v;\n \}\n\n\n float3 float3spow( float3 base, float exponent )\n \{\n return float3(spow(base.x, exponent), spow(base.y, exponent), spow(base.z, exponent));\n \}\n\n float3 float3sign( float3 v )\n \{\n return float3(sign(v.x), sign(v.y), sign(v.z));\n \}\n\n\n float3 float3abs( float3 a )\n \{\n return fabs(a);\n \}\n\n\n\n // \"safe\" div\n float sdiv( float a, float b )\n \{\n if(b == 0.0f)\n \{\n return 0.0f;\n \}\n else\n \{\n return a / b;\n \}\n \}\n \n\n float hue_angle( float a, float b )\n \{\n float h = degrees(atan2(b, a)) / 360;\n \n return h;\n \}\n\n\n\n float3 float3_to_domain_100( float3 v )\n \{\n return v ;\n \}\n \n float clip(float x, float a, float b)\n \{\n return max(a, min(x, b));\n \}\n\n float mod(float a, float N)\n \{\n return a - N*floor(a/N);\n \} \n\n\n float achromatic_response_forward(float3 RGB)\n \{\n\n float R = RGB.x;\n float G = RGB.y;\n float B = RGB.z;\n\n\n float A = 2 * R + G + 0.05 * B - 0.305;\n\n return A;\n \}\n\n float colourfulness_correlate(float N_c,float e_t,float a,float b) \n \{\n\n float M = 43 * N_c * e_t * sqrt(pow(a,2) + pow(b,2));\n\n return M;\n \}\n\n\n\n float degree_of_adaptation(float F, float L_A )\n \{\n float D = F * (1 - (1 / 3.6) * exp((-L_A - 42) / 92));\n\n return D;\n \}\n\n // convert radians to degrees\n float degrees( float radians )\n \{\n return radians * 180.0f / PI;\n \}\n\n\n // convert degrees to radians\n float radians( float degrees )\n \{\n return degrees / 180.0f * PI;\n \}\n\n\n\n float3 compress(float3 xyz)\n \{\n \n float x = xyz.x;\n float y = xyz.y;\n float z = xyz.z;\n \n float C = (x+y+z)/3;\n if (C == 0.0f)\n return float3(x,y,z);\n\n float R = sqrt(spow((x-C),2) + spow((y-C),2) + spow((z-C),2)) ;\n // np.sqrt(2/3)\n // 0.816496580927726\n R = R * 0.816496580927726;\n \n if (R != 0.0)\n \{\n x = (x-C)/R ;\n y = (y-C)/R ;\n z = (z-C)/R ;\n \}\n \n float r = R/C ;\n float s = -min(x, min(y, z));\n \n float t = 0.0;\n if (r != 0.0)\n \{\n t = (0.5+spow((spow((s-0.5),2) + spow((sqrt(4/spow(r,2)+1)-1),2)/4),0.5));\n if (t == 0.0f)\n return float3(xyz.x,xyz.y,xyz.z);\n t = 1/t;\n \}\n \n x = C*x*t + C ;\n y = C*y*t + C ;\n z = C*z*t + C ;\n \n return float3(x,y,z);\n \}\n\n\nfloat3 uncompress(float3 xyz)\n\{\n\n \n float x = xyz.x;\n float y = xyz.y;\n float z = xyz.z;\n \n float C = (x+y+z)*(1.0/3.0) ;\n if (C == 0.0f)\n return float3(x,y,z);\n\n float R = sqrt(spow((x-C),2) + spow((y-C),2) + spow((z-C),2));\n // np.sqrt(2/3)\n // 0.816496580927726\n R = R * 0.816496580927726;\n \n if (R != 0.0)\n \{\n x = (x-C)/R ;\n y = (y-C)/R ;\n z = (z-C)/R ;\n \}\n\n float t = R/C ;\n float s = -min(x, min(y, z));\n \n float r = 0.0;\n if (t != 0.0)\n \{\n r = sqrt(spow((2*sqrt(spow((1/t-0.5),2)-spow((s-0.5),2))+1),2)-1);\n if (r == 0.0f)\n return float3(xyz.x,xyz.y,xyz.z);\n r = 2/r;\n \}\n \n x = C*x*r + C ;\n y = C*y*r + C ;\n z = C*z*r + C ;\n \n return float3(x,y,z);\n\}\n\n\n\n\n\n float hue_angle_dependency_Hellwig2022(float h)\n \{\n // \"\"\"\n // Compute the hue angle dependency of the *Helmholtz–Kohlrausch* effect.\n // Parameters\n // ----------\n // h\n // Hue :math:`h` angle in degrees.\n // Returns\n // -------\n // :class:`numpy.floating` or :class:`numpy.ndarray`\n // Hue angle dependency.\n // Examples\n // --------\n // >>> hue_angle_dependency_Hellwig2022(219.0484326582719)\n // ... # doctest: +ELLIPSIS\n // 0.8962565...\n // \"\"\"\n\n // h = as_float_array(h)\n return float( \\\n -0.160 * cos(h) \\\n + 0.132 * cos(2 * h) \\\n - 0.405 * sin(h) \\\n + 0.080 * sin(2 * h) \\ \n + 0.792 \\\n );\n\n // return float( -0.160f * cos(h) + 0.132f * cos(2.0f * h) - 0.405f * sin(h) + 0.080f * sin(2.0f * h) + 0.792f );\n \}\n\n\n\n float3x3 RGBPrimsToXYZMatrix(float2 rxy, float2 gxy, float2 bxy, float2 wxy,float Y, bool direction)\n \{\n // # given r g b chromaticities and whitepoint, convert RGB colors to XYZ\n // # based on CtlColorSpace.cpp from the CTL source code : 77\n // # param: xy - dict of chromaticity xy coordinates: rxy: float2(x, y) etc\n // # param: Y - luminance of \"white\" - defaults to 1.0\n // # param: inverse - calculate XYZ to RGB instead\n\n float2 r = rxy;\n float2 g = gxy;\n float2 b = bxy;\n float2 w = wxy;\n\n float X = w.x * Y / w.y;\n float Z = (1 - w.x - w.y) * Y / w.y;\n\n // # Scale factors for matrix rows\n float d = r.x * (b.y - g.y) + b.x * (g.y - r.y) + g.x * (r.y - b.y);\n\n float Sr = (X * (b.y - g.y) - \\\n g.x * (Y * (b.y - 1.0f) + \\\n b.y * (X + Z)) + \\\n b.x * (Y * (g.y - 1.0f) + \\\n g.y * (X + Z))) / d ;\n \n float Sg = (X * (r.y - b.y) + \\\n r.x * (Y * (b.y - 1.0f) + \\\n b.y * (X + Z)) - \\\n b.x * (Y * (r.y - 1.0f) + \\\n r.y * (X + Z))) / d ;\n\n float Sb = (X * (g.y - r.y) - \\\n r.x * (Y * (g.y - 1.0f) + \\\n g.y * (X + Z)) + \\\n g.x * (Y * (r.y - 1.0f) + \\\n r.y * (X + Z))) / d ;\n\n // # Assemble the matrix\n float Mdata\[] =\n \{\n Sr * r.x, Sr * r.y, Sr * (1.0f - r.x - r.y),\n Sg * g.x, Sg * g.y, Sg * (1.0f - g.x - g.y),\n Sb * b.x, Sb * b.y, Sb * (1.0f - b.x - b.y),\n \};\n\n float MdataNukeOrder\[] = \{\n Mdata\[0], Mdata\[3], Mdata\[6],\n Mdata\[1], Mdata\[4], Mdata\[7],\n Mdata\[2], Mdata\[5], Mdata\[8],\n \};\n\n float3x3 newMatrix;\n newMatrix.setArray(MdataNukeOrder);\n\n // create inverse matrix\n float3x3 newMatrixInverse = newMatrix.invert();\n\n // return forward or inverse matrix\n if (direction == 0)\n \{\n return newMatrix;\n \}\n else if (direction == 1)\n \{\n return newMatrixInverse;\n \}\n \}\n\n float3 viewingConditionsToSurround(int viewingConditions)\n \{\n float3 newSurround;\n // hack to turn incoming int value into surround coeffs\n if (viewingConditions == 0)\n \{\n // \"Dark\": InductionFactors_CIECAM02(0.8, 0.525, 0.8),\n newSurround = float3(0.8, 0.525, 0.8);\n \}\n else if (viewingConditions == 1)\n \{\n // \"Dim\": InductionFactors_CIECAM02(0.9, 0.59, 0.9),\n newSurround = float3(0.9, 0.59, 0.9);\n \}\n else if (viewingConditions == 2)\n \{\n // \"Average\": InductionFactors_CIECAM02(1, 0.69, 1),\n newSurround = float3(1.0, 0.69, 1.0);\n \}\n else if (viewingConditions == 3)\n \{\n // Pull from external input\n newSurround = userSurround;\n \}\n return newSurround;\n \}\n\n // \"PowerP\" compression function (also used in the ACES Reference Gamut Compression transform)\n // values of v above 'treshold' are compressed by a 'power' function\n // so that an input value of 'limit' results in an output of 1.0\n float compressPowerP( float v, float threshold, float limit, float power, int inverse )\n \{\n float s = (limit-threshold)/pow(pow((1.0f-threshold)/(limit-threshold),-power)-1.0f,1.0f/power);\n\n float vCompressed;\n\n if( inverse )\n \{\n vCompressed = (v<threshold||limit<1.0001f||v>threshold+s)?v:threshold+s*pow(-(pow((v-threshold)/s,power)/(pow((v-threshold)/s,power)-1.0f)),1.0f/power);\n \}\n else\n \{\n vCompressed = (v<threshold||limit<1.0001f)?v:threshold+s*((v-threshold)/s)/(pow(1.0f+pow((v-threshold)/s,power),1.0f/power));\n \}\n\n return vCompressed;\n \}\n\n // Two-Stage chromatic adaptation transforms as proposed by Zhai, Q., & Luo, M. R. (2018)\n // https://opg.optica.org/oe/fulltext.cfm?uri=oe-26-6-7724\n // https://github.com/colour-science/colour/blob/e5fa0790adcc3e5df5fa42ddf2bb75214c8cf59c/colour/adaptation/zhai2018.py\n float3 CAT_Zhai2018( float3 XYZ_b, float3 XYZ_wb, float3 XYZ_wd, float D_b, float D_d, float3x3 M)\n \{\n float3 XYZ_wo = 100.0f;\n float3 RGB_b = vector_dot(M, XYZ_b);\n float3 RGB_wb = vector_dot(M, XYZ_wb);\n float3 RGB_wd = vector_dot(M, XYZ_wd);\n float3 RGB_wo = vector_dot(M, XYZ_wo);\n \n float3 D_RGB_b = D_b * (XYZ_wb.y / XYZ_wo.y) * (RGB_wo / RGB_wb) + 1 - D_b;\n float3 D_RGB_d = D_d * (XYZ_wd.y / XYZ_wo.y) * (RGB_wo / RGB_wd) + 1 - D_d;\n float3 D_RGB = D_RGB_b / D_RGB_d;\n \n float3 RGB_d = D_RGB * RGB_b;\n float3 XYZ_d = vector_dot(M.invert(), RGB_d);\n \n return XYZ_d;\n \}\n\n // apply chromatic adaptation transform to 'XYZ' from 'XYZ_ws' to 'XYZ_wd' white points\n // 'type' selects the cone fundamentals matrix (except for Zhai2018 which uses a 2-stage tranforms based on CATO2 fundamentals)\n // 'adaptDegree' sets the degree of adaptation for the Zhai2018 model\n float3 apply_CAT( float3 XYZ, float3 XYZ_ws, float3 XYZ_wd, int type, float adaptDegree )\n \{\n float3x3 XYZ_to_LMS;\n\n if( type == 1 )\n \{\n // XYZ Scaling\n XYZ_to_LMS = identity_matrix;\n \}\n else if( type == 2 )\n \{\n // Bradford\n XYZ_to_LMS = XYZ_to_LMS_Bradford;\n \}\n else if( type == 3 )\n \{\n // CAT02\n XYZ_to_LMS = XYZ_to_LMS_CAT02;\n \}\n else if( type == 4 )\n \{\n // Zhai2018\n return CAT_Zhai2018(XYZ, XYZ_ws, XYZ_wd, adaptDegree, adaptDegree, XYZ_to_LMS_CAT02);\n \}\n else\n \{\n // None\n return XYZ;\n \}\n\n float3 LMS_ws = vector_dot(XYZ_to_LMS, XYZ_ws);\n float3 LMS_wd = vector_dot(XYZ_to_LMS, XYZ_wd);\n\n // if(LMS_ws.x == 0.0f)\n // \{\n // LMS_ws.x = 0.000001f;\n // \}\n // if(LMS_ws.y == 0.0f)\n // \{\n // LMS_ws.y = 0.000001f;\n // \}\n // if(LMS_ws.z == 0.0f)\n // \{\n // LMS_ws.z = 0.000001f;\n // \}\n\n float3x3 Mscale = identity_matrix;\n Mscale\[0]\[0] = LMS_wd.x / LMS_ws.x;\n Mscale\[1]\[1] = LMS_wd.y / LMS_ws.y;\n Mscale\[2]\[2] = LMS_wd.z / LMS_ws.z;\n\n float3x3 M = XYZ_to_LMS.invert() * Mscale * XYZ_to_LMS;\n\n return vector_dot(M, XYZ);\n \}\n\n\n float3 post_adaptation_non_linear_response_compression_forward(float3 RGB, float F_L)\n \{\n // RGB = as_float_array(RGB)\n // F_L = as_float_array(F_L)\n \n float3 F_L_RGB = float3spow(F_L * float3abs(RGB) / 100.0f, 0.42f);\n float3 RGB_c = (400.0f * sign(RGB) * F_L_RGB) / (27.13f + F_L_RGB) + 0.1f;\n \n return RGB_c;\n \}\n\n \n float3 post_adaptation_non_linear_response_compression_inverse(float3 RGB,float F_L)\n \{\n // RGB = as_float_array(RGB)\n // F_L = as_float_array(F_L)\n\n\n // RGB_p = (\n // np.sign(RGB - 0.1)\n // * 100\n // / F_L\[..., np.newaxis]\n // * spow(\n // (27.13 * np.absolute(RGB - 0.1)) / (400 - np.absolute(RGB - 0.1)),\n // 1 / 0.42,\n // )\n // )\n\n\n // RGB_p = ( np.sign(RGB - 0.1) * 100 / F_L\[..., np.newaxis] * spow( (27.13 * np.absolute(RGB - 0.1)) / (400 - np.absolute(RGB - 0.1)), 1 / 0.42, ))\n\n // older compression formula subbed in\n // float3 RGB_p = float3sign(RGB) * 100.0f / F_L * float3spow((27.13f * float3abs(RGB)) / (400.0f - float3abs(RGB)), 1.0f / 0.42f);\n\n // float3 RGB_p = sign(RGB - 0.1f) * 100.0f / F_L * spow((27.13f * float3abs(RGB - 0.1f)) / (400.0f - float3abs(RGB - 0.1f)), 1.0f / 0.42f);\n float3 RGB_p = (float3sign(RGB - 0.1f) * 100.0f / F_L * float3spow((27.13f * float3abs(RGB - 0.1f)) / (400.0f - float3abs(RGB - 0.1f)), 1.0f / 0.42f) );\n // float3 RGB_p = float3sign(RGB) * 100.0f / F_L * float3spow((27.13f * float3abs(RGB)) / (400.0f - float3abs(RGB)), 1.0f / 0.42f);\n return RGB_p;\n \}\n\n\n // def d_post_adaptation_non_linear_response_compression_forward(\n // RGB: ArrayLike, F_L: FloatingOrArrayLike\n // ) -> NDArray:\n // F_L_RGB = spow(F_L\[..., np.newaxis] * RGB / 100, 0.42)\n // F_L_100 = spow(F_L\[..., np.newaxis] / 100, 0.42)\n \n // d_RGB_a = ( 400 * ((0.42 * 27.13) * spow(RGB, -0.58) * F_L_100) / (F_L_RGB + 27.13) ** 2 )\n \n // return d_RGB_a\n \n \n float3 d_post_adaptation_non_linear_response_compression_forward( float3 RGB, float F_L)\n \{\n float3 F_L_RGB = float3spow(F_L * RGB / 100.0f, 0.42f);\n float F_L_100 = spow(F_L / 100.0f, 0.42f);\n \n // float3 d_RGB_a = ( 400.0f * ((0.42f * 27.13f) * float3spow(RGB, -0.58f) * F_L_100)/ (F_L_RGB + 27.13f) ** 2.0f );\n float3 d_RGB_a = ( 400.0f * ((0.42f * 27.13f) * float3spow(RGB, -0.58f) * F_L_100)/ ( (F_L_RGB + 27.13f) * (F_L_RGB + 27.13f) ));\n // d_RGB_a = d_RGB_a * d_RGB_a;\n\n return d_RGB_a;\n \}\n\n // convert XYZ tristimulus values to the ZCAM intermediate Izazbz colorspace\n float3 XYZ_to_Izazbz( float3 XYZD65 )\n \{\n float3 XYZpD65 = XYZD65;\n XYZpD65.x = zcam_cb * XYZD65.x - (zcam_cb - 1.0f) * XYZD65.z;\n XYZpD65.y = zcam_cg * XYZD65.y - (zcam_cg - 1.0f) * XYZD65.x;\n float3 LMS = vector_dot(XYZ_to_LMS_ZCAM, XYZpD65);\n float3 LMSp = 0.0f;\n if (compressMode)\n \{\n LMS = compress(LMS);\n \}\n LMSp.x = spow( ( zcam_c1 + zcam_c2 * spow((LMS.x/10000.0f),zcam_eta) ) / ( 1.0f + zcam_c3 * spow((LMS.x/10000.0f),zcam_eta) ), zcam_rho);\n LMSp.y = spow( ( zcam_c1 + zcam_c2 * spow((LMS.y/10000.0f),zcam_eta) ) / ( 1.0f + zcam_c3 * spow((LMS.y/10000.0f),zcam_eta) ), zcam_rho);\n LMSp.z = spow( ( zcam_c1 + zcam_c2 * spow((LMS.z/10000.0f),zcam_eta) ) / ( 1.0f + zcam_c3 * spow((LMS.z/10000.0f),zcam_eta) ), zcam_rho);\n if (compressMode)\n \{\n LMSp = uncompress(LMSp);\n \}\n float3 Izazbz = vector_dot(LMS_to_Izazbz, LMSp);\n // return float3(LMS_to_Izazbz\[0]\[0], LMS_to_Izazbz\[0]\[1], LMS_to_Izazbz\[0]\[2]);\n return Izazbz;\n \}\n\n\n // convert the ZCAM intermediate Izazbz colorspace to XYZ tristimulus values\n float3 Izazbz_to_XYZ( float3 Izazbz )\n \{\n float3 LMSp = vector_dot(LMS_to_Izazbz.invert(), Izazbz);\n float3 LMS = 0.0f;\n if (compressMode)\n \{\n LMSp = compress(LMSp);\n \}\n LMS.x = 10000.0f*spow((zcam_c1-spow(LMSp.x,1.0f/zcam_rho)) / (zcam_c3*spow(LMSp.x,1.0f/zcam_rho)-zcam_c2),1.0f/zcam_eta);\n LMS.y = 10000.0f*spow((zcam_c1-spow(LMSp.y,1.0f/zcam_rho)) / (zcam_c3*spow(LMSp.y,1.0f/zcam_rho)-zcam_c2),1.0f/zcam_eta);\n LMS.z = 10000.0f*spow((zcam_c1-spow(LMSp.z,1.0f/zcam_rho)) / (zcam_c3*spow(LMSp.z,1.0f/zcam_rho)-zcam_c2),1.0f/zcam_eta);\n if (compressMode)\n \{\n LMS = uncompress(LMS);\n \}\n float3 XYZpD65 = vector_dot(XYZ_to_LMS_ZCAM.invert(), LMS);\n float3 XYZD65 = XYZpD65;\n XYZD65.x = (XYZpD65.x+(zcam_cb-1.0f)*XYZpD65.z)/zcam_cb;\n XYZD65.y = (XYZpD65.y+(zcam_cg-1.0f)*XYZD65.x)/zcam_cg;\n return XYZD65;\n \}\n\n\n // convert the ZCAM intermediate Izazbz colorspace to the ZCAM J (lightness), M (colorfulness) and h (hue) correlates\n // needs the Iz values of the reference white and the viewing conditions parameters\n float3 Izazbz_to_JMh( float3 Izazbz, float refWhiteIz, int viewingConditions )\n \{\n float3 JMh = 0.0f;\n float zcam_F_s = zcam_viewing_conditions_coeff;\n\n JMh.z = fmod(degrees(atan2(Izazbz.z,Izazbz.y))+360.0f,360.0f);\n float ez = 1.015f + cos(radians(89.038f+JMh.z));\n float Qz = 2700.0f * spow(Izazbz.x, (1.6f * zcam_F_s) / pow(zcam_F_b, 0.12f)) * pow(zcam_F_s, 2.2f) * pow(zcam_F_b, 0.5f) * pow(zcam_F_L, 0.2f);\n float Qzw = 2700.0f * spow(refWhiteIz, (1.6f * zcam_F_s) / pow(zcam_F_b, 0.12f)) * pow(zcam_F_s, 2.2f) * pow(zcam_F_b, 0.5f) * pow(zcam_F_L, 0.2f);\n JMh.x = 100.0f * (Qz / Qzw);\n JMh.y = 100.0f * spow((spow(Izazbz.y, 2.0f) + spow(Izazbz.z, 2.0f)), 0.37f) * ((spow(ez, 0.068f) * pow(zcam_F_L, 0.2f)) / (pow(zcam_F_b, 0.1f) * pow(refWhiteIz, 0.78f)));\n\n return JMh;\n // return float3(Qz, Qzw, JMh.z);\n \}\n\n\n // convert the ZCAM J (lightness), M (colorfulness) and h (hue) correlates to the ZCAM intermediate Izazbz colorspace\n // needs the Iz values of the reference white and the viewing conditions parameters\n float3 JMh_to_Izazbz( float3 JMh, float refWhiteIz, int viewingConditions )\n \{\n float zcam_F_s = zcam_viewing_conditions_coeff;\n float Qzm = spow(zcam_F_s, 2.2f) * spow(zcam_F_b, 0.5f) * spow(zcam_F_L, 0.2f);\n float Qzw = 2700.0f * spow(refWhiteIz, (1.6f * zcam_F_s) / spow(zcam_F_b, 0.12f)) * Qzm;\n float Izp = spow(zcam_F_b, 0.12f) / (1.6f * zcam_F_s);\n float Izd = 2700.0f * 100.0f * Qzm;\n float ez = 1.015f + cos(radians(89.038f+JMh.z));\n float hzr = radians(JMh.z);\n float Czp = spow((JMh.y * spow(refWhiteIz, 0.78f) * spow(zcam_F_b, 0.1f)) / (100.0f * spow(ez, 0.068f) * spow(zcam_F_L, 0.2f)), 50.0f / 37.0f);\n\n return float3( spow((JMh.x * Qzw) / Izd, Izp), Czp * cos(hzr), Czp * sin(hzr));\n \}\n\n\n // convert XYZ tristimulus values to the ZCAM J (lightness), M (colorfulness) and h (hue) correlates\n // needs XYZ tristimulus values for the reference white and a D65 white as well as the viewing conditions as parameters\n float3 XYZ_to_JMh( float3 XYZ, float3 referenceWhite, float3 d65White, int viewingConditions , float L_A, float Y_b, bool discountIlluminant, bool HK_mode)\n \{\n\n if ( camMode == 0 )\n \{\n float3 refWhiteIzazbz = XYZ_to_Izazbz(referenceWhite*referenceLuminance/referenceWhite.y);\n return Izazbz_to_JMh(XYZ_to_Izazbz(apply_CAT(XYZ, referenceWhite, d65White, catType, cat_adaptDegree)), refWhiteIzazbz.x, viewingConditions);\n \}\n else if( camMode == 1 )\n \{\n // return float3(1.0f,2.0f,3.0f);\n // return XYZ_to_Hellwig2022_JMh(apply_CAT(XYZ, refWhite, d65White, catType, cat_adaptDegree), XYZ_w, L_A, Y_b,viewingConditionsToSurround(viewingConditions),discountIlluminant);\n return XYZ_to_Hellwig2022_JMh(XYZ, referenceWhite, L_A, Y_b,viewingConditionsToSurround(viewingConditions),discountIlluminant,HK_mode);\n // return XYZ_to_Hellwig2022_JMh(XYZ, XYZ_w, L_A, Y_b,viewingConditionsToSurround(viewingConditions),discountIlluminant);\n \}\n \}\n\n\n // convert the ZCAM J (lightness), M (colorfulness) and h (hue) correlates to XYZ tristimulus values\n // needs XYZ tristimulus values for the reference white and a D65 white as well as the viewing conditions as parameters\n float3 JMh_to_XYZ( float3 JMh, float3 referenceWhite, float3 d65White, int viewingConditions , float L_A, float Y_b, bool discountIlluminant, bool HK_mode)\n \{\n float3 XYZ;\n if ( camMode == 0 )\n \{\n float3 refWhiteIzazbz = XYZ_to_Izazbz(referenceWhite*referenceLuminance/referenceWhite.y);\n XYZ = apply_CAT(Izazbz_to_XYZ(JMh_to_Izazbz(JMh, refWhiteIzazbz.x, viewingConditions)), d65White, referenceWhite, catType, cat_adaptDegree);\n \}\n else if( camMode == 1 )\n \{\n // return float3(1.0f,2.0f,3.0f);\n // XYZ = apply_CAT(Hellwig2022_JMh_to_XYZ(JMh, XYZ_w, L_A, Y_b, viewingConditionsToSurround(viewingConditions), discountIlluminant), d65White, refWhite, catType, cat_adaptDegree);\n XYZ = Hellwig2022_JMh_to_XYZ(JMh, referenceWhite, L_A, Y_b, viewingConditionsToSurround(viewingConditions), discountIlluminant,HK_mode);\n // XYZ = Hellwig2022_JMh_to_XYZ(JMh, XYZ_w, L_A, Y_b, viewingConditionsToSurround(viewingConditions), discountIlluminant);\n \}\n return XYZ;\n \}\n\n\n // check if the 3D point 'v' is inside a cube with the dimensions cubeSize x cubeSize x cubeSize \n // the 'smoothing' parameter rounds off the edges and corners of the cube with the exception of the 0,0,0 and cubeSize x cubeSize x cubeSize corners\n // a smoothing value of 0.0 applies no smoothing and 1.0 the maximum amount (smoothing values > 1.0 result in undefined behavior )\n int isInsideCube( float3 v, float cubeSize, float smoothing)\n \{\n float3 normv = v / cubeSize;\n\n float minv = min(normv.x, min(normv.y, normv.z));\n float maxv = max(normv.x, max(normv.y, normv.z));\n\n if( smoothing <= 0.0f )\n \{\n // when not smoothing we can use a much simpler test\n if(minv < 0.0f || maxv > 1.0f)\n \{\n return 0;\n \}\n\n return 1;\n \}\n\n float3 clamped = normv;\n\n float radius = smoothing/2.0f;\n\n radius = clamp(radius*maxv*(1.0f-minv), 0.0f, radius);\n\n clamped.x = clamp(normv.x, radius, 1.0f-radius);\n clamped.y = clamp(normv.y, radius, 1.0f-radius);\n clamped.z = clamp(normv.z, radius, 1.0f-radius);\n\n\n if( length(normv - clamped ) > radius)\n \{\n return 0;\n \}\n\n return 1;\n \}\n\n // convert ACEScct encoded values to linear\n float ACEScct_to_linear( float v )\n \{\n return v > 0.155251141552511f ? spow( 2.0f, v * 17.52f - 9.72f) : (v - 0.0729055341958355f) / 10.5402377416545f;\n \}\n\n // encode linear values as ACEScct\n float linear_to_ACEScct( float v )\n \{\n return v > 0.0078125f ? (log2(v) + 9.72f) / 17.52f : 10.5402377416545f * v + 0.0729055341958355f;\n \}\n\n\n // convert sRGB gamma encoded values to linear\n float sRGB_to_linear( float v )\n \{\n return v < 0.04045f ? v / 12.92f : spow((v + 0.055f) / 1.055f, 2.4f);\n \}\n\n // encode linear values as sRGB gamma\n float linear_to_sRGB( float v )\n \{\n return v <= 0.0031308f ? 12.92f * v : 1.055 * (spow(v, 1.0f / 2.4f)) - 0.055f;\n \}\n\n // convert ST2084 PQ encoded values to linear\n float ST2084_to_linear( float v )\n \{\n float V_p = spow(v, st2084_m_2_d);\n return spow((max(0.0f, V_p - st2084_c_1) / (st2084_c_2 - st2084_c_3 * V_p)), st2084_m_1_d)*st2084_L_p;\n \}\n\n // encode linear values as ST2084 PQ\n float linear_to_ST2084( float v )\n \{\n float Y_p = spow(max(0.0f, v) / st2084_L_p, st2084_m_1);\n\n return spow((st2084_c_1 + st2084_c_2 * Y_p) / (st2084_c_3 * Y_p + 1.0f), st2084_m_2);\n \}\n\n // decode value 'v' with the inverse of the selected encoding fuction to luminance\n float encodingToLuminance(int encoding, float v)\n \{\n if( encoding == 1 )\n \{\n // ACEScct\n return ACEScct_to_linear(v) * referenceLuminance;\n \}\n else if( encoding == 2 )\n \{\n // sRGB\n return sRGB_to_linear(v) * referenceLuminance;\n \}\n else if( encoding == 3 )\n \{\n // BT.1886 (Gamma 2.4)\n return spow(v, 2.4f) * referenceLuminance;\n \}\n else if( encoding == 4 )\n \{\n // Gamma 2.6\n return spow(v, 2.6f) * referenceLuminance;\n \}\n else if( encoding == 5 )\n \{\n // ST2084\n return ST2084_to_linear(v);\n \}\n else\n \{\n // Linear\n // default\n return v * referenceLuminance;\n \}\n \}\n\n // decode the components of a 3D vector 'v' with the inverse of the selected encoding fuction to luminance\n float3 encodingToLuminance3(int encoding, float3 v)\n \{\n float3 lin;\n lin.x = encodingToLuminance(encoding, v.x);\n lin.y = encodingToLuminance(encoding, v.y);\n lin.z = encodingToLuminance(encoding, v.z);\n\n return lin;\n \}\n\n // encode the linear luminance value 'v' with the encoding fuction selected by 'encoding'\n float luminanceToEncoding(int encoding, float v)\n \{\n if( encoding == 1 )\n \{\n // ACEScct\n return linear_to_ACEScct(v / referenceLuminance);\n \}\n else if( encoding == 2 )\n \{\n // sRGB\n return linear_to_sRGB(v / referenceLuminance);\n \}\n else if( encoding == 3 )\n \{\n // BT.1886 (Gamma 2.4)\n return spow(v / referenceLuminance, 1.0f/2.4f);\n \}\n else if( encoding == 4 )\n \{\n // Gamma 2.6\n return spow(v / referenceLuminance, 1.0f/2.6f);\n \}\n else if( encoding == 5 )\n \{\n // ST2084\n return linear_to_ST2084(v);\n \}\n else\n \{\n // Linear\n // default\n return v / referenceLuminance;\n \}\n \}\n\n // encode the linear luminance value components of a 3D vector 'v' with the encoding fuction selected by 'encoding'\n float3 luminanceToEncoding3(int encoding, float3 v)\n \{\n float3 enc;\n enc.x = luminanceToEncoding(encoding, v.x);\n enc.y = luminanceToEncoding(encoding, v.y);\n enc.z = luminanceToEncoding(encoding, v.z);\n\n return enc;\n \}\n\n\n // convert RGB values in the input colorspace to the ZCAM intermediate Izazbz colorspace\n float3 input_RGB_to_Izazbz(float3 inputRGB)\n \{\n // clamp input to +/- HALF_MAX range (to remove inf values, etc.)\n inputRGB = clamp3(inputRGB, -HALF_MAX, HALF_MAX);\n\n // convert to linear XYZ luminance values\n float3 luminanceRGB = encodingToLuminance3( encodingIn, inputRGB);\n float3 luminanceXYZ = vector_dot(RGB_to_XYZ_input, luminanceRGB);\n\n // assuming 'fully adapted', dark' viewing conditions for input image (does that make sense?)\n return XYZ_to_Izazbz(apply_CAT(luminanceXYZ, inWhite, d65White, catType, 1.0f));\n // return apply_CAT(luminanceXYZ, inWhite, d65White, catType, 1.0f);\n \}\n\n\n // convert values in the ZCAM intermediate Izazbz colorspace to RGB values in the input colorspace\n float3 Izazbz_to_input_RGB(float3 Izazbz)\n \{\n float3 luminanceXYZ = Izazbz_to_XYZ(Izazbz);\n luminanceXYZ = apply_CAT(luminanceXYZ, d65White, inWhite, catType, 1.0f);\n float3 luminanceRGB = vector_dot(XYZ_to_RGB_input, luminanceXYZ);\n float3 RGB = luminanceToEncoding3(encodingIn, luminanceRGB);\n return RGB;\n \}\n\n // convert RGB values in the output colorspace to the ZCAM J (lightness), M (colorfulness) and h (hue) correlates\n float3 output_RGB_to_JMh(float3 RGB)\n \{\n float3 luminanceRGB = encodingToLuminance3(encodingOut, RGB);\n float3 XYZ = vector_dot(RGB_to_XYZ_output, luminanceRGB);\n float3 JMh = XYZ_to_JMh(XYZ, limitWhite, d65White, viewingConditions, L_A_out, Y_b_out, discountIlluminant_out,HK_mode_out);\n return JMh;\n \}\n\n // convert RGB values in the output colorspace to the ZCAM J (lightness), M (colorfulness) and h (hue) correlates\n float3 luminance_RGB_to_JMh(float3 luminanceRGB)\n \{\n // float3 luminanceRGB = encodingToLuminance3(encodingOut, RGB);\n float3 XYZ = vector_dot(RGB_to_XYZ_output, luminanceRGB);\n float3 JMh = XYZ_to_JMh(XYZ, refWhite, d65White, outputViewingConditions, L_A, Y_b, discountIlluminant_mid, HK_mode_mid);\n return JMh;\n \}\n\n\n // convert ZCAM J (lightness), M (colorfulness) and h (hue) correlates to RGB values in the output colorspace\n float3 JMh_to_output_RGB(float3 JMh)\n \{\n float3 luminanceXYZ = JMh_to_XYZ( JMh, limitWhite, d65White, outputViewingConditions , L_A_out, Y_b_out, discountIlluminant_out, HK_mode_out);\n float3 luminanceRGB = vector_dot(XYZ_to_RGB_output, luminanceXYZ);\n float3 outputRGB = luminanceToEncoding3( encodingOut, luminanceRGB);\n\n if( clampOutput )\n \{\n outputRGB = clamp3(outputRGB, 0.0f, 1.0f);\n \}\n\n return outputRGB;\n \}\n\n // convert ZCAM J (lightness), M (colorfulness) and h (hue) correlates to RGB values in the output colorspace\n float3 JMh_to_luminance_RGB(float3 JMh)\n \{\n float3 luminanceXYZ = JMh_to_XYZ( JMh, refWhite, d65White, outputViewingConditions , L_A, Y_b, discountIlluminant_mid, HK_mode_mid);\n float3 luminanceRGB = vector_dot(XYZ_to_RGB_output, luminanceXYZ);\n // float3 outputRGB = luminanceToEncoding3( encodingOut, luminanceRGB);\n\n return luminanceRGB;\n \}\n\n\n // convert linear RGB values with the limiting primaries to ZCAM J (lightness), M (colorfulness) and h (hue) correlates\n float3 limit_RGB_to_JMh(float3 RGB)\n \{\n float3 luminanceRGB = RGB * boundaryRGB *referenceLuminance;\n float3 XYZ = vector_dot(RGB_to_XYZ_limit, luminanceRGB);\n float3 JMh = XYZ_to_JMh(XYZ, refWhite, d65White, viewingConditions, L_A, Y_b, discountIlluminant_mid, HK_mode_mid);\n return JMh;\n \}\n\n\n // convert ZCAM J (lightness), M (colorfulness) and h (hue) correlates to linear RGB values with the limiting primaries\n float3 JMh_to_limit_RGB(float3 JMh)\n \{\n float3 luminanceXYZ = JMh_to_XYZ( JMh, refWhite, d65White, viewingConditions, L_A, Y_b, discountIlluminant_mid, HK_mode_mid );\n float3 luminanceRGB = vector_dot(XYZ_to_RGB_output, luminanceXYZ);\n float3 RGB = luminanceRGB / boundaryRGB / referenceLuminance;\n return RGB;\n \}\n\n float3 XYZ_to_Hellwig2022_JMh( float3 XYZ, float3 XYZ_w, float L_A, float Y_b, float3 surround, bool discountIlluminant, bool HK_mode)\n \{\n // \"\"\"\n // Compute the *Hellwig and Fairchild (2022)* colour appearance model\n // correlates from given *CIE XYZ* tristimulus values.\n\n // Parameters\n // ----------\n // XYZ\n // *CIE XYZ* tristimulus values of test sample / stimulus.\n // XYZ_w\n // *CIE XYZ* tristimulus values of reference white.\n // L_A\n // Adapting field *luminance* :math:`L_A` in :math:`cd/m^2`, (often taken\n // to be 20% of the luminance of a white object in the scene).\n // Y_b\n // Luminous factor of background :math:`Y_b` such as\n // :math:`Y_b = 100 x L_b / L_w` where :math:`L_w` is the luminance of the\n // light source and :math:`L_b` is the luminance of the background. For\n // viewing images, :math:`Y_b` can be the average :math:`Y` value for the\n // pixels in the entire image, or frequently, a :math:`Y` value of 20,\n // approximate an :math:`L^*` of 50 is used.\n // surround\n // Surround viewing conditions induction factors.\n // discount_illuminant\n // Truth value indicating if the illuminant should be discounted.\n\n // Returns\n // -------\n // :class:`colour.CAM_Specification_Hellwig2022`\n // *Hellwig and Fairchild (2022)* colour appearance model specification.\n\n // Notes\n // -----\n // +------------+-----------------------+---------------+\n // | **Domain** | **Scale - Reference** | **Scale - 1** |\n // +============+=======================+===============+\n // | ``XYZ`` | \[0, 100] | \[0, 1] |\n // +------------+-----------------------+---------------+\n // | ``XYZ_w`` | \[0, 100] | \[0, 1] |\n // +------------+-----------------------+---------------+\n\n // +-------------------------------------+-----------------------+-----------\\\n // ----+\n // | **Range** | **Scale - Reference** | **Scale - \\\n // 1** |\n // +=====================================+=======================+===========\\\n // ====+\n // | ``CAM_Specification_Hellwig2022.J`` | \[0, 100] | \[0, 1] \\\n // |\n // +-------------------------------------+-----------------------+-----------\\\n // ----+\n // | ``CAM_Specification_Hellwig2022.C`` | \[0, 100] | \[0, 1] \\\n // |\n // +-------------------------------------+-----------------------+-----------\\\n // ----+\n // | ``CAM_Specification_Hellwig2022.h`` | \[0, 360] | \[0, 1] \\\n // |\n // +-------------------------------------+-----------------------+-----------\\\n // ----+\n // | ``CAM_Specification_Hellwig2022.s`` | \[0, 100] | \[0, 1] \\\n // |\n // +-------------------------------------+-----------------------+-----------\\\n // ----+\n // | ``CAM_Specification_Hellwig2022.Q`` | \[0, 100] | \[0, 1] \\\n // |\n // +-------------------------------------+-----------------------+-----------\\\n // ----+\n // | ``CAM_Specification_Hellwig2022.M`` | \[0, 100] | \[0, 1] \\\n // |\n // +-------------------------------------+-----------------------+-----------\\\n // ----+\n // | ``CAM_Specification_Hellwig2022.H`` | \[0, 400] | \[0, 1] \\\n // |\n // +-------------------------------------+-----------------------+-----------\\\n // ----+\n\n // References\n // ----------\n // :cite:`Fairchild2022`, :cite:`Hellwig2022`\n\n // Examples\n // --------\n // >>> XYZ = np.array(\[19.01, 20.00, 21.78])\n // >>> XYZ_w = np.array(\[95.05, 100.00, 108.88])\n // >>> L_A = 318.31\n // >>> Y_b = 20.0\n // >>> surround = VIEWING_CONDITIONS_Hellwig2022\['Average']\n // >>> XYZ_to_Hellwig2022(XYZ, XYZ_w, L_A, Y_b, surround)\n // ... # doctest: +ELLIPSIS\n // CAM_Specification_Hellwig2022(J=41.7312079..., C=0.0257636..., \\\n // h=217.0679597..., s=0.0608550..., Q=55.8523226..., M=0.0339889..., \\\n // H=275.5949861..., HC=None)\n // \"\"\"\n\n\n XYZ = float3_to_domain_100(XYZ);\n XYZ_w = float3_to_domain_100(XYZ_w) * XYZ_w_scaler;\n float _X_w = XYZ_w.x ;\n float Y_w = XYZ_w.y ;\n float _Z_w = XYZ_w.z ;\n // L_A = as_float_array(L_A)\n // Y_b = as_float_array(Y_b)\n\n // # Step 0\n // # Converting *CIE XYZ* tristimulus values to sharpened *RGB* values.\n float3x3 MATRIX_16 = CAT_CAT16;\n float3 RGB_w = vector_dot(MATRIX_16, XYZ_w);\n\n // # Computing degree of adaptation :math:`D`.\n float D = clip(degree_of_adaptation(surround.x, L_A), 0, 1);\n if(discountIlluminant)\n \{\n D = 1.0f;\n \}\n\n\n // # Viewing conditions dependent parameters\n float k = 1 / (5 * L_A + 1);\n float k4 = pow(k,4);\n float F_L = 0.2f * k4 * (5.0f * L_A) + 0.1f * pow((1.0f - k4), 2.0f) * spow(5.0f * L_A, 1.0f / 3.0f) ;\n float n = sdiv(Y_b, Y_w);\n float z = 1.48 + sqrt(n);\n\n // // float D_RGB = ( D\[..., np.newaxis] * Y_w\[..., np.newaxis] / RGB_w + 1 - D\[..., np.newaxis] )\n float3 D_RGB = D * Y_w / RGB_w + 1 - D;\n float3 RGB_wc = D_RGB * RGB_w;\n \n // # Applying forward post-adaptation non-linear response compression.\n // F_L_RGB = spow(F_L\[..., np.newaxis] * np.absolute(RGB_wc) / 100, 0.42)\n float3 F_L_RGB = float3spow(F_L * float3abs(RGB_wc) / 100.0f, 0.42f);\n\n // # Computing achromatic responses for the whitepoint.\n // RGB_aw = (400 * np.sign(RGB_wc) * F_L_RGB) / (27.13 + F_L_RGB) + 0.1\n float3 RGB_aw = (400.0f * float3sign(RGB_wc) * F_L_RGB) / (27.13f + F_L_RGB) + 0.1f;\n \n\n // # Computing achromatic responses for the whitepoint.\n // R_aw, G_aw, B_aw = tsplit(RGB_aw)\n float R_aw = RGB_aw.x ;\n float G_aw = RGB_aw.y ;\n float B_aw = RGB_aw.z ;\n // A_w = 2 * R_aw + G_aw + 0.05 * B_aw - 0.305\n float A_w = 2 * R_aw + G_aw + 0.05f * B_aw - 0.305f;\n\n // # Step 1\n // # Converting *CIE XYZ* tristimulus values to sharpened *RGB* values.\n // RGB = vector_dot(MATRIX_16, XYZ)\n\n float3 RGB = vector_dot(MATRIX_16, XYZ);\n // float3 RGB = XYZ;\n\n // # Step 2\n // RGB_c = D_RGB * RGB\n float3 RGB_c = D_RGB * RGB;\n\n // # Step 3\n // # Applying forward post-adaptation non-linear response compression.\n // // F_L_RGB = spow(F_L\[..., np.newaxis] * np.absolute(RGB_c) / 100, 0.42)\n // float3 F_L_RGB_2 = float3spow(F_L * float3abs(RGB_c) / 100.0f, 0.42f);\n // // RGB_a = (400 * np.sign(RGB_c) * F_L_RGB) / (27.13 + F_L_RGB) + 0.1\n // float3 RGB_a = (400.0f * float3sign(RGB_c) * F_L_RGB_2) / (27.13f + F_L_RGB_2) + 0.1f;\n\n\n // # Step 3\n // # Applying forward post-adaptation non-linear response compression.\n // RGB_a = post_adaptation_non_linear_response_compression_forward(RGB_c, F_L)\n // RGB_a_l = d_post_adaptation_non_linear_response_compression_forward(\n // full(3, L_B), F_L\n // ) * (\n // RGB_c - L_B\n // ) + post_adaptation_non_linear_response_compression_forward(\n // full(3, L_B), F_L\n // )\n // RGB_a = np.where(RGB_c < L_B, RGB_a_l, RGB_a)\n\n\n if (compressMode)\n \{\n RGB_c = compress(RGB_c);\n \}\n\n float3 RGB_a = post_adaptation_non_linear_response_compression_forward(RGB_c, F_L);\n\n if (compressMode)\n \{\n RGB_a = uncompress(RGB_a);\n \}\n\n\n // # Step 3\n // # Applying forward post-adaptation non-linear response compression.\n // float3 RGB_a = RGB_c;\n // float3 RGB_a_l = d_post_adaptation_non_linear_response_compression_forward(L_B, F_L) * ( RGB_c - L_B) + post_adaptation_non_linear_response_compression_forward( L_B, F_L );\n if (linear_extension)\n \{\n\n float3 RGB_a_l = d_post_adaptation_non_linear_response_compression_forward(\n L_B, F_L\n ) * (\n RGB_c - L_B\n ) + post_adaptation_non_linear_response_compression_forward(\n L_B, F_L\n );\n \n // float3 RGB_d;\n RGB_a.x = RGB_c.x < L_B.x ? RGB_a_l.x: RGB_a.x;\n RGB_a.y = RGB_c.y < L_B.y ? RGB_a_l.y: RGB_a.y;\n RGB_a.z = RGB_c.z < L_B.z ? RGB_a_l.z: RGB_a.z; \n \}\n\n\n\n // # Step 4\n // # Converting to preliminary cartesian coordinates.\n // R_a, G_a, B_a = tsplit(RGB_a)\n float R_a = RGB_a.x ;\n float G_a = RGB_a.y ;\n float B_a = RGB_a.z ;\n // a = R_a - 12 * G_a / 11 + B_a / 11\n float a = R_a - 12.0f * G_a / 11.0f + B_a / 11.0f;\n // b = (R_a + G_a - 2 * B_a) / 9\n float b = (R_a + G_a - 2.0f * B_a) / 9.0f;\n\n // # Computing the *hue* angle :math:`h`.\n // h = np.degrees(np.arctan2(b, a)) % 360\n // Unclear why this isnt matching the python version.\n float h = mod(degrees(atan2(b, a)), 360.0f);\n\n \n\n // # Step 5\n // # Computing eccentricity factor *e_t*.\n // hr = np.radians(h)\n float hr = radians(h);\n\n // _h = hr\n // _2_h = 2 * hr\n // _3_h = 3 * hr\n // _4_h = 4 * hr\n float _h = hr;\n float _2_h = 2 * hr;\n float _3_h = 3 * hr;\n float _4_h = 4 * hr;\n\n // e_t = (\n // -0.0582 * np.cos(_h)\n // - 0.0258 * np.cos(_2_h)\n // - 0.1347 * np.cos(_3_h)\n // + 0.0289 * np.cos(_4_h)\n // - 0.1475 * np.sin(_h)\n // - 0.0308 * np.sin(_2_h)\n // + 0.0385 * np.sin(_3_h)\n // + 0.0096 * np.sin(_4_h)\n // + 1\n // )\n float e_t = (\n -0.0582f * cos(_h)\n - 0.0258f * cos(_2_h)\n - 0.1347f * cos(_3_h)\n + 0.0289f * cos(_4_h)\n - 0.1475f * sin(_h)\n - 0.0308f * sin(_2_h)\n + 0.0385f * sin(_3_h)\n + 0.0096f * sin(_4_h)\n + 1.0f\n );\n\n // # Step 6\n // # Computing achromatic responses for the stimulus.\n // R_a, G_a, B_a = tsplit(RGB_a)\n float R_a2 = RGB_a.x ;\n float G_a2 = RGB_a.y ;\n float B_a2 = RGB_a.z ;\n // A = 2 * R_a + G_a + 0.05 * B_a - 0.305\n float A = 2 * R_a2 + G_a2 + 0.05f * B_a2 - 0.305f;\n\n // # Step 7\n // # Computing the correlate of *Lightness* :math:`J`.\n // with sdiv_mode():\n // J = 100 * spow(sdiv(A, A_w), surround.c * z)\n\n float J = 100.0f * spow(sdiv(A, A_w), surround.y * z);\n\n // # Step 8\n // # Computing the correlate of *brightness* :math:`Q`.\n // with sdiv_mode():\n // Q = (2 / as_float(surround.c)) * (J / 100) * A_w\n float Q = (2.0f / float(surround.y)) * (J / 100.0f) * A_w;\n\n // # Step 9\n // # Computing the correlate of *colourfulness* :math:`M`.\n // M = 43 * surround.N_c * e_t * np.sqrt(a**2 + b**2)\n float M = 43.0f * surround.z * e_t * sqrt(a * a + b * b);\n\n // # Computing the correlate of *chroma* :math:`C`.\n // with sdiv_mode():\n // C = 35 * sdiv(M, A_w)\n float C = 35.0f * sdiv(M, A_w);\n\n\n // # Computing the correlate of *saturation* :math:`s`.\n // with sdiv_mode():\n // s = 100 * sdiv(M, Q)\n float s = 100.0f * sdiv(M, Q);\n\n // # *Helmholtz–Kohlrausch* Effect Extension.\n float J_HK = J + hue_angle_dependency_Hellwig2022(hr) * spow(C, 0.587f);\n float Q_HK = (2.0f / surround.y) * (J_HK / 100.0f) * A_w ;\n \n // return XYZ_w;\n // return RGB_w;\n // return \{D,k,k4\};\n // return \{F_L,n,z\};\n // return RGB_c;\n if (HK_mode)\n \{\n return \{J_HK,M,h\};\n \}\n else\n \{\n return \{J,M,h\};\n \}\n // return XYZ;\n \}\n\n float3 Hellwig2022_JMh_to_XYZ( float3 JMh, float3 XYZ_w, float L_A, float Y_b, float3 surround, bool discountIlluminant, bool HK_mode)\n \{\n float J = JMh.x;\n float M = JMh.y;\n float h = JMh.z;\n XYZ_w = XYZ_w * XYZ_w_scaler;\n \n\n\n // L_A = as_float_array(L_A)\n // XYZ_w = to_domain_100(XYZ_w)\n // _X_w, Y_w, _Z_w = tsplit(XYZ_w)\n float _X_w = XYZ_w.x;\n float Y_w = XYZ_w.y;\n float _Z_w = XYZ_w.z;\n\n // # Step 0\n // # Converting *CIE XYZ* tristimulus values to sharpened *RGB* values.\n // RGB_w = vector_dot(MATRIX_16, XYZ_w)\n float3x3 MATRIX_16 = CAT_CAT16;\n float3 RGB_w = vector_dot(MATRIX_16, XYZ_w);\n\n\n // # Computing degree of adaptation :math:`D`.\n float D = clip(degree_of_adaptation(surround.x, L_A), 0, 1);\n if(discountIlluminant)\n \{\n D = 1.0f;\n \}\n\n\n\n // # Viewing conditions dependent parameters\n float k = 1 / (5 * L_A + 1);\n float k4 = pow(k,4);\n float F_L = 0.2f * k4 * (5.0f * L_A) + 0.1f * pow((1.0f - k4), 2.0f) * spow(5.0f * L_A, 1.0f / 3.0f) ;\n float n = sdiv(Y_b, Y_w);\n float z = 1.48 + sqrt(n);\n\n // // float D_RGB = ( D\[..., np.newaxis] * Y_w\[..., np.newaxis] / RGB_w + 1 - D\[..., np.newaxis] )\n float3 D_RGB = D * Y_w / RGB_w + 1 - D;\n float3 RGB_wc = D_RGB * RGB_w;\n \n // # Applying forward post-adaptation non-linear response compression.\n // F_L_RGB = spow(F_L\[..., np.newaxis] * np.absolute(RGB_wc) / 100, 0.42)\n float3 F_L_RGB = float3spow(F_L * float3abs(RGB_wc) / 100.0f, 0.42f);\n\n // # Computing achromatic responses for the whitepoint.\n // RGB_aw = (400 * np.sign(RGB_wc) * F_L_RGB) / (27.13 + F_L_RGB) + 0.1\n float3 RGB_aw = (400.0f * float3sign(RGB_wc) * F_L_RGB) / (27.13f + F_L_RGB) + 0.1f;\n\n // # Computing achromatic responses for the whitepoint.\n // R_aw, G_aw, B_aw = tsplit(RGB_aw)\n float R_aw = RGB_aw.x ;\n float G_aw = RGB_aw.y ;\n float B_aw = RGB_aw.z ;\n // A_w = 2 * R_aw + G_aw + 0.05 * B_aw - 0.305\n float A_w = 2 * R_aw + G_aw + 0.05f * B_aw - 0.305f;\n\n // # Step 2\n // # Computing eccentricity factor *e_t*.\n // hr = np.radians(h)\n float hr = radians(h);\n\n\n // # *Helmholtz–Kohlrausch* Effect Extension.\n float C = (M * 35) / A_w;\n \n if (HK_mode)\n \{\n J = J - hue_angle_dependency_Hellwig2022(hr) * spow(C, 0.587f);\n \}\n\n\n\n // _h = hr\n // _2_h = 2 * hr\n // _3_h = 3 * hr\n // _4_h = 4 * hr\n float _h = hr;\n float _2_h = 2 * hr;\n float _3_h = 3 * hr;\n float _4_h = 4 * hr;\n \n // e_t = (\n // -0.0582 * np.cos(_h)\n // - 0.0258 * np.cos(_2_h)\n // - 0.1347 * np.cos(_3_h)\n // + 0.0289 * np.cos(_4_h)\n // - 0.1475 * np.sin(_h)\n // - 0.0308 * np.sin(_2_h)\n // + 0.0385 * np.sin(_3_h)\n // + 0.0096 * np.sin(_4_h)\n // + 1\n // )\n float e_t = (\n -0.0582f * cos(_h)\n - 0.0258f * cos(_2_h)\n - 0.1347f * cos(_3_h)\n + 0.0289f * cos(_4_h)\n - 0.1475f * sin(_h)\n - 0.0308f * sin(_2_h)\n + 0.0385f * sin(_3_h)\n + 0.0096f * sin(_4_h)\n + 1.0f\n );\n\n // # Computing achromatic response :math:`A` for the stimulus.\n // A = A = A_w * spow(J / 100, 1 / (surround.c * z))\n float A = A_w * spow(J / 100.0f, 1.0f / (surround.y * z));\n\n // # Computing *P_p_1* to *P_p_2*.\n // P_p_1 = 43 * surround.N_c * e_t\n // P_p_2 = A\n float P_p_1 = 43.0f * surround.z * e_t;\n float P_p_2 = A;\n\n\n // # Step 3\n // # Computing opponent colour dimensions :math:`a` and :math:`b`.\n // with sdiv_mode():\n // gamma = M / P_p_1\n float gamma = M / P_p_1;\n \n // a = gamma * np.cos(hr)\n float a = gamma * cos(hr);\n // b = gamma * np.sin(hr)\n float b = gamma * sin(hr);\n\n\n // # Step 4\n // # Applying post-adaptation non-linear response compression matrix.\n // RGB_a = (\n // vector_dot(\n // \[\n // \[460, 451, 288],\n // \[460, -891, -261],\n // \[460, -220, -6300],\n // ],\n // tstack(\[P_p_2, a, b]),\n // )\n // / 1403\n // )\n\n float3 RGB_a = vector_dot(panlrcm, float3(P_p_2, a, b)) / 1403.0f;\n\n // # Step 5\n // # Applying inverse post-adaptation non-linear response compression.\n // RGB_c = (\n // np.sign(RGB_a)\n // * 100\n // / F_L\[..., np.newaxis]\n // * spow(\n // (27.13 * np.absolute(RGB_a)) / (400 - np.absolute(RGB_a)),\n // 1 / 0.42,\n // )\n // )\n // float3 RGB_c = float3sign(RGB_a) * 100.0f / F_L * float3spow((27.13f * float3abs(RGB_a)) / (400.0f - float3abs(RGB_a)), 1.0f / 0.42f);\n\n\n // # Step 5\n // # Applying inverse post-adaptation non-linear response compression.\n // RGB_c = post_adaptation_non_linear_response_compression_inverse(RGB_a, F_L)\n // RGB_c_l = (\n // RGB_a\n // - post_adaptation_non_linear_response_compression_forward(\n // full(3, L_B), F_L\n // )\n // ) / (\n // d_post_adaptation_non_linear_response_compression_forward(\n // full(3, L_B), F_L\n // )\n // ) + L_B\n // RGB_c = np.where(RGB_c < L_B, RGB_c_l, RGB_c)\n\n // Adding 0.1 here seems to fix the inversion issue, not really clear on why I'm needing to do this\n // RGB_a = RGB_a + 0.1f;\n if (compressMode)\n \{\n RGB_a = compress(RGB_a);\n \}\n\n float3 RGB_c = post_adaptation_non_linear_response_compression_inverse(RGB_a + 0.1, F_L);\n\n if (compressMode)\n \{\n RGB_c = uncompress(RGB_c);\n \}\n\n // float3 RGB_c = RGB_a;\n if (linear_extension)\n \{\n float3 RGB_c_l = ( RGB_a + 0.1 - post_adaptation_non_linear_response_compression_forward( L_B, F_L)) / (d_post_adaptation_non_linear_response_compression_forward( L_B, F_L)) + L_B;\n \n // float3 RGB_d;\n RGB_c.x = RGB_c.x < L_B.x ? RGB_c_l.x : RGB_c.x;\n RGB_c.y = RGB_c.y < L_B.y ? RGB_c_l.y : RGB_c.y;\n RGB_c.z = RGB_c.z < L_B.z ? RGB_c_l.z : RGB_c.z;\n \}\n\n\n // # Step 6\n // RGB = RGB_c / D_RGB\n float3 RGB = RGB_c / D_RGB;\n \n \n // # Step 7\n // XYZ = vector_dot(MATRIX_INVERSE_16, RGB)\n float3x3 MATRIX_INVERSE_16 = CAT_CAT16.invert();\n float3 XYZ = vector_dot(MATRIX_INVERSE_16, RGB);\n\n\n // return XYZ;\n return XYZ;\n\n \}\n\n\n\n\n\n // convert HSV cylindrical projection values to RGB\n float3 HSV_to_RGB( float3 HSV )\n \{\n float C = HSV.z*HSV.y;\n float X = C*(1.0f-fabs(fmod(HSV.x*6.0f,2.0f)-1.0f));\n float m = HSV.z-C;\n\n float3 RGB;\n RGB.x = (HSV.x<1.0f/6.0f? C :HSV.x<2.0f/6.0f? X :HSV.x<3.0f/6.0f?0.0f:HSV.x<4.0f/6.0f?0.0f:HSV.x<5.0f/6.0f? X : C )+m;\n RGB.y = (HSV.x<1.0f/6.0f? X :HSV.x<2.0f/6.0f? C :HSV.x<3.0f/6.0f? C :HSV.x<4.0f/6.0f? X :HSV.x<5.0f/6.0f?0.0f:0.0f)+m;\n RGB.z = (HSV.x<1.0f/6.0f?0.0f:HSV.x<2.0f/6.0f?0.0f:HSV.x<3.0f/6.0f? X :HSV.x<4.0f/6.0f? C :HSV.x<5.0f/6.0f? C : X )+m;\n return RGB;\n \}\n\n\n // convert RGB to HSV cylindrical projection values\n float3 RGB_to_HSV( float3 RGB )\n \{\n float cmax = max(RGB.x,max(RGB.y,RGB.z));\n float cmin = min(RGB.x,min(RGB.y,RGB.z));\n float delta = cmax-cmin;\n\n float3 HSV;\n HSV.x = delta==0.0f?0.0f:cmax==RGB.x?(fmod((RGB.y-RGB.z)/delta+6.0f,6.0f))/6.0f:cmax==RGB.y?(((RGB.z-RGB.x)/delta+2.0f)/6.0f):(((RGB.x-RGB.y)/delta+4.0f)/6.0f);\n HSV.y = cmax == 0.0f ? 0.0f : delta / cmax;\n HSV.z = cmax;\n return HSV;\n \}\n\n\n // retrieve the JM coordinates of the limiting gamut cusp at the hue slice 'h'\n // cusps are very expensive to compute\n // and the DRT is only using them for lightness mapping\n // which does not require a high degree of accuracy\n // so instead we use a pre-computed table of cusp points\n // sampled at 1 degree hue intervals of the the RGB target gamut\n // and lerp between them to get the approximate J & M values\n float2 cuspFromTable(float h)\n \{\n\n float3 lo;\n float3 hi;\n\n if( h <= gamutCuspTable\[0].z )\n \{\n lo = gamutCuspTable\[gamutCuspTableSize-1];\n lo.z = lo.z-360.0f;\n hi = gamutCuspTable\[0];\n \}\n else if( h >= gamutCuspTable\[gamutCuspTableSize-1].z )\n \{\n lo = gamutCuspTable\[gamutCuspTableSize-1];\n hi = gamutCuspTable\[0];\n hi.z = hi.z+360.f;\n \}\n else\n \{\n for(int i = 1; i < gamutCuspTableSize; ++i)\n \{\n if( h <= gamutCuspTable\[i].z )\n \{\n lo = gamutCuspTable\[i-1];\n hi = gamutCuspTable\[i];\n break;\n \}\n \}\n \}\n\n float t = (h - lo.z) / (hi.z - lo.z);\n\n float cuspJ = lerp(lo.x, hi.x, t);\n float cuspM = lerp(lo.y, hi.y, t);\n\n return float2(cuspJ,cuspM);\n \}\n\n\n // find the JM coordinates of the smoothed boundary of the limiting gamut in ZCAM at the hue slice 'h' \n // by searching along the line defined by 'JMSource' and 'JMFocus'\n // the function will search outwards from where the line intersects the achromatic axis with a staring incement of 'startStepSize'\n // once the boundary has been crossed it will search in the opposite direction with half the step size\n // and will repeat this as as many times as is set by the 'precision' paramter\n float2 findBoundary(float2 JMSource, float2 JMFocus, float h, float3 XYZw, float3 XYZd65, float3x3 XYZ_to_RGB, float smoothing, int precision, float startStepSize )\n \{\n\n float2 achromaticIntercept = float2(JMFocus.x - (((JMSource.x-JMFocus.x) / (JMSource.y-JMFocus.y))*JMFocus.y), 0.0f);\n\n if( achromaticIntercept.x <= 0.0f || achromaticIntercept.x >= limitJmax )\n \{\n return achromaticIntercept;\n \}\n\n\n float stepSize = startStepSize;\n float2 unitVector = normalize(achromaticIntercept - JMFocus);\n float2 JMtest = achromaticIntercept;\n int searchOutwards = 1;\n\n for( int i = 0; i < precision; ++i )\n \{\n\n for( int k = 0; k < 30; ++k )\n \{\n JMtest = JMtest + unitVector * stepSize;\n int inside = isInsideCube( vector_dot(XYZ_to_RGB, JMh_to_XYZ( float3(JMtest.x, JMtest.y, h), XYZw, XYZd65, outputViewingConditions , L_A, Y_b, discountIlluminant_mid, HK_mode_mid) / referenceLuminance ), boundaryRGB, smoothing);\n\n if( searchOutwards )\n \{\n if( JMtest.x < 0.0f || JMtest.x > limitJmax || JMtest.y > limitMmax || !inside )\n \{\n searchOutwards = 0;\n stepSize = -fabs(stepSize) / 2.0f;\n break;\n \}\n \}\n else\n \{\n if( JMtest.y < 0.0f || inside )\n \{\n searchOutwards = 1;\n stepSize = fabs(stepSize) / 2.0f;\n break;\n \}\n \}\n \}\n \}\n\n\n float2 JMboundary = float2( clamp(JMtest.x, 0.0f, limitJmax), clamp(JMtest.y, 0.0f, limitMmax) );\n // float2 JMboundary = float2(JMtest.x, JMtest.y);\n return JMboundary;\n \}\n\n\n\n// Michalis Menton Dual Spring Curve\n float forwardMmTonescale(float x)\n \{\n float tc = 0.0f;\n if (x<0.18)\n \{\n tc = cs*spow(x,c0);\n \}\n else\n \{\n tc = c0*(x-0.18)+0.18;\n \}\n \n float ts = s1*spow((tc/(s0+tc)),p);\n float tf = ts*ts/(ts+fl);\n float ccf = spow(s0/(x+s0),dch)*sat;\n\n return tf;\n \}\n\n float inverseMmTonescale(float x)\n \{\n\n float tf = (x+sqrt(x*(4*fl+x)))/2;\n float ts = s0/(spow((s1/tf),(1/p))-1);\n float tc = 0.0f;\n if (ts<0.18)\n \{\n tc = spow((ts/cs),(1/c0));\n \}\n else\n \{\n tc = (ts-0.18)/c0+0.18;\n \}\n float ccf = spow(s0/(tc+s0),dch)*sat;\n\n return tc;\n \}\n\n // Daniele's Compression Curve\n // https://www.desmos.com/calculator/fihdxfot6s\n\n float forwardDanieleCompressionCurve(float x)\n \{\n float m0 = n / nr;\n float m = 0.5f * ( m0 + sqrt(m0 * ( m0 + 4 * t_1 ) ) ) ;\n float s_1 = w * pow(m,1.0f/g);\n\n // Scale Data\n // x = x / n;\n\n // Ref Version\n float f = pow(((max(0.0f,x))/(x+s_1)),g)*m;\n float h = max(0.0f,((pow(f,2.0f))/(f+t_1)));\n \n // Scale Data\n // h = h * n;\n\n return h;\n \}\n\n float inverseDanieleCompressionCurve(float x)\n \{\n float m0 = n / nr;\n float m = 0.5f * ( m0 + sqrt(m0 * ( m0 + 4 * t_1 ) ) ) ;\n float s_1 = w * pow(m,1.0f/g);\n \n // inverted version of forwardDanieleCompressionCurve\n\n\n float new_f = 0.5f * (x + sqrt(x) * sqrt(4 * t_1 + x));\n float new_x = pow(new_f/m, 1.0f/g) * s_1 / (1.0f-pow(new_f/m, 1.0f/g)); ;\n\n // // Rescale data down\n // x = x * n;\n\n return new_x;\n \}\n\n float daniele_evo_fwd(float Y)\n \{\n float f = daniele_m_2 * pow(max(0.0f, Y) / (Y + daniele_s_2), daniele_g);\n float h = max(0.0f, f * f / (f + daniele_t_1));\n\n return h;\n \}\n\n float daniele_evo_rev(float Y)\n \{\n Y = max(0.0f, min(daniele_n / (daniele_u_2 * daniele_n_r), Y));\n float h = (Y + sqrt(Y * (4.0f * daniele_t_1 + Y))) / 2.0f;\n float f = daniele_s_2 / (pow((daniele_m_2 / h), (1.0f / daniele_g)) - 1.0f);\n\n return f;\n \}\n\n \n\n // convert Iz to luminance\n // note that the PQ fuction used for Iz differs from the ST2084 function by replacing m_2 with rho\n // it also includes a luminance shift caused by the 2nd row-sum of the XYZ to LMS matrix not adding up to 1.0\n float IzToLuminance( float Iz )\n \{\n float V_p = spow(Iz, 1.0f / zcam_rho);\n float luminance = spow((max(0.0f, V_p - st2084_c_1) / (st2084_c_2 - st2084_c_3 * V_p)), st2084_m_1_d)*st2084_L_p * zcam_luminance_shift;\n return luminance;\n \}\n\n\n // convert luminance to Iz\n // note that the PQ fuction used for Iz differs from the ST2084 function by replacing m_2 with rho\n // it also includes a luminance shift caused by the 2nd row-sum of the XYZ to LMS matrix not adding up to 1.0\n float luminanceToIz( float luminance )\n \{\n float Y_p = spow((luminance/zcam_luminance_shift) / st2084_L_p, st2084_m_1);\n float Iz = spow((st2084_c_1 + st2084_c_2 * Y_p) / (st2084_c_3 * Y_p + 1.0f), zcam_rho);\n return Iz;\n \}\n\n // calculate a scale factor for colorfulness\n // based on the difference between the original and tone scaled (TS) Iz values\n // we are only interested in the differences above mid grey\n // so we first offset the original Iz values to align 18% it with the mid point of the IzTS value\n float highlightDesatFactor(float Iz, float IzTS)\n \{\n float linear = Iz;\n\n // no highlight desat below SSTS mid point\n if (linear < 0.18f)\n \{\n return 1.0f;\n \}\n\n float IzMid = 0.18f;\n float IzMidTS = sstsLuminance.y / referenceLuminance;\n\n float IzAligned = Iz + IzMidTS - IzMid;\n\n float desatFactor = 1.0f - clamp(compressPowerP((log10(max(HALF_MIN, IzAligned)) - log10(max(HALF_MIN, IzTS))) * desatHighlights,\n compressionFuncParams.x, HALF_MAX, compressionFuncParams.z, 0), 0.0f, 1.0f);\n return desatFactor;\n \}\n\n float smooth_window(float x, float s0, float e0, float s1, float e1)\n \{\n float x0 = clamp((x - s0) / (e0 - s0), 0.0f, 1.0f);\n float x1 = clamp((x - e1) / (s1 - e1), 0.0f, 1.0f);\n float x0s = x0 * x0 * (3 - 2 * x0);\n float x1s = x1 * x1 * (3 - 2 * x1);\n\n return x > s1 ? x1s : x < e0 ? x0s : 1.0f;\n \}\n\n float hueAngle(float h, float offset, float width)\n \{\n float rot = 30.0f; // Rotate so that ACES RGBCMY align better with h\n return smooth_window(fmod(h + offset, 360.0f), 120.0f - width + rot, 120.0f + rot, 120.0f + rot, 120.0f + width + rot);\n \}\n\n float desat_curve(float x)\n \{\n float t = 0.02f;\n float m = daniele_n / daniele_n_r;\n float w = 1.05f * m;\n float f = (max(0.0f, x) / (x + w)) * m;\n return max(0.0f, f * f / (f + t));\n \}\n\n float powerp(float x, float t, float l, float p)\n \{\n float c = (x - t) / (l - t);\n c = c != 0.0f ? c / pow(1.0f + pow(c, p), 1.0f / p) : 0.0f;\n return t + (l - t) * c;\n \}\n\n // Chroma compression\n //\n // - Compresses the scene colorfulness with desat_curve() and powerp() to bring the\n // values to sensible range after tonescale.\n // - Scales the colorfulness with a cubic curve to affect the rate of change of\n // desaturation as lightness is increased. This is done per-hue and affects\n // a range of colorfulness (distance from the achromatic).\n // - Global saturation control can be used to set overall image colorfulness.\n //\n float chromaCompression(float3 JMh, float luminance, int invert)\n \{\n float M = JMh.y;\n\n // Model specific factors to avoid having to change parameters manually\n float model_desat_factor = camMode == 1 ? chromaCompress * 1.2f : chromaCompress * 0.9f;\n float model_factor = camMode == 1 ? 5.0f : 1.0f;\n float model_shadow_boost = camMode == 1 ? shadow_boost * 1.0f : shadow_boost * 1.0f;\n\n //\n // Compression curve based on the difference of the scene luminance and desat_curve().\n // This scales automatically, compressing less with higher peak luminance. Higher peak\n // luminance has a slower rate of change for colorfulness so it needs less compression.\n // The goal is to compress close to the point where the tonescale hits peak white with\n // the desat_factor. This should give better match between different peak luminances.\n // https://www.desmos.com/calculator/g9ve9668bb\n //\n model_desat_factor += chromaCompressParams.x * (log(daniele_n / daniele_n_r) / log(10000.0f / 100.0f));\n float x = log10(max(HALF_MIN, luminance)) - log10(max(HALF_MIN, desat_curve(luminance)));\n float desatcurve = powerp(x * model_desat_factor, 0.0f, chromaCompressParams.y, chromaCompressParams.z);\n float desatFactor = clamp(1.0f - desatcurve, 0.0f, 1.0f);\n\n //\n // Per-hue compression of M with R (J). Larger values of R will compress larger range of colorfulness.\n // https://www.desmos.com/calculator/nygtri388c\n //\n // This could replaced with a shape that takes h correlate as input for more precise compression.\n float ra = hueAngle(JMh.z, 120.0f, 70.0f);\n float ga = hueAngle(JMh.z, 350.0f, 70.0f);\n float ba = hueAngle(JMh.z, 240.0f, 70.0f);\n float ca = hueAngle(JMh.z, 300.0f, 70.0f);\n float ma = hueAngle(JMh.z, 180.0f, 70.0f);\n float yo = hueAngle(JMh.z, 60.0f, 90.0f);\n\n float R = JMh.x * model_factor * ((ra * rfM) + (ga * gfM) + (ba * bfM) + (ca * cfM) + (ma * mfM) + (yo * yofM));\n\n // Controls compression with R, c == 1 no compression, c == 0.0001 full compression.\n // The driver is the tonescaled lightness in 0-1 range. The shadow_boost affects\n // saturation mainly at and under normal exposure.\n float c = max(0.99f - (JMh.x / limitJmax), 0.01f) * model_shadow_boost;\n\n if (!invert)\n \{\n M *= desatFactor;\n// if (M != 0.0f && R != 0.0f && M > 0.0001f)\n if (M != 0.0f && R != 0.0f)\n \{\n M *= ((M * M + R * c) / (M * M + R));\n \}\n M *= sat;\n \}\n else\n \{\n M /= sat;\n if (M != 0.0f && R != 0.0f)\n \{\n float t0 = 3.0f * R * c;\n float p0 = M * M - t0;\n float p1 = 2.0f * M * M + 27.0f * R - 3.0f * t0;\n float p2 = pow((sqrt(M * M * p1 * p1 - 4.0f * p0 * p0 * p0) / 2.0f) + M * p1 / 2.0f, 1.0f / 3.0f);\n M = (p0 / (3.0f * p2) + (p2 / 3.0f) + (M / 3.0f));\n \}\n M /= desatFactor;\n \}\n\n return M;\n \}\n\n float3 input_RGB_to_JMh(float3 inputRGB)\n \{\n // clamp input to +/- HALF_MAX range (to remove inf values, etc.)\n inputRGB = clamp3(inputRGB, -HALF_MAX, HALF_MAX);\n\n // convert to linear XYZ luminance values\n float3 luminanceRGB = encodingToLuminance3( encodingIn, inputRGB);\n float3 luminanceXYZ = vector_dot(RGB_to_XYZ_input, luminanceRGB);\n\n // // CAT to go from D60 to D65\n // if (D60toD65CATtoggle)\n // \{\n // luminanceXYZ = vector_dot(D60toD65CAT, luminanceXYZ);\n // \}\n \n\n // // assuming 'fully adapted', dark' viewing conditions for input image (does that make sense?)\n // float3 Izazbz = XYZ_to_Izazbz(apply_CAT(luminanceXYZ, inWhite, d65White, catType, 1.0f));\n // // return apply_CAT(luminanceXYZ, inWhite, d65White, catType, 1.0f);\n // float3 refWhiteIzazbz = XYZ_to_Izazbz(refWhite*referenceLuminance/refWhite.y);\n // float3 colorJMh = Izazbz_to_JMh(Izazbz, refWhiteIzazbz.x, 0);\n\n float3 JMh = XYZ_to_JMh(luminanceXYZ, inWhite, d65White, viewingConditions, L_A, Y_b, discountIlluminant_in, HK_mode_in);\n\n if (diagnosticMode == 6)\n \{\n return luminanceXYZ;\n \}\n else\n \{\n return JMh;\n \}\n\n \}\n\n\n\n float3 JMh_to_input_RGB(float3 JMh)\n \{\n\n\n float3 luminanceXYZ = JMh_to_XYZ( JMh, inWhite, d65White, viewingConditions , L_A, Y_b, discountIlluminant_in, HK_mode_in);\n // // CAT to go from D60 to D65\n // if (D60toD65CATtoggle)\n // \{\n // luminanceXYZ = vector_dot(D60toD65CAT, luminanceXYZ);\n // \}\n float3 luminanceRGB = vector_dot(XYZ_to_RGB_input, luminanceXYZ);\n float3 inputRGB = luminanceToEncoding3( encodingIn, luminanceRGB);\n\n\n return inputRGB;\n\n \}\n\n\n\n float3 forwardTonescale( float3 inputJMh, float3 srcRGB )\n \{\n float3 refWhiteIzazbz = XYZ_to_Izazbz(refWhite*referenceLuminance/refWhite.y);\n\n float3 outputJMh;\n\n // if( ! applyTonecurve && ! applyHighlightDesat )\n // \{\n // // nothing to do here except output input JMh\n // return outputJMh;\n // \}\n\n // float3 colorJMh = Izazbz_to_JMh(inputIzazbz, refWhiteIzazbz.x, 0);\n \n float3 monoJMh = float3(inputJMh.x,0.0f,0.0f);\n\n float3 linearJMh = JMh_to_luminance_RGB(monoJMh);\n float linear = linearJMh.x/referenceLuminance;\n\n // float3 monoIzazbz = JMh_to_Izazbz(colorJMh, refWhiteIzazbz.x, 0);\n // float3 monoXYZ = Izazbz_to_XYZ(monoIzazbz);\n\n float luminanceTS = linear;\n\n // switch for applying the different tonescale compression functions\n if ( toneScaleMode == 0 )\n \{\n luminanceTS = linear;\n \}\n else if( toneScaleMode == 1 )\n \{\n luminanceTS = forwardMmTonescale(linear) * mmScaleFactor;\n \}\n else if( toneScaleMode == 2 )\n \{\n luminanceTS = forwardDanieleCompressionCurve(linear) * mmScaleFactor;\n \}\n else if( toneScaleMode == 3 )\n \{\n luminanceTS = pow(1.0f/2.2f,linear)*referenceLuminance;\n \}\n else if( toneScaleMode == 4 )\n \{\n luminanceTS = daniele_evo_fwd(linear) * mmScaleFactor;\n \}\n\n float3 tonemappedmonoJMh = luminance_RGB_to_JMh(float3(luminanceTS,luminanceTS,luminanceTS));\n float3 tonemappedJMh = float3(tonemappedmonoJMh.x,inputJMh.y,inputJMh.z);\n // float3 tonemappedJMh = float3(tonemappedmonoJMh.x,0.0f,0.0f);\n // float3 tonemappedJMh = float3(inputJMh.x,inputJMh.y,inputJMh.z);\n\n // return outputJMh;\n if( applyTonecurve )\n \{\n outputJMh = tonemappedJMh;\n \}\n else\n \{\n outputJMh = inputJMh;\n \}\n\n // Apply highlight desat\n if (applyChromaCompression)\n \{\n outputJMh.y = chromaCompression(outputJMh, linear, 0);\n \}\n else if( applyHighlightDesat )\n \{\n float factM = highlightDesatFactor(linear, luminanceTS/referenceLuminance);\n outputJMh.y = outputJMh.y * factM;\n \}\n else\n \{\n outputJMh.y = outputJMh.y; \n \}\n\n return outputJMh;\n\n \}\n\n\n float3 inverseTonescale( float3 JMh )\n \{\n float3 tonemappedJMh = JMh;\n\n if( ! applyTonecurve && ! applyHighlightDesat )\n \{\n // nothing else to do here\n return tonemappedJMh;\n \}\n\n float3 untonemappedColourJMh = tonemappedJMh;\n \n float3 monoTonemappedJMh = float3(tonemappedJMh.x,0.0f,0.0f);\n float3 monoTonemappedRGB = JMh_to_luminance_RGB(monoTonemappedJMh);\n float3 newMonoTonemappedJMh = luminance_RGB_to_JMh(monoTonemappedRGB);\n float luminance = monoTonemappedRGB.x;\n\n // Dummy value to init the var\n float linear = 50.0f;\n // swtich for testing out the MM tonescale from Jed\n if( toneScaleMode == 1 )\n \{\n linear = inverseMmTonescale(luminance/mmScaleFactor);\n \}\n else if( toneScaleMode == 2 )\n \{\n linear = inverseDanieleCompressionCurve(luminance/mmScaleFactor);\n \}\n else if( toneScaleMode == 4 )\n \{\n linear = daniele_evo_rev(luminance / mmScaleFactor);\n \}\n else\n \{\n linear = luminance;\n \}\n\n linear = linear*referenceLuminance;\n \n if( applyTonecurve )\n \{\n float3 untonemappedMonoJMh = luminance_RGB_to_JMh(float3(linear,linear,linear));\n untonemappedColourJMh = float3(untonemappedMonoJMh.x,tonemappedJMh.y,tonemappedJMh.z);\n \} \n\n // Apply highlight desat\n if (applyChromaCompression)\n \{\n untonemappedColourJMh.y = chromaCompression(tonemappedJMh, linear/referenceLuminance, 1);\n \}\n else if( applyHighlightDesat )\n \{\n float factM = highlightDesatFactor(linear/referenceLuminance, luminance/referenceLuminance);\n untonemappedColourJMh.y = untonemappedColourJMh.y / factM;\n \}\n\n return untonemappedColourJMh;\n \}\n\n\n // compress the ZCAM JM values into the limiting gamut by projecting them towards a focus point beyond the achromatic axis\n // in order to avoid the gamut compression to also compress black and white tones towards the focus point\n // (which would result in lifed blacks and crushed highlights)\n // we offset the focus further away from the achromatic axis the closer the lightness of a sample is to the zero or the limitJmax value\n // a far away focus point means the compression vector becomes close to orthogonal to the lightness axis preserving black & white lightness\n // the 'distanceGainCalcJ' paramter should be set to inputJMh.x for the forward direction\n // and to the best guess of the original, uncompressed values for the inverse direction\n // this is used for iteratively converging on the original, uncompressed value of J which would have gotten obfuscated by the forward transform\n float3 compressGamut( float3 inputJMh, int invert, float distanceGainCalcJ )\n \{\n if( ! applyGamutCompression )\n \{\n return inputJMh;\n \}\n\n float sstsMidJ = XYZ_to_JMh( refWhite * sstsLuminance.y, refWhite, d65White, outputViewingConditions, L_A_out, Y_b_out, discountIlluminant_mid, HK_mode_mid).x;\n float2 JMinput = float2(inputJMh.x, inputJMh.y);\n float2 JMcusp = cuspFromTable( inputJMh.z);\n\n float focusJ = lerp(JMcusp.x, sstsMidJ, cuspMidBlend);\n\n float focusDistanceGain = 1.0f;\n\n // This section was causing a weird to collapse of the M value with Hellwig. Added a toggle to help chase it down\n if( distanceGainCalcJ > focusJ && focusJbypass)\n \{\n focusDistanceGain = (limitJmax - focusJ) / max(0.0001f, (limitJmax - min(limitJmax, distanceGainCalcJ)));\n \}\n else\n \{\n focusDistanceGain = (focusJ) / max(0.0001f, distanceGainCalcJ); \n \}\n\n float2 JMfocus = float2( focusJ, -JMcusp.y*focusDistanceClamped*focusDistanceGain );\n float2 vecToFocus = (JMfocus - JMinput);\n float2 achromaticIntercept = float2(JMfocus.x - (((JMinput.x-JMfocus.x) / (JMinput.y-JMfocus.y))*JMfocus.y), 0.0f);\n\n // to reduce the number of expensive boundary finding iterations needed\n // we taking an educated guess at a good starting step size\n // based on how far the sample is either above or below the gamut cusp\n float cuspToTipRatio;\n if( JMinput.x > JMcusp.x )\n \{\n cuspToTipRatio = (JMinput.x - JMcusp.x) / (limitJmax - JMcusp.x);\n \}\n else\n \{\n cuspToTipRatio = (JMcusp.x - JMinput.x) / (JMcusp.x);\n \}\n\n float startStepSize = lerp(JMcusp.y / 3.0f, 0.1f, cuspToTipRatio);\n\n // The casuse of the issues around M collapse (see line 2415) seem to be related to this line\n float2 JMboundary = findBoundary(JMinput, JMfocus, inputJMh.z, refWhite, d65White, XYZ_to_RGB_limit, smoothCusps, boundarySolvePrecision, startStepSize);\n float normFact = 1.0f / max(0.0001f, length(JMboundary - achromaticIntercept));\n float v = length(JMinput-achromaticIntercept) * normFact;\n float vCompressed = compressPowerP(v, compressionFuncParams.x, compressionFuncParams.y, compressionFuncParams.z, invert);\n float2 JMcompressed = 0.0f;\n // hack to stop nan values after compression\n if (JMinput.y != 0.0f)\n \{\n JMcompressed = achromaticIntercept + normalize(JMinput-achromaticIntercept)*vCompressed/normFact;\n \}\n else\n \{\n JMcompressed = JMinput;\n \}\n JMcompressed.x = lerp(JMcompressed.x,inputJMh.x,compressionMix);\n JMcompressed.y = lerp(JMcompressed.y,inputJMh.y,compressionMix);\n if (diagnosticMode == 5)\n \{\n return float3(JMfocus.x, JMfocus.y, normFact);\n \}\n else\n \{\n return float3(JMcompressed.x, JMcompressed.y, inputJMh.z);\n \}\n \}\n\n\n // apply the forward gamut compression to the limiting primaries\n float3 compressGamutForward( float3 JMh )\n \{\n float3 JMhcompressed = compressGamut( JMh, 0, JMh.x );\n // Hack to deal with weird zero values on output\n // JMhcompressed.x = min(300.0f,JMhcompressed.x);\n return JMhcompressed;\n \}\n\n\n // apply the inverse gamut compression\n // and iterate a given number of times to reconstruct the original J value\n float3 compressGamutInverse( float3 JMh )\n \{\n float3 JMhuncompressed;\n float distanceGainCalcJ = JMh.x;\n\n for( int i = 0; i < inverseSolverIterations; ++i )\n \{\n JMhuncompressed = compressGamut( JMh, 1, distanceGainCalcJ );\n distanceGainCalcJ = JMhuncompressed.x;\n \}\n\n return JMhuncompressed;\n \}\n\n\n void init()\n \{\n HALF_MIN = 0.0000000596046448f;\n HALF_MAX = 65504.0f;\n\n zcam_L_A = referenceLuminance * backgroundLuminance / 100.0f;\n zcam_F_b = sqrt(backgroundLuminance/referenceLuminance);\n zcam_F_L = 0.171f*spow(zcam_L_A, 1.0f/3.0f) * (1.0f-exp(-48.0f/9.0f*zcam_L_A));\n\n if( discountIlluminant_in )\n \{\n cat_adaptDegree = 1.0f;\n \}\n else\n \{\n float viewingConditionsCoeff = 1.0f;\n\n if( viewingConditions == 0 )\n \{\n viewingConditionsCoeff = 0.8f;\n \}\n else if( viewingConditions == 1 )\n \{\n viewingConditionsCoeff = 0.9f;\n \}\n else if( viewingConditions == 2 )\n \{\n viewingConditionsCoeff = 1.0f;\n \}\n\n cat_adaptDegree = viewingConditionsCoeff * (1.0f - (1.0f / 3.6f) * exp((-zcam_L_A - 42.0f) / 92.0f));\n \}\n\n\n zcam_cb = 1.15f;\n zcam_cg = 0.66f;\n zcam_c1 = 3424.0f / spow(2.0f,12.0f);\n zcam_c2 = 2413.0f / spow(2.0f, 7.0f);\n zcam_c3 = 2392.0f / spow(2.0f, 7.0f);\n zcam_eta = 2610.0f / spow(2.0f,14.0f);\n // zcam_rho = 1.7f * 2323.0f / pow(2.0f,5.0f);\n zcam_luminance_shift = 1.0f / (-0.20151000f + 1.12064900f + 0.05310080f);\n\n zcam_viewing_conditions_coeff = 1.0f;\n\n if( viewingConditions == 0 )\n \{\n zcam_viewing_conditions_coeff = 0.525f;\n \}\n else if( viewingConditions == 1 )\n \{\n zcam_viewing_conditions_coeff = 0.59f;\n \}\n else if( viewingConditions == 2 )\n \{\n zcam_viewing_conditions_coeff = 0.69f;\n \}\n\n st2084_m_1=2610.0f / 4096.0f * (1.0f / 4.0f);\n st2084_m_2=2523.0f / 4096.0f * 128.0f;\n st2084_c_1=3424.0f / 4096.0f;\n st2084_c_2=2413.0f / 4096.0f * 32.0f;\n st2084_c_3=2392.0f / 4096.0f * 32.0f;\n st2084_m_1_d = 1.0f / st2084_m_1;\n st2084_m_2_d = 1.0f / st2084_m_2;\n st2084_L_p = 10000.0f;\n\n // pre-calculate Daniele Evo constants\n daniele_r_hit = daniele_r_hit_min + (daniele_r_hit_max - daniele_r_hit_min) * (log(daniele_n / daniele_n_r) / log(10000.0f / 100.0f));\n daniele_m_0 = daniele_n / daniele_n_r;\n daniele_m_1 = 0.5f * (daniele_m_0 + sqrt(daniele_m_0 * (daniele_m_0 + 4.0f * daniele_t_1)));\n daniele_u = pow((daniele_r_hit / daniele_m_1) / ((daniele_r_hit / daniele_m_1) + 1.0f), daniele_g);\n daniele_m = daniele_m_1 / daniele_u;\n daniele_w_i = log(daniele_n / 100.0f) / log(2.0f);\n daniele_c_t = daniele_c_d * (1.0f + daniele_w_i * daniele_w_g) / daniele_n_r;\n daniele_g_ip = 0.5f * (daniele_c_t + sqrt(daniele_c_t * (daniele_c_t + 4.0f * daniele_t_1)));\n daniele_g_ipp2 = -daniele_m_1 * pow(daniele_g_ip / daniele_m, 1.0f / daniele_g) / (pow(daniele_g_ip / daniele_m, 1.0f / daniele_g) - 1.0f);\n daniele_w_2 = daniele_c / daniele_g_ipp2;\n daniele_s_2 = daniele_w_2 * daniele_m_1;\n daniele_u_2 = pow((daniele_r_hit / daniele_m_1) / ((daniele_r_hit / daniele_m_1) + daniele_w_2), daniele_g);\n daniele_m_2 = daniele_m_1 / daniele_u_2;\n\n float identity_matrix_data\[]=\{ 1.0f, 0.0f, 0.0f,\n 0.0f, 1.0f, 0.0f,\n 0.0f, 0.0f, 1.0f \};\n\n float XYZ_to_LMS_Bradford_data\[]=\{ 0.8951f, 0.2664f,-0.1614f,\n -0.7502f, 1.7135f, 0.0367f,\n 0.0389f,-0.0685f, 1.0296f \};\n\n float XYZ_to_LMS_CAT02_data\[]=\{ 0.7328f, 0.4296f,-0.1624f,\n -0.7036f, 1.6975f, 0.0061f,\n 0.0030f, 0.0136f, 0.9834f \};\n\n float XYZ_to_LMS_ZCAM_data\[]=\{ 0.41478972f, 0.57999900f, 0.01464800f,\n -0.20151000f, 1.12064900f, 0.05310080f,\n -0.01660080f, 0.26480000f, 0.66847990f \};\n\n float eps = 3.7035226210190005e-11f;\n float LMS_to_Izazbz_data\[]=\{ 0.000000f, 1.0001f-eps , 0.000000f,\n 3.524000f,-4.066708f, 0.542708f,\n 0.199076f, 1.096799f,-1.295875f \};\n\n\n identity_matrix.setArray(identity_matrix_data);\n XYZ_to_LMS_Bradford.setArray(XYZ_to_LMS_Bradford_data);\n XYZ_to_LMS_CAT02.setArray(XYZ_to_LMS_CAT02_data);\n // XYZ_to_LMS_ZCAM.setArray(XYZ_to_LMS_ZCAM_data);\n LMS_to_Izazbz.setArray(LMS_to_Izazbz_data);\n\n\n // Blink does not seem to support initialising multidimensional arrays\n // So instead of being able to index the matrix data directly from one\n // we need to use long if/else statements to populate the\n // input, limit & output primary matrices\n // (maybe there is a better way?)\n\n float XYZ_to_AP0_ACES_matrix_data\[]=\n \{\n 1.0498110175f, 0.0000000000f, -0.0000974845f,\n -0.4959030231f, 1.3733130458f, 0.0982400361f,\n 0.0000000000f, 0.0000000000f, 0.9912520182f\n \};\n\n float XYZ_to_AP1_ACES_matrix_data\[]=\n \{\n 1.6410233797f, -0.3248032942f, -0.2364246952f,\n -0.6636628587f, 1.6153315917f, 0.0167563477f,\n 0.0117218943f, -0.0082844420f, 0.9883948585f,\n \};\n\n float XYZ_to_Rec709_D65_matrix_data\[]=\n \{\n 3.2409699419f, -1.5373831776f, -0.4986107603f,\n -0.9692436363f, 1.8759675015f, 0.0415550574f,\n 0.0556300797f, -0.2039769589f, 1.0569715142f,\n \};\n\n float XYZ_to_Rec2020_D65_matrix_data\[]=\n \{\n 1.7166511880f, -0.3556707838f, -0.2533662814f,\n -0.6666843518f, 1.6164812366f, 0.0157685458f,\n 0.0176398574f, -0.0427706133f, 0.9421031212f,\n \};\n\n float XYZ_to_P3_D65_matrix_data\[]=\n \{\n 2.4934969119f, -0.9313836179f, -0.4027107845f,\n -0.8294889696f, 1.7626640603f, 0.0236246858f,\n 0.0358458302f, -0.0761723893f, 0.9568845240f,\n \};\n\n float XYZ_to_P3_DCI_matrix_data\[]=\n \{\n 2.7253940305f, -1.0180030062f, -0.4401631952f,\n -0.7951680258f, 1.6897320548f, 0.0226471906f,\n 0.0412418914f, -0.0876390192f, 1.1009293786f\n \};\n\n float CAT_CAT16_data\[]=\n \{\n 0.401288, 0.650173, -0.051461,\n -0.250268, 1.204414, 0.045854,\n -0.002079, 0.048952, 0.953127,\n \};\n\n float Modified_CAT16_data\[]=\n \{\n 0.656619, 0.342071, 0.00131062,\n -0.222571, 1.10658, 0.115987,\n -0.000634146, 0.05855, 0.942084,\n \};\n\n // populate the input primaries matrix\n if( primariesIn == 0 )\n \{\n XYZ_to_RGB_input.setArray(XYZ_to_AP0_ACES_matrix_data);\n \}\n else if( primariesIn == 1 )\n \{\n XYZ_to_RGB_input.setArray(XYZ_to_AP1_ACES_matrix_data);\n \}\n else if( primariesIn == 2 )\n \{\n XYZ_to_RGB_input.setArray(XYZ_to_Rec709_D65_matrix_data);\n \}\n else if( primariesIn == 3 )\n \{\n XYZ_to_RGB_input.setArray(XYZ_to_Rec2020_D65_matrix_data);\n \}\n else if( primariesIn == 4 )\n \{\n XYZ_to_RGB_input.setArray(XYZ_to_P3_D65_matrix_data);\n \}\n else if( primariesIn == 5 )\n \{\n XYZ_to_RGB_input.setArray(XYZ_to_P3_DCI_matrix_data);\n \}\n else\n \{\n XYZ_to_RGB_input.setArray(identity_matrix_data);\n \}\n\n // populate the limiting primaries matrix\n if( primariesLimit == 0 )\n \{\n XYZ_to_RGB_limit.setArray(XYZ_to_AP0_ACES_matrix_data);\n \}\n else if( primariesLimit == 1 )\n \{\n XYZ_to_RGB_limit.setArray(XYZ_to_AP1_ACES_matrix_data);\n \}\n else if( primariesLimit == 2 )\n \{\n XYZ_to_RGB_limit.setArray(XYZ_to_Rec709_D65_matrix_data);\n \}\n else if( primariesLimit == 3 )\n \{\n XYZ_to_RGB_limit.setArray(XYZ_to_Rec2020_D65_matrix_data);\n \}\n else if( primariesLimit == 4 )\n \{\n XYZ_to_RGB_limit.setArray(XYZ_to_P3_D65_matrix_data);\n \}\n else if( primariesLimit == 5 )\n \{\n XYZ_to_RGB_limit.setArray(XYZ_to_P3_DCI_matrix_data);\n \}\n else\n \{\n XYZ_to_RGB_limit.setArray(identity_matrix_data);\n \}\n\n // populate the output primaries matrix\n if( primariesOut == 0 )\n \{\n XYZ_to_RGB_output.setArray(XYZ_to_AP0_ACES_matrix_data);\n \}\n else if( primariesOut == 1 )\n \{\n XYZ_to_RGB_output.setArray(XYZ_to_AP1_ACES_matrix_data);\n \}\n else if( primariesOut == 2 )\n \{\n XYZ_to_RGB_output.setArray(XYZ_to_Rec709_D65_matrix_data);\n \}\n else if( primariesOut == 3 )\n \{\n XYZ_to_RGB_output.setArray(XYZ_to_Rec2020_D65_matrix_data);\n \}\n else if( primariesOut == 4 )\n \{\n XYZ_to_RGB_output.setArray(XYZ_to_P3_D65_matrix_data);\n \}\n else if( primariesOut == 5 )\n \{\n XYZ_to_RGB_output.setArray(XYZ_to_P3_DCI_matrix_data);\n \}\n else\n \{\n XYZ_to_RGB_output.setArray(identity_matrix_data);\n \}\n\n RGB_to_XYZ_input = XYZ_to_RGB_input.invert();\n RGB_to_XYZ_limit = XYZ_to_RGB_limit.invert();\n RGB_to_XYZ_output = XYZ_to_RGB_output.invert();\n\n float3x3 XYZ_to_RGB_sRGB;\n XYZ_to_RGB_sRGB.setArray(XYZ_to_Rec709_D65_matrix_data);\n float3 white(1.0f, 1.0f, 1.0f);\n\n d65White = vector_dot(XYZ_to_RGB_sRGB.invert(), white);\n inWhite = vector_dot(RGB_to_XYZ_input, white);\n outWhite = vector_dot(RGB_to_XYZ_output, white);\n refWhite = vector_dot(RGB_to_XYZ_limit, white);\n limitWhite = vector_dot(RGB_to_XYZ_limit, white);\n\n boundaryRGB = sstsLuminance.z / referenceLuminance;\n\n if (catDataSelection == 0)\n \{\n CAT_CAT16.setArray(CAT_CAT16_data);\n \}\n else if (catDataSelection == 1)\n \{\n CAT_CAT16.setArray(Modified_CAT16_data);\n \}\n else if (catDataSelection == 2)\n \{\n CAT_CAT16 = RGBPrimsToXYZMatrix(rxy,gxy,bxy,wxy,1.0f,1);\n \}\n\n float panlrcm_data\[]=\n \{\n 460.0f, 451.0f, 288.0f,\n 460.0f, -891.0f, -261.0f,\n 460.0f, -220.0f, -6300.0f,\n \};\n panlrcm.setArray(panlrcm_data);\n\n //\n // solving the RGB cusp from JMh is very expensive\n // instead we go the other way and start with a RGB cusp sweep\n // which is easily calculated by converting via HSV (Hue, 1.0, 1.0)\n // we then convert each cusp to JMh and add them to a table \n //\n\n gamutCuspTableSize = 360;\n\n for( int i = 0; i < gamutCuspTableSize; ++i )\n \{\n float hNorm = float(i) / (gamutCuspTableSize);\n float3 RGB = HSV_to_RGB(float3(hNorm, 1.0f, 1.0f));\n gamutCuspTableUnsorted\[i] = limit_RGB_to_JMh(RGB);\n \}\n\n int minhIndex = 0;\n for( int i = 1; i < gamutCuspTableSize; ++i )\n \{\n if( gamutCuspTableUnsorted\[i].z < gamutCuspTableUnsorted\[minhIndex].z)\n \{\n minhIndex = i;\n \}\n \}\n\n\n for( int i = 0; i < gamutCuspTableSize; ++i )\n \{\n gamutCuspTable\[i] = gamutCuspTableUnsorted\[(minhIndex+i)%gamutCuspTableSize];\n \n \}\n\n // calculate the maximum expected J & M values for the given limit gamut\n // these are used as limiting values for the gamut boundary searches\n\n // limitJmax (asumed to match limitRGB white)\n limitJmax = limit_RGB_to_JMh(float3(1.0f)).x;\n\n\n // limitMmax (assumed to coincide with one of the RGBCMY corners of the limitRGB cube)\n float3 gamutCornersTable\[6];\n gamutCornersTable\[0] = limit_RGB_to_JMh(float3(1.0f, 0.0f, 0.0f));\n gamutCornersTable\[1] = limit_RGB_to_JMh(float3(1.0f, 1.0f, 0.0f));\n gamutCornersTable\[2] = limit_RGB_to_JMh(float3(0.0f, 1.0f, 0.0f));\n gamutCornersTable\[3] = limit_RGB_to_JMh(float3(0.0f, 1.0f, 1.0f));\n gamutCornersTable\[4] = limit_RGB_to_JMh(float3(0.0f, 0.0f, 1.0f));\n gamutCornersTable\[5] = limit_RGB_to_JMh(float3(1.0f, 0.0f, 1.0f));\n\n limitMmax = 0.0f;\n for( int i = 0; i < 6; ++i )\n \{\n limitMmax = max(limitMmax, gamutCornersTable\[i].y);\n \}\n\n // ensure positive, non-zero focus depth\n // to avoid the gamut boundary search vector becoming zero for achromatic colors\n // which will cause the boundary search loop to continue forever and the node to hang\n focusDistanceClamped = max(0.01f, focusDistance);\n \}\n\n\n void process()\n \{\n SampleType(src) source = src();\n float3 srcRGB(source.x, source.y, source.z);\n float3 dstRGB;\n float3 diagnostic;\n float3 compressedJMh;\n float3 tonemappedJMh;\n float3 JMh;\n\n if( invert )\n \{\n compressedJMh = output_RGB_to_JMh(srcRGB);\n tonemappedJMh = compressGamutInverse(compressedJMh);\n JMh = inverseTonescale(tonemappedJMh);\n dstRGB = JMh_to_input_RGB(JMh);\n diagnostic = dstRGB;\n \}\n else\n \{\n JMh = input_RGB_to_JMh(srcRGB);\n tonemappedJMh = forwardTonescale(JMh, srcRGB);\n compressedJMh = compressGamutForward(tonemappedJMh);\n dstRGB = JMh_to_output_RGB(compressedJMh);\n diagnostic = dstRGB;\n \}\n\n if ( diagnosticMode == 1 || diagnosticMode == 6 )\n \{\n // Mode 6 actually returns XYZ, mode 1 returns real JMh\n diagnostic = JMh;\n \}\n else if ( diagnosticMode == 2)\n \{\n diagnostic = tonemappedJMh;\n \}\n else if ( diagnosticMode == 3 || diagnosticMode == 5 )\n \{\n diagnostic = compressedJMh;\n \}\n else if ( diagnosticMode == 4 )\n \{\n dstRGB = JMh_to_output_RGB(JMh);\n diagnostic = dstRGB;\n \}\n else if ( diagnosticMode == 7)\n \{\n dstRGB = JMh_to_output_RGB(srcRGB);\n diagnostic = dstRGB;\n \}\n else if ( diagnosticMode == 8)\n \{\n diagnostic = inWhite;\n \}\n else if ( diagnosticMode == 9)\n \{\n diagnostic = outWhite;\n \}\n else if ( diagnosticMode == 10)\n \{\n diagnostic = limitWhite;\n \}\n else if ( diagnosticMode == 11)\n \{\n diagnostic = d65White;\n \}\n\n dst() = float4(diagnostic.x, diagnostic.y, diagnostic.z, source.w ); \n \}\n\};\n"
useGPUIfAvailable {{parent.use_gpu}}
rebuild ""
DRT_CAM_Kernel_encodingIn {{parent.encoding_in}}
DRT_CAM_Kernel_primariesIn {{parent.primaries_in}}
DRT_CAM_Kernel_toneScaleMode {{parent.toneScaleMode}}
DRT_CAM_Kernel_camMode {{parent.camMode}}
DRT_CAM_Kernel_catType {{parent.cat_type}}
DRT_CAM_Kernel_discountIlluminant_in true
DRT_CAM_Kernel_discountIlluminant_mid true
DRT_CAM_Kernel_discountIlluminant_out true
DRT_CAM_Kernel_compressMode true
DRT_CAM_Kernel_referenceLuminance {{parent.reference_luminance}}
DRT_CAM_Kernel_backgroundLuminance {{parent.background_luminance}}
DRT_CAM_Kernel_viewingConditions {{inputViewingConditions}}
DRT_CAM_Kernel_outputViewingConditions {{parent.viewing_conditions}}
DRT_CAM_Kernel_applyTonecurve {{applyTonecurve}}
DRT_CAM_Kernel_sstsLuminance {{parent.ssts_luminance.x} {parent.ssts_luminance.y} {parent.ssts_luminance.z}}
DRT_CAM_Kernel_applyHighlightDesat {{parent.apply_highlight_desat}}
DRT_CAM_Kernel_applyChromaCompression {{parent.applyChromaCompression}}
DRT_CAM_Kernel_desatHighlights {{parent.desat_highlights}}
DRT_CAM_Kernel_chromaCompress {{parent.chromaCompression}}
DRT_CAM_Kernel_chromaCompressParams {0.559 2.085 0.823}
DRT_CAM_Kernel_sat {{"1.15 * parent.saturation"}}
DRT_CAM_Kernel_shadow_boost 1.25
DRT_CAM_Kernel_rfM 4.5
DRT_CAM_Kernel_gfM 6
DRT_CAM_Kernel_bfM 30
DRT_CAM_Kernel_cfM 20
DRT_CAM_Kernel_mfM 20
DRT_CAM_Kernel_yofM 2.5
DRT_CAM_Kernel_primariesLimit {{parent.primaries_limit}}
DRT_CAM_Kernel_applyGamutCompression {{parent.apply_gamut_compression}}
DRT_CAM_Kernel_cuspMidBlend {{parent.cusp_mid_blend}}
DRT_CAM_Kernel_focusDistance {{parent.focus_distance}}
DRT_CAM_Kernel_compressionFuncParams {{parent.compression_params.x} {parent.compression_params.y} {parent.compression_params.z}}
DRT_CAM_Kernel_compressionMix {{parent.BlinkScript1_DRT_CAM_Kernel_compressionMix}}
DRT_CAM_Kernel_smoothCusps {{parent.smooth_cusps}}
DRT_CAM_Kernel_boundarySolvePrecision {{parent.solve_precision}}
DRT_CAM_Kernel_inverseSolverIterations {{parent.inverse_solver_iterations}}
DRT_CAM_Kernel_encodingOut {{parent.encoding_out}}
DRT_CAM_Kernel_primariesOut {{parent.primaries_out}}
DRT_CAM_Kernel_clampOutput {{parent.clamp_output}}
DRT_CAM_Kernel_invert {{parent.invert}}
DRT_CAM_Kernel_XYZ_to_LMS_ZCAM {
{{DRT_CAM_Blink4.preMatrix.matrix*matrixScaler} {DRT_CAM_Blink4.preMatrix.matrix*matrixScaler} {DRT_CAM_Blink4.preMatrix.matrix*matrixScaler}}
{{DRT_CAM_Blink4.preMatrix.matrix*matrixScaler} {DRT_CAM_Blink4.preMatrix.matrix*matrixScaler} {DRT_CAM_Blink4.preMatrix.matrix*matrixScaler}}
{{DRT_CAM_Blink4.preMatrix.matrix*matrixScaler} {DRT_CAM_Blink4.preMatrix.matrix*matrixScaler} {DRT_CAM_Blink4.preMatrix.matrix*matrixScaler}}
}
DRT_CAM_Kernel_zcam_rho {{"1.7 * 2523.0 / pow(2.0,5.0)"}}
DRT_CAM_Kernel_Lp {{parent.ssts_luminance.z}}
DRT_CAM_Kernel_su 2
DRT_CAM_Kernel_c0 1.2
DRT_CAM_Kernel_cs {{0.18**(1-DRT_CAM_Kernel_c0)}}
DRT_CAM_Kernel_c1 1.1
DRT_CAM_Kernel_p {{DRT_CAM_Kernel_c1*(0.9+0.05*DRT_CAM_Kernel_su)}}
DRT_CAM_Kernel_w1 {{(0.595*DRT_CAM_Kernel_Lp/10000)**0.931+1.037}}
DRT_CAM_Kernel_s1 {{DRT_CAM_Kernel_w1*DRT_CAM_Kernel_Lp/100}}
DRT_CAM_Kernel_ex -0.26
DRT_CAM_Kernel_eb 0.08
DRT_CAM_Kernel_e0 {{2**(DRT_CAM_Kernel_ex+DRT_CAM_Kernel_eb*log(DRT_CAM_Kernel_s1)/log(2))}}
DRT_CAM_Kernel_s0 {{(DRT_CAM_Kernel_s1/DRT_CAM_Kernel_e0)**(1/DRT_CAM_Kernel_c1)}}
DRT_CAM_Kernel_fl 0.01
DRT_CAM_Kernel_dch 0.55
DRT_CAM_Kernel_mmScaleFactor 100
DRT_CAM_Kernel_n {{ssts_luminance.z}}
DRT_CAM_Kernel_nr 100
DRT_CAM_Kernel_g 1.1
DRT_CAM_Kernel_w 0.84
DRT_CAM_Kernel_t_1 1
DRT_CAM_Kernel_daniele_n {{parent.ssts_luminance.z}}
DRT_CAM_Kernel_daniele_n_r 100
DRT_CAM_Kernel_daniele_g 1.15
DRT_CAM_Kernel_daniele_c 0.18
DRT_CAM_Kernel_daniele_c_d 10.013
DRT_CAM_Kernel_daniele_w_g 0.14
DRT_CAM_Kernel_daniele_t_1 0.04
DRT_CAM_Kernel_daniele_r_hit_min 128
DRT_CAM_Kernel_daniele_r_hit_max 896
DRT_CAM_Kernel_catDataSelection {{parent.HellwigCam16Data}}
DRT_CAM_Kernel_rxy {0.84 0.17}
DRT_CAM_Kernel_gxy {-1.25 2.4}
DRT_CAM_Kernel_bxy {0.04 -0.6}
DRT_CAM_Kernel_wxy {4200 -1050}
DRT_CAM_Kernel_XYZ_w {95.05 100 108.88}
DRT_CAM_Kernel_XYZ_w_scaler 100
DRT_CAM_Kernel_L_A {{parent.BlinkScript1_DRT_CAM_Kernel_L_A}}
DRT_CAM_Kernel_Y_b {{parent.BlinkScript1_DRT_CAM_Kernel_Y_b}}
DRT_CAM_Kernel_L_B {0 {DRT_CAM_Kernel_L_B.x} {DRT_CAM_Kernel_L_B.x}}
DRT_CAM_Kernel_L_A_out {{parent.BlinkScript1_DRT_CAM_Kernel_L_A_out}}
DRT_CAM_Kernel_Y_b_out {{parent.BlinkScript1_DRT_CAM_Kernel_Y_b_out}}
DRT_CAM_Kernel_focusJbypass true
rebuild_finalise ""
name BlinkScript1
note_font "Bitstream Vera Sans"
selected true
xpos -908
ypos -186
addUserKnob {20 User}
addUserKnob {7 matrixScaler R 0 2}
matrixScaler 0.99415
}
set Nab48c000 [stack 0]
Clamp {
minimum_enable false
maximum {{parent.parent.DRT_CAM_Blink4.ssts_luminance.z/100}}
name Clamp1
xpos -908
ypos -112
disable {{1-parent.clamp_output}}
}
set Nab48c400 [stack 0]
Output {
name Output1
xpos -908
ypos -10
}
push $Nab48c000
Multiply {
value 0.01
name Multiply1
xpos -757
ypos -139
}
push $Nac0b4c00
Colorspace {
primary_in ACES
colorspace_out sRGB
primary_out DCI-P3
name Colorspace1
xpos -632
ypos -195
}
ColorMatrix {
inputs 0
matrix {
{0.368792 0.531205 0.103642}
{-0.193458 1.03225 0.131287}
{-0.0348077 0.283972 0.671427}
}
name preMatrix
xpos -639
ypos -256
}
Ramp {
inputs 0
output {rgba.red -rgba.green -rgba.blue rgba.alpha}
p0 {0 0}
p1 {0 1556}
name Ramp1
xpos -480
ypos -373
}
Ramp {
output {-rgba.red rgba.green -rgba.blue rgba.alpha}
p0 {0 0}
p1 {0 1556}
color 140
name Ramp6
xpos -480
ypos -341
}
Ramp {
output {-rgba.red -rgba.green rgba.blue rgba.alpha}
p0 {0 0}
p1 {2048 0}
color 360
name Ramp2
xpos -480
ypos -309
}
Expression {
temp_name0 factor
temp_expr0 4
expr0 10
expr2 int(b/factor)*factor
name Expression2
xpos -480
ypos -277
}
Shuffle2 {
fromInput1 {{0} B}
fromInput2 {{0} B}
mappings "4 rgba.red 0 0 rgba.red 0 0 rgba.blue 0 2 rgba.blue 0 2 rgba.alpha 0 3 rgba.alpha 0 3 rgba.green 0 1 rgba.green 0 1"
name Shuffle1
xpos -480
ypos -253
disable true
}
Multiply {
channels {-rgba.red rgba.green -rgba.blue none}
value {{frame-1}}
name Multiply2
xpos -480
ypos -229
disable true
}
Multiply {
value {5 10 1 1}
name Multiply4
xpos -480
ypos -205
disable true
}
Reformat {
type "to box"
box_width 82
box_height 1324
box_fixed true
resize distort
name Reformat1
xpos -480
ypos -173
}
BlinkScript {
kernelSourceFile /Users/afry/GitHub/nukeHellwig2022/hellwig2022_linearExtension.blink
recompileCount 329
ProgramGroup 1
KernelDescription "2 \"hellwig2022\" iterate pixelWise 04a153eb156481d24da07bce758805af9618d86417134288c34f84b6aacda788 2 \"src\" Read Point \"dst\" Write Point 13 \"direction\" Int 1 AAAAAA== \"catDataSelection\" Int 1 AAAAAA== \"XYZ_w\" Float 3 AAAAAAAAAAAAAAAAAAAAAA== \"L_A\" Float 1 AAAAAA== \"Y_b\" Float 1 AAAAAA== \"L_B\" Float 3 AAAAAAAAAAAAAAAAAAAAAA== \"surround\" Float 3 AAAAAAAAAAAAAAAAAAAAAA== \"discount_illuminant\" Bool 1 AA== \"HK_mode\" Bool 1 AA== \"rxy\" Float 2 AAAAAAAAAAA= \"gxy\" Float 2 AAAAAAAAAAA= \"bxy\" Float 2 AAAAAAAAAAA= \"wxy\" Float 2 AAAAAAAAAAA= 13 \"direction\" 1 1 \"catDataSelection\" 1 1 \"XYZ_w\" 3 1 \"L_A\" 1 1 \"Y_b\" 1 1 \"L_B\" 3 1 \"surround\" 3 1 \"discount_illuminant\" 1 1 \"HK_mode\" 1 1 \"rxy\" 2 1 \"gxy\" 2 1 \"bxy\" 2 1 \"wxy\" 2 1 3 \"HALF_MIN\" Float 1 1 AAAAAA== \"HALF_MAX\" Float 1 1 AAAAAA== \"CAT_CAT16\" Float 9 1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
kernelSource "\nkernel hellwig2022 : ImageComputationKernel<ePixelWise>\n\{\n Image<eRead, eAccessPoint, eEdgeClamped> src; // the input image\n Image<eWrite> dst; // the output image\n\n param:\n\n // the kernel parameters\n int direction; // the direction of the convolution\n int catDataSelection; // original vs modified CAT16 matrix\n\n float3 XYZ_w;\n float L_A;\n float Y_b;\n float3 L_B;\n float3 surround;\n bool discount_illuminant;\n bool HK_mode;\n\n // xy coordintes for custom CAT matrix\n float2 rxy;\n float2 gxy;\n float2 bxy;\n float2 wxy;\n\n\n local:\n float HALF_MIN;\n float HALF_MAX;\n\n float3x3 CAT_CAT16;\n\n\n void define()\n \{\n\n \}\n\n // multiplies a 3D vector with a 3x3 matrix\n float3 vector_dot( float3x3 m, float3 v)\n \{\n float3 r = 1.0f;\n for(int c = 0; c<3; c++)\n \{\n r\[c] = m\[c]\[0]*v.x + m\[c]\[1]*v.y + m\[c]\[2]*v.z;\n \}\n\n return r;\n \}\n\n // linear interpolation between two values a & b with the bias t\n float lerp(float a, float b, float t)\n \{\n return a + t * (b - a);\n \}\n\n // \"safe\" power function to avoid NANs or INFs when taking a fractional power of a negative base\n // this one initially returned -pow(abs(b), e) for negative b\n // but this ended up producing undesirable results in some cases\n // so now it just returns 0.0 instead\n float spow( float base, float exponent )\n \{\n if(base < 0.0f && exponent != floor(exponent) )\n \{\n return 0.0f;\n \}\n else\n \{\n return pow(base, exponent); \n \}\n \}\n\n float3 float3spow( float3 base, float exponent )\n \{\n return float3(spow(base.x, exponent), spow(base.y, exponent), spow(base.z, exponent));\n \}\n\n float3 float3sign( float3 v )\n \{\n return float3(sign(v.x), sign(v.y), sign(v.z));\n \}\n\n\n // \"safe\" div\n float sdiv( float a, float b )\n \{\n if(b == 0.0f)\n \{\n return 0.0f;\n \}\n else\n \{\n return a / b;\n \}\n \}\n \n\n // convert radians to degrees\n float degrees( float radians )\n \{\n return radians * 180.0f / PI;\n \}\n\n float abs( float a )\n \{\n return fabs(a);\n \}\n\n float3 float3abs( float3 a )\n \{\n return fabs(a);\n \}\n \n\n // get the y value of f(x) where the fuction is defined as a line between two points\n // the two points as passed as an array \[a.x, a.y, b.x, b.y]\n float lerp1D( float4 table, float x)\n \{\n float m = (table.w-table.y) / (table.z-table.x);\n float c = table.y - (m*table.x);\n float y = x*m+c;\n return y;\n \}\n\n float3 float3_to_domain_100( float3 v )\n \{\n return v;\n \}\n \n\n\n float hue_angle( float a, float b )\n \{\n // \"\"\"\n // Return the *hue* angle :math:`h` in degrees.\n\n // Parameters\n // ----------\n // a\n // Opponent colour dimension :math:`a`.\n // b\n // Opponent colour dimension :math:`b`.\n\n // Returns\n // -------\n // :class:`numpy.floating` or :class:`numpy.ndarray`\n // *Hue* angle :math:`h` in degrees.\n\n // Examples\n // --------\n // >>> a = -0.000624112068243\n // >>> b = -0.000506270106773\n // >>> hue_angle(a, b) # doctest: +ELLIPSIS\n // 219.0484326...\n // \"\"\"\n\n // a = as_float_array(a);\n // b = as_float_array(b);\n\n float h = degrees(atan2(b, a)) / 360;\n\n return h;\n \}\n\n float clip(float x, float a, float b)\n \{\n return max(a, min(x, b));\n \}\n\n float mod(float a, float N)\n \{\n return a - N*floor(a/N);\n \} \n\n float radians(float a)\n \{\n return a * PI / 180.0f;\n \}\n\n\n\n\n float hue_angle_dependency_Hellwig2022(float h)\n \{\n // \"\"\"\n // Compute the hue angle dependency of the *Helmholtz–Kohlrausch* effect.\n // Parameters\n // ----------\n // h\n // Hue :math:`h` angle in degrees.\n // Returns\n // -------\n // :class:`numpy.floating` or :class:`numpy.ndarray`\n // Hue angle dependency.\n // Examples\n // --------\n // >>> hue_angle_dependency_Hellwig2022(219.0484326582719)\n // ... # doctest: +ELLIPSIS\n // 0.8962565...\n // \"\"\"\n\n // h = as_float_array(h)\n return float( \\\n -0.160 * cos(h) \\\n + 0.132 * cos(2 * h) \\\n - 0.405 * sin(h) \\\n + 0.080 * sin(2 * h) \\ \n + 0.792 \\\n );\n\n // return float( -0.160f * cos(h) + 0.132f * cos(2.0f * h) - 0.405f * sin(h) + 0.080f * sin(2.0f * h) + 0.792f );\n \}\n\n\n float3x3 RGBPrimsToXYZMatrix(float2 rxy, float2 gxy, float2 bxy, float2 wxy,float Y, bool direction)\n \{\n // # given r g b chromaticities and whitepoint, convert RGB colors to XYZ\n // # based on CtlColorSpace.cpp from the CTL source code : 77\n // # param: xy - dict of chromaticity xy coordinates: rxy: float2(x, y) etc\n // # param: Y - luminance of \"white\" - defaults to 1.0\n // # param: inverse - calculate XYZ to RGB instead\n\n float2 r = rxy;\n float2 g = gxy;\n float2 b = bxy;\n float2 w = wxy;\n\n float X = w.x * Y / w.y;\n float Z = (1 - w.x - w.y) * Y / w.y;\n\n // # Scale factors for matrix rows\n float d = r.x * (b.y - g.y) + b.x * (g.y - r.y) + g.x * (r.y - b.y);\n\n float Sr = (X * (b.y - g.y) - \\\n g.x * (Y * (b.y - 1.0f) + \\\n b.y * (X + Z)) + \\\n b.x * (Y * (g.y - 1.0f) + \\\n g.y * (X + Z))) / d ;\n \n float Sg = (X * (r.y - b.y) + \\\n r.x * (Y * (b.y - 1.0f) + \\\n b.y * (X + Z)) - \\\n b.x * (Y * (r.y - 1.0f) + \\\n r.y * (X + Z))) / d ;\n\n float Sb = (X * (g.y - r.y) - \\\n r.x * (Y * (g.y - 1.0f) + \\\n g.y * (X + Z)) + \\\n g.x * (Y * (r.y - 1.0f) + \\\n r.y * (X + Z))) / d ;\n\n // # Assemble the matrix\n float Mdata\[] =\n \{\n Sr * r.x, Sr * r.y, Sr * (1.0f - r.x - r.y),\n Sg * g.x, Sg * g.y, Sg * (1.0f - g.x - g.y),\n Sb * b.x, Sb * b.y, Sb * (1.0f - b.x - b.y),\n \};\n\n float MdataNukeOrder\[] = \{\n Mdata\[0], Mdata\[3], Mdata\[6],\n Mdata\[1], Mdata\[4], Mdata\[7],\n Mdata\[2], Mdata\[5], Mdata\[8],\n \};\n\n float3x3 newMatrix;\n newMatrix.setArray(MdataNukeOrder);\n\n // create inverse matrix\n float3x3 newMatrixInverse = newMatrix.invert();\n\n // return forward or inverse matrix\n if (direction == 0)\n \{\n return newMatrix;\n \}\n else if (direction == 1)\n \{\n return newMatrixInverse;\n \}\n \}\n\n\n float achromatic_response_forward(float3 RGB)\n \{\n // \"\"\"\n // Return the achromatic response :math:`A` from given compressed\n // *CAM16* transform sharpened *RGB* array and :math:`N_\{bb\}` chromatic\n // induction factor for forward *Hellwig and Fairchild (2022)* implementation.\n\n // Parameters\n // ----------\n // RGB\n // Compressed *CAM16* transform sharpened *RGB* array.\n\n // Returns\n // -------\n // :class:`numpy.floating` or :class:`numpy.ndarray`\n // Achromatic response :math:`A`.\n\n // Examples\n // --------\n // >>> RGB = np.array(\[7.94634384, 7.94713791, 7.9488967])\n // >>> achromatic_response_forward(RGB) # doctest: +ELLIPSIS\n // 23.9322704...\n // \"\"\"\n\n float R = RGB.x;\n float G = RGB.y;\n float B = RGB.z;\n\n\n float A = 2 * R + G + 0.05 * B - 0.305;\n\n return A;\n \}\n\n float colourfulness_correlate(float N_c,float e_t,float a,float b) \n \{\n // \"\"\"\n // Return the *colourfulness* correlate :math:`M`.\n\n // Parameters\n // ----------\n // N_c\n // Surround chromatic induction factor :math:`N_\{c\}`.\n // e_t\n // Eccentricity factor :math:`e_t`.\n // a\n // Opponent colour dimension :math:`a`.\n // b\n // Opponent colour dimension :math:`b`.\n\n // Returns\n // -------\n // :class:`numpy.floating` or :class:`numpy.ndarray`\n // *Colourfulness* correlate :math:`M`.\n\n // Examples\n // --------\n // >>> N_c = 1\n // >>> e_t = 1.13423124867\n // >>> a = -0.00063418423001\n // >>> b = -0.000479072513542\n // >>> colourfulness_correlate(N_c, e_t, a, b) # doctest: +ELLIPSIS\n // 0.0387637...\n // \"\"\"\n\n // N_c = as_float_array(N_c)\n // e_t = as_float_array(e_t)\n // a = as_float_array(a)\n // b = as_float_array(b)\n\n float M = 43 * N_c * e_t * sqrt(pow(a,2) + pow(b,2));\n\n return M;\n \}\n\n\n\n float degree_of_adaptation(float F, float L_A )\n \{\n // \"\"\"\n // Return the degree of adaptation :math:`D` from given surround maximum\n // degree of adaptation :math:`F` and adapting field *luminance* :math:`L_A`\n // in :math:`cd/m^2`.\n\n // Parameters\n // ----------\n // F\n // Surround maximum degree of adaptation :math:`F`.\n // L_A\n // Adapting field *luminance* :math:`L_A` in :math:`cd/m^2`.\n\n // Returns\n // -------\n // :class:`numpy.floating` or :class:`numpy.ndarray`\n // Degree of adaptation :math:`D`.\n\n // Examples\n // --------\n // >>> degree_of_adaptation(1.0, 318.31) # doctest: +ELLIPSIS\n // 0.9944687...\n // \"\"\"\n\n // F = as_float_array(F)\n // L_A = as_float_array(L_A)\n\n float D = F * (1 - (1 / 3.6) * exp((-L_A - 42) / 92));\n\n return D;\n \}\n\n\n\n // def d_post_adaptation_non_linear_response_compression_forward(\n // RGB: ArrayLike, F_L: FloatingOrArrayLike\n // ) -> NDArray:\n // F_L_RGB = spow(F_L\[..., np.newaxis] * RGB / 100, 0.42)\n // F_L_100 = spow(F_L\[..., np.newaxis] / 100, 0.42)\n \n // d_RGB_a = (\n // 400\n // * ((0.42 * 27.13) * spow(RGB, -0.58) * F_L_100)\n // / (F_L_RGB + 27.13) ** 2\n // )\n \n // return d_RGB_a\n\n // ** example\n // (a**2 + b**2)\n // (a * a + b * b);\n \n\n\n\n \n // def post_adaptation_non_linear_response_compression_forward(\n // RGB: ArrayLike, F_L: FloatingOrArrayLike\n // ) -> NDArray:\n\n\n // RGB = as_float_array(RGB)\n // F_L = as_float_array(F_L)\n\n // F_L_RGB = spow(F_L\[..., np.newaxis] * np.absolute(RGB) / 100, 0.42)\n // RGB_c = (400 * np.sign(RGB) * F_L_RGB) / (27.13 + F_L_RGB) + 0.1\n\n // return RGB_c\n\n\n float3 post_adaptation_non_linear_response_compression_forward(float3 RGB, float F_L)\n \{\n // RGB = as_float_array(RGB)\n // F_L = as_float_array(F_L)\n \n float3 F_L_RGB = float3spow(F_L * float3abs(RGB) / 100.0f, 0.42f);\n float3 RGB_c = (400.0f * sign(RGB) * F_L_RGB) / (27.13f + F_L_RGB) + 0.1f;\n \n return RGB_c;\n \}\n\n \n float3 post_adaptation_non_linear_response_compression_inverse(float3 RGB,float F_L)\n \{\n // RGB = as_float_array(RGB)\n // F_L = as_float_array(F_L)\n\n\n // RGB_p = (\n // np.sign(RGB - 0.1)\n // * 100\n // / F_L\[..., np.newaxis]\n // * spow(\n // (27.13 * np.absolute(RGB - 0.1)) / (400 - np.absolute(RGB - 0.1)),\n // 1 / 0.42,\n // )\n // )\n\n\n // RGB_p = ( np.sign(RGB - 0.1) * 100 / F_L\[..., np.newaxis] * spow( (27.13 * np.absolute(RGB - 0.1)) / (400 - np.absolute(RGB - 0.1)), 1 / 0.42, ))\n\n // older compression formula subbed in\n // float3 RGB_p = float3sign(RGB) * 100.0f / F_L * float3spow((27.13f * float3abs(RGB)) / (400.0f - float3abs(RGB)), 1.0f / 0.42f);\n\n // float3 RGB_p = sign(RGB - 0.1f) * 100.0f / F_L * spow((27.13f * float3abs(RGB - 0.1f)) / (400.0f - float3abs(RGB - 0.1f)), 1.0f / 0.42f);\n float3 RGB_p = (float3sign(RGB - 0.1f) * 100.0f / F_L * float3spow((27.13f * float3abs(RGB - 0.1f)) / (400.0f - float3abs(RGB - 0.1f)), 1.0f / 0.42f) );\n // float3 RGB_p = float3sign(RGB) * 100.0f / F_L * float3spow((27.13f * float3abs(RGB)) / (400.0f - float3abs(RGB)), 1.0f / 0.42f);\n return RGB_p;\n \}\n\n\n // def d_post_adaptation_non_linear_response_compression_forward(\n // RGB: ArrayLike, F_L: FloatingOrArrayLike\n // ) -> NDArray:\n // F_L_RGB = spow(F_L\[..., np.newaxis] * RGB / 100, 0.42)\n // F_L_100 = spow(F_L\[..., np.newaxis] / 100, 0.42)\n \n // d_RGB_a = ( 400 * ((0.42 * 27.13) * spow(RGB, -0.58) * F_L_100) / (F_L_RGB + 27.13) ** 2 )\n \n // return d_RGB_a\n \n \n float3 d_post_adaptation_non_linear_response_compression_forward( float3 RGB, float F_L)\n \{\n float3 F_L_RGB = float3spow(F_L * RGB / 100.0f, 0.42f);\n float F_L_100 = spow(F_L / 100.0f, 0.42f);\n \n // float3 d_RGB_a = ( 400.0f * ((0.42f * 27.13f) * float3spow(RGB, -0.58f) * F_L_100)/ (F_L_RGB + 27.13f) ** 2.0f );\n float3 d_RGB_a = ( 400.0f * ((0.42f * 27.13f) * float3spow(RGB, -0.58f) * F_L_100)/ ( (F_L_RGB + 27.13f) * (F_L_RGB + 27.13f) ));\n // d_RGB_a = d_RGB_a * d_RGB_a;\n\n return d_RGB_a;\n \}\n\n\n float3 XYZ_to_Hellwig2022_linearExtension_JMh( float3 XYZ, float3 XYZ_w, float L_A, float Y_b, float3 surround, bool discount_illuminant)\n \{\n // \"\"\"\n // Compute the *Hellwig and Fairchild (2022)* colour appearance model\n // correlates from given *CIE XYZ* tristimulus values.\n\n // Parameters\n // ----------\n // XYZ\n // *CIE XYZ* tristimulus values of test sample / stimulus.\n // XYZ_w\n // *CIE XYZ* tristimulus values of reference white.\n // L_A\n // Adapting field *luminance* :math:`L_A` in :math:`cd/m^2`, (often taken\n // to be 20% of the luminance of a white object in the scene).\n // Y_b\n // Luminous factor of background :math:`Y_b` such as\n // :math:`Y_b = 100 x L_b / L_w` where :math:`L_w` is the luminance of the\n // light source and :math:`L_b` is the luminance of the background. For\n // viewing images, :math:`Y_b` can be the average :math:`Y` value for the\n // pixels in the entire image, or frequently, a :math:`Y` value of 20,\n // approximate an :math:`L^*` of 50 is used.\n // surround\n // Surround viewing conditions induction factors.\n // discount_illuminant\n // Truth value indicating if the illuminant should be discounted.\n\n // Returns\n // -------\n // :class:`colour.CAM_Specification_Hellwig2022`\n // *Hellwig and Fairchild (2022)* colour appearance model specification.\n\n // Notes\n // -----\n // +------------+-----------------------+---------------+\n // | **Domain** | **Scale - Reference** | **Scale - 1** |\n // +============+=======================+===============+\n // | ``XYZ`` | \[0, 100] | \[0, 1] |\n // +------------+-----------------------+---------------+\n // | ``XYZ_w`` | \[0, 100] | \[0, 1] |\n // +------------+-----------------------+---------------+\n\n // +-------------------------------------+-----------------------+-----------\\\n // ----+\n // | **Range** | **Scale - Reference** | **Scale - \\\n // 1** |\n // +=====================================+=======================+===========\\\n // ====+\n // | ``CAM_Specification_Hellwig2022.J`` | \[0, 100] | \[0, 1] \\\n // |\n // +-------------------------------------+-----------------------+-----------\\\n // ----+\n // | ``CAM_Specification_Hellwig2022.C`` | \[0, 100] | \[0, 1] \\\n // |\n // +-------------------------------------+-----------------------+-----------\\\n // ----+\n // | ``CAM_Specification_Hellwig2022.h`` | \[0, 360] | \[0, 1] \\\n // |\n // +-------------------------------------+-----------------------+-----------\\\n // ----+\n // | ``CAM_Specification_Hellwig2022.s`` | \[0, 100] | \[0, 1] \\\n // |\n // +-------------------------------------+-----------------------+-----------\\\n // ----+\n // | ``CAM_Specification_Hellwig2022.Q`` | \[0, 100] | \[0, 1] \\\n // |\n // +-------------------------------------+-----------------------+-----------\\\n // ----+\n // | ``CAM_Specification_Hellwig2022.M`` | \[0, 100] | \[0, 1] \\\n // |\n // +-------------------------------------+-----------------------+-----------\\\n // ----+\n // | ``CAM_Specification_Hellwig2022.H`` | \[0, 400] | \[0, 1] \\\n // |\n // +-------------------------------------+-----------------------+-----------\\\n // ----+\n\n // References\n // ----------\n // :cite:`Fairchild2022`, :cite:`Hellwig2022`\n\n // Examples\n // --------\n // >>> XYZ = np.array(\[19.01, 20.00, 21.78])\n // >>> XYZ_w = np.array(\[95.05, 100.00, 108.88])\n // >>> L_A = 318.31\n // >>> Y_b = 20.0\n // >>> surround = VIEWING_CONDITIONS_Hellwig2022\['Average']\n // >>> XYZ_to_Hellwig2022(XYZ, XYZ_w, L_A, Y_b, surround)\n // ... # doctest: +ELLIPSIS\n // CAM_Specification_Hellwig2022(J=41.7312079..., C=0.0257636..., \\\n // h=217.0679597..., s=0.0608550..., Q=55.8523226..., M=0.0339889..., \\\n // H=275.5949861..., HC=None)\n // \"\"\"\n\n XYZ = float3_to_domain_100(XYZ);\n XYZ_w = float3_to_domain_100(XYZ_w);\n float _X_w = XYZ_w.x ;\n float Y_w = XYZ_w.y ;\n float _Z_w = XYZ_w.z ;\n // L_A = as_float_array(L_A)\n // Y_b = as_float_array(Y_b)\n\n // # Step 0\n // # Converting *CIE XYZ* tristimulus values to sharpened *RGB* values.\n float3x3 MATRIX_16 = CAT_CAT16;\n float3 RGB_w = vector_dot(MATRIX_16, XYZ_w);\n\n // # Computing degree of adaptation :math:`D`.\n float D = clip(degree_of_adaptation(surround.x, L_A), 0, 1);\n if(discount_illuminant)\n \{\n D = 1.0f;\n \}\n\n\n // # Viewing conditions dependent parameters\n float k = 1 / (5 * L_A + 1);\n float k4 = pow(k,4);\n float F_L = 0.2f * k4 * (5.0f * L_A) + 0.1f * pow((1.0f - k4), 2.0f) * spow(5.0f * L_A, 1.0f / 3.0f) ;\n float n = sdiv(Y_b, Y_w);\n float z = 1.48 + sqrt(n);\n\n // // float D_RGB = ( D\[..., np.newaxis] * Y_w\[..., np.newaxis] / RGB_w + 1 - D\[..., np.newaxis] )\n float3 D_RGB = D * Y_w / RGB_w + 1 - D;\n float3 RGB_wc = D_RGB * RGB_w;\n \n // # Applying forward post-adaptation non-linear response compression.\n // F_L_RGB = spow(F_L\[..., np.newaxis] * np.absolute(RGB_wc) / 100, 0.42)\n float3 F_L_RGB = float3spow(F_L * float3abs(RGB_wc) / 100.0f, 0.42f);\n\n // # Computing achromatic responses for the whitepoint.\n // RGB_aw = (400 * np.sign(RGB_wc) * F_L_RGB) / (27.13 + F_L_RGB) + 0.1\n float3 RGB_aw = (400.0f * float3sign(RGB_wc) * F_L_RGB) / (27.13f + F_L_RGB) + 0.1f;\n \n\n // # Computing achromatic responses for the whitepoint.\n // R_aw, G_aw, B_aw = tsplit(RGB_aw)\n float R_aw = RGB_aw.x ;\n float G_aw = RGB_aw.y ;\n float B_aw = RGB_aw.z ;\n // A_w = 2 * R_aw + G_aw + 0.05 * B_aw - 0.305\n float A_w = 2 * R_aw + G_aw + 0.05f * B_aw - 0.305f;\n\n // # Step 1\n // # Converting *CIE XYZ* tristimulus values to sharpened *RGB* values.\n // RGB = vector_dot(MATRIX_16, XYZ)\n\n float3 RGB = vector_dot(MATRIX_16, XYZ);\n // float3 RGB = XYZ;\n\n // # Step 2\n // RGB_c = D_RGB * RGB\n float3 RGB_c = D_RGB * RGB;\n\n // # Step 3\n // # Applying forward post-adaptation non-linear response compression.\n // // F_L_RGB = spow(F_L\[..., np.newaxis] * np.absolute(RGB_c) / 100, 0.42)\n // float3 F_L_RGB_2 = float3spow(F_L * float3abs(RGB_c) / 100.0f, 0.42f);\n // // RGB_a = (400 * np.sign(RGB_c) * F_L_RGB) / (27.13 + F_L_RGB) + 0.1\n // float3 RGB_a = (400.0f * float3sign(RGB_c) * F_L_RGB_2) / (27.13f + F_L_RGB_2) + 0.1f;\n\n\n // # Step 3\n // # Applying forward post-adaptation non-linear response compression.\n // RGB_a = post_adaptation_non_linear_response_compression_forward(RGB_c, F_L)\n // RGB_a_l = d_post_adaptation_non_linear_response_compression_forward(\n // full(3, L_B), F_L\n // ) * (\n // RGB_c - L_B\n // ) + post_adaptation_non_linear_response_compression_forward(\n // full(3, L_B), F_L\n // )\n // RGB_a = np.where(RGB_c < L_B, RGB_a_l, RGB_a)\n\n // # Step 3\n // # Applying forward post-adaptation non-linear response compression.\n float3 RGB_a = post_adaptation_non_linear_response_compression_forward(RGB_c, F_L);\n // float3 RGB_a = RGB_c;\n // float3 RGB_a_l = d_post_adaptation_non_linear_response_compression_forward(L_B, F_L) * ( RGB_c - L_B) + post_adaptation_non_linear_response_compression_forward( L_B, F_L );\n\n float3 RGB_a_l = d_post_adaptation_non_linear_response_compression_forward(\n L_B, F_L\n ) * (\n RGB_c - L_B\n ) + post_adaptation_non_linear_response_compression_forward(\n L_B, F_L\n );\n\n // float3 RGB_d;\n RGB_a.x = RGB_c.x < L_B.x ? RGB_a_l.x: RGB_a.x;\n RGB_a.y = RGB_c.y < L_B.y ? RGB_a_l.y: RGB_a.y;\n RGB_a.z = RGB_c.z < L_B.z ? RGB_a_l.z: RGB_a.z;\n\n\n\n\n // # Step 4\n // # Converting to preliminary cartesian coordinates.\n // R_a, G_a, B_a = tsplit(RGB_a)\n float R_a = RGB_a.x ;\n float G_a = RGB_a.y ;\n float B_a = RGB_a.z ;\n // a = R_a - 12 * G_a / 11 + B_a / 11\n float a = R_a - 12.0f * G_a / 11.0f + B_a / 11.0f;\n // b = (R_a + G_a - 2 * B_a) / 9\n float b = (R_a + G_a - 2.0f * B_a) / 9.0f;\n\n // # Computing the *hue* angle :math:`h`.\n // h = np.degrees(np.arctan2(b, a)) % 360\n // Unclear why this isnt matching the python version.\n float h = mod(degrees(atan2(b, a)), 360.0f);\n\n \n\n // # Step 5\n // # Computing eccentricity factor *e_t*.\n // hr = np.radians(h)\n float hr = radians(h);\n\n // _h = hr\n // _2_h = 2 * hr\n // _3_h = 3 * hr\n // _4_h = 4 * hr\n float _h = hr;\n float _2_h = 2 * hr;\n float _3_h = 3 * hr;\n float _4_h = 4 * hr;\n\n // e_t = (\n // -0.0582 * np.cos(_h)\n // - 0.0258 * np.cos(_2_h)\n // - 0.1347 * np.cos(_3_h)\n // + 0.0289 * np.cos(_4_h)\n // - 0.1475 * np.sin(_h)\n // - 0.0308 * np.sin(_2_h)\n // + 0.0385 * np.sin(_3_h)\n // + 0.0096 * np.sin(_4_h)\n // + 1\n // )\n float e_t = (\n -0.0582f * cos(_h)\n - 0.0258f * cos(_2_h)\n - 0.1347f * cos(_3_h)\n + 0.0289f * cos(_4_h)\n - 0.1475f * sin(_h)\n - 0.0308f * sin(_2_h)\n + 0.0385f * sin(_3_h)\n + 0.0096f * sin(_4_h)\n + 1.0f\n );\n\n // # Step 6\n // # Computing achromatic responses for the stimulus.\n // R_a, G_a, B_a = tsplit(RGB_a)\n float R_a2 = RGB_a.x ;\n float G_a2 = RGB_a.y ;\n float B_a2 = RGB_a.z ;\n // A = 2 * R_a + G_a + 0.05 * B_a - 0.305\n float A = 2 * R_a2 + G_a2 + 0.05f * B_a2 - 0.305f;\n\n // # Step 7\n // # Computing the correlate of *Lightness* :math:`J`.\n // with sdiv_mode():\n // J = 100 * spow(sdiv(A, A_w), surround.c * z)\n\n float J = 100.0f * spow(sdiv(A, A_w), surround.y * z);\n\n // # Step 8\n // # Computing the correlate of *brightness* :math:`Q`.\n // with sdiv_mode():\n // Q = (2 / as_float(surround.c)) * (J / 100) * A_w\n float Q = (2.0f / float(surround.y)) * (J / 100.0f) * A_w;\n\n // # Step 9\n // # Computing the correlate of *colourfulness* :math:`M`.\n // M = 43 * surround.N_c * e_t * np.sqrt(a**2 + b**2)\n float M = 43.0f * surround.z * e_t * sqrt(a * a + b * b);\n\n // # Computing the correlate of *chroma* :math:`C`.\n // with sdiv_mode():\n // C = 35 * sdiv(M, A_w)\n float C = 35.0f * sdiv(M, A_w);\n\n\n // # Computing the correlate of *saturation* :math:`s`.\n // with sdiv_mode():\n // s = 100 * sdiv(M, Q)\n float s = 100.0f * sdiv(M, Q);\n\n // # *Helmholtz–Kohlrausch* Effect Extension.\n float J_HK = J + hue_angle_dependency_Hellwig2022(hr) * spow(C, 0.587f);\n float Q_HK = (2.0f / surround.y) * (J_HK / 100.0f) * A_w ;\n \n // return XYZ_w;\n // return RGB_w;\n // return \{D,k,k4\};\n // return \{F_L,n,z\};\n // return RGB_c;\n if (HK_mode)\n \{\n return \{J_HK,M,h\};\n \}\n else\n \{\n return \{J,M,h\};\n \}\n // return XYZ;\n \}\n\n float3 Hellwig2022_linearExtension_JMh_to_XYZ( float3 JMh, float3 XYZ_w, float L_A, float Y_b, float3 surround, bool discount_illuminant)\n \{\n float J = JMh.x;\n float M = JMh.y;\n float h = JMh.z;\n\n \n // L_A = as_float_array(L_A)\n // XYZ_w = to_domain_100(XYZ_w)\n // _X_w, Y_w, _Z_w = tsplit(XYZ_w)\n float _X_w = XYZ_w.x;\n float Y_w = XYZ_w.y;\n float _Z_w = XYZ_w.z;\n\n // # Step 0\n // # Converting *CIE XYZ* tristimulus values to sharpened *RGB* values.\n // RGB_w = vector_dot(MATRIX_16, XYZ_w)\n float3x3 MATRIX_16 = CAT_CAT16;\n float3 RGB_w = vector_dot(MATRIX_16, XYZ_w);\n\n\n // # Computing degree of adaptation :math:`D`.\n float D = clip(degree_of_adaptation(surround.x, L_A), 0, 1);\n if(discount_illuminant)\n \{\n D = 1.0f;\n \}\n\n\n\n // # Viewing conditions dependent parameters\n float k = 1 / (5 * L_A + 1);\n float k4 = pow(k,4);\n float F_L = 0.2f * k4 * (5.0f * L_A) + 0.1f * pow((1.0f - k4), 2.0f) * spow(5.0f * L_A, 1.0f / 3.0f) ;\n float n = sdiv(Y_b, Y_w);\n float z = 1.48 + sqrt(n);\n\n // // float D_RGB = ( D\[..., np.newaxis] * Y_w\[..., np.newaxis] / RGB_w + 1 - D\[..., np.newaxis] )\n float3 D_RGB = D * Y_w / RGB_w + 1 - D;\n float3 RGB_wc = D_RGB * RGB_w;\n \n // # Applying forward post-adaptation non-linear response compression.\n // F_L_RGB = spow(F_L\[..., np.newaxis] * np.absolute(RGB_wc) / 100, 0.42)\n float3 F_L_RGB = float3spow(F_L * float3abs(RGB_wc) / 100.0f, 0.42f);\n\n // # Computing achromatic responses for the whitepoint.\n // RGB_aw = (400 * np.sign(RGB_wc) * F_L_RGB) / (27.13 + F_L_RGB) + 0.1\n float3 RGB_aw = (400.0f * float3sign(RGB_wc) * F_L_RGB) / (27.13f + F_L_RGB) + 0.1f;\n\n // # Computing achromatic responses for the whitepoint.\n // R_aw, G_aw, B_aw = tsplit(RGB_aw)\n float R_aw = RGB_aw.x ;\n float G_aw = RGB_aw.y ;\n float B_aw = RGB_aw.z ;\n // A_w = 2 * R_aw + G_aw + 0.05 * B_aw - 0.305\n float A_w = 2 * R_aw + G_aw + 0.05f * B_aw - 0.305f;\n\n // # Step 2\n // # Computing eccentricity factor *e_t*.\n // hr = np.radians(h)\n float hr = radians(h);\n\n\n // # *Helmholtz–Kohlrausch* Effect Extension.\n float C = (M * 35) / A_w;\n \n if (HK_mode)\n \{\n J = J - hue_angle_dependency_Hellwig2022(hr) * spow(C, 0.587f);\n \}\n\n\n\n // _h = hr\n // _2_h = 2 * hr\n // _3_h = 3 * hr\n // _4_h = 4 * hr\n float _h = hr;\n float _2_h = 2 * hr;\n float _3_h = 3 * hr;\n float _4_h = 4 * hr;\n \n // e_t = (\n // -0.0582 * np.cos(_h)\n // - 0.0258 * np.cos(_2_h)\n // - 0.1347 * np.cos(_3_h)\n // + 0.0289 * np.cos(_4_h)\n // - 0.1475 * np.sin(_h)\n // - 0.0308 * np.sin(_2_h)\n // + 0.0385 * np.sin(_3_h)\n // + 0.0096 * np.sin(_4_h)\n // + 1\n // )\n float e_t = (\n -0.0582f * cos(_h)\n - 0.0258f * cos(_2_h)\n - 0.1347f * cos(_3_h)\n + 0.0289f * cos(_4_h)\n - 0.1475f * sin(_h)\n - 0.0308f * sin(_2_h)\n + 0.0385f * sin(_3_h)\n + 0.0096f * sin(_4_h)\n + 1.0f\n );\n\n // # Computing achromatic response :math:`A` for the stimulus.\n // A = A = A_w * spow(J / 100, 1 / (surround.c * z))\n float A = A_w * spow(J / 100.0f, 1.0f / (surround.y * z));\n\n // # Computing *P_p_1* to *P_p_2*.\n // P_p_1 = 43 * surround.N_c * e_t\n // P_p_2 = A\n float P_p_1 = 43.0f * surround.z * e_t;\n float P_p_2 = A;\n\n\n // # Step 3\n // # Computing opponent colour dimensions :math:`a` and :math:`b`.\n // with sdiv_mode():\n // gamma = M / P_p_1\n float gamma = M / P_p_1;\n \n // a = gamma * np.cos(hr)\n float a = gamma * cos(hr);\n // b = gamma * np.sin(hr)\n float b = gamma * sin(hr);\n\n\n // # Step 4\n // # Applying post-adaptation non-linear response compression matrix.\n // RGB_a = (\n // vector_dot(\n // \[\n // \[460, 451, 288],\n // \[460, -891, -261],\n // \[460, -220, -6300],\n // ],\n // tstack(\[P_p_2, a, b]),\n // )\n // / 1403\n // )\n\n float panlrcm_data\[]=\n \{\n 460.0f, 451.0f, 288.0f,\n 460.0f, -891.0f, -261.0f,\n 460.0f, -220.0f, -6300.0f,\n \};\n float3x3 panlrcm;\n panlrcm.setArray(panlrcm_data);\n\n float3 RGB_a = vector_dot(panlrcm, float3(P_p_2, a, b)) / 1403.0f;\n\n // # Step 5\n // # Applying inverse post-adaptation non-linear response compression.\n // RGB_c = (\n // np.sign(RGB_a)\n // * 100\n // / F_L\[..., np.newaxis]\n // * spow(\n // (27.13 * np.absolute(RGB_a)) / (400 - np.absolute(RGB_a)),\n // 1 / 0.42,\n // )\n // )\n // float3 RGB_c = float3sign(RGB_a) * 100.0f / F_L * float3spow((27.13f * float3abs(RGB_a)) / (400.0f - float3abs(RGB_a)), 1.0f / 0.42f);\n\n\n // # Step 5\n // # Applying inverse post-adaptation non-linear response compression.\n // RGB_c = post_adaptation_non_linear_response_compression_inverse(RGB_a, F_L)\n // RGB_c_l = (\n // RGB_a\n // - post_adaptation_non_linear_response_compression_forward(\n // full(3, L_B), F_L\n // )\n // ) / (\n // d_post_adaptation_non_linear_response_compression_forward(\n // full(3, L_B), F_L\n // )\n // ) + L_B\n // RGB_c = np.where(RGB_c < L_B, RGB_c_l, RGB_c)\n\n // Adding 0.1 here seems to fix the inversion issue, not really clear on why I'm needing to do this\n // RGB_a = RGB_a + 0.1f;\n float3 RGB_c = post_adaptation_non_linear_response_compression_inverse(RGB_a + 0.1, F_L);\n // float3 RGB_c = RGB_a;\n float3 RGB_c_l = ( RGB_a + 0.1 - post_adaptation_non_linear_response_compression_forward( L_B, F_L)) / (d_post_adaptation_non_linear_response_compression_forward( L_B, F_L)) + L_B;\n\n float3 RGB_d;\n RGB_d.x = RGB_c.x < L_B.x ? RGB_c_l.x : RGB_c.x;\n RGB_d.y = RGB_c.y < L_B.y ? RGB_c_l.y : RGB_c.y;\n RGB_d.z = RGB_c.z < L_B.z ? RGB_c_l.z : RGB_c.z;\n\n\n // # Step 6\n // RGB = RGB_c / D_RGB\n float3 RGB = RGB_d / D_RGB;\n \n \n // # Step 7\n // XYZ = vector_dot(MATRIX_INVERSE_16, RGB)\n float3x3 MATRIX_INVERSE_16 = CAT_CAT16.invert();\n float3 XYZ = vector_dot(MATRIX_INVERSE_16, RGB);\n\n\n // return XYZ;\n return XYZ;\n\n \}\n\n\n\n\n void init()\n \{\n HALF_MIN = 0.0000000596046448f;\n HALF_MAX = 65504.0f;\n\n float CAT_CAT16_data\[]=\n \{\n 0.401288, 0.650173, -0.051461,\n -0.250268, 1.204414, 0.045854,\n -0.002079, 0.048952, 0.953127,\n \};\n\n float Modified_CAT16_data\[]=\n \{\n 0.656619, 0.342071, 0.00131062,\n -0.222571, 1.10658, 0.115987,\n -0.000634146, 0.05855, 0.942084,\n \};\n\n if (catDataSelection == 0)\n \{\n CAT_CAT16.setArray(CAT_CAT16_data);\n \}\n else if (catDataSelection == 1)\n \{\n CAT_CAT16.setArray(Modified_CAT16_data);\n \}\n else if (catDataSelection == 2)\n \{\n CAT_CAT16 = RGBPrimsToXYZMatrix(rxy,gxy,bxy,wxy,1.0f,1);\n \}\n\n\n \}\n\n\n void process()\n \{\n SampleType(src) source = src();\n float3 srcRGB(source.x, source.y, source.z);\n float3 dstRGB;\n float3 diagnostic;\n\n // diagnostic = srcRGB;\n\n // float3 surround(1.0f, 0.69f, 1.0f);\n // float3 XYZ_w(95.05f, 100.00f, 108.88f);\n\n if (direction == 0)\n \{\n float3 JMh = XYZ_to_Hellwig2022_linearExtension_JMh(srcRGB, XYZ_w, L_A, Y_b,surround,discount_illuminant);\n dstRGB = JMh;\n \}\n else if (direction == 1)\n \{\n float3 XYZ_out = Hellwig2022_linearExtension_JMh_to_XYZ(srcRGB, XYZ_w, L_A, Y_b, surround, discount_illuminant);\n dstRGB = XYZ_out;\n \}\n else if (direction == 2)\n \{\n\n dstRGB = srcRGB;\n \}\n else if (direction == 3)\n \{\n float3 compressed = post_adaptation_non_linear_response_compression_forward(srcRGB,L_A);\n float3 uncompressed = post_adaptation_non_linear_response_compression_inverse(compressed,L_A);\n dstRGB = uncompressed;\n \}\n else if (direction == 4)\n \{\n float3 JMh = XYZ_to_Hellwig2022_linearExtension_JMh(srcRGB, XYZ_w, L_A, Y_b, surround, discount_illuminant);\n float3 XYZ_out = Hellwig2022_linearExtension_JMh_to_XYZ(JMh , XYZ_w, L_A, Y_b, surround, discount_illuminant);\n dstRGB = XYZ_out;\n \}\n else if (direction == 5)\n \{ \n float angle = hue_angle_dependency_Hellwig2022(srcRGB.x);\n dstRGB = float3(angle,angle,angle);\n \}\n\n\n diagnostic = dstRGB;\n\n\n dst() = float4(diagnostic.x, diagnostic.y, diagnostic.z, source.w ); \n \}\n\};\n"
rebuild ""
hellwig2022_direction 1
hellwig2022_catDataSelection 2
hellwig2022_XYZ_w {95.05 100 108.88}
hellwig2022_L_A 318.31
hellwig2022_Y_b 20
hellwig2022_L_B {{parent.BlinkScript1.DRT_CAM_Kernel_L_B x2 0.7400000095} {parent.BlinkScript1.DRT_CAM_Kernel_L_B x2 0.3149999976} {parent.BlinkScript1.DRT_CAM_Kernel_L_B x2 1.659999967}}
hellwig2022_surround {1.25 0.6150000095 1.296000004}
hellwig2022_rxy {{parent.BlinkScript1.DRT_CAM_Kernel_rxy} {parent.BlinkScript1.DRT_CAM_Kernel_rxy}}
hellwig2022_gxy {{parent.BlinkScript1.DRT_CAM_Kernel_gxy} {parent.BlinkScript1.DRT_CAM_Kernel_gxy}}
hellwig2022_bxy {{parent.BlinkScript1.DRT_CAM_Kernel_bxy} {parent.BlinkScript1.DRT_CAM_Kernel_bxy}}
hellwig2022_wxy {{parent.BlinkScript1.DRT_CAM_Kernel_wxy} {parent.BlinkScript1.DRT_CAM_Kernel_wxy}}
rebuild_finalise ""
name BlinkScript5
label "\[python nuke.thisNode().knob('kernelSourceFile').value().split('/').pop(-1)]"
xpos -480
ypos -105
}
Group {
name PlotChromaticity3
xpos -480
ypos -41
addUserKnob {20 PlotChromaticity_tab l PlotChromaticity}
addUserKnob {6 use_gpu l "Use GPU if available" +STARTLINE}
use_gpu true
addUserKnob {26 ""}
addUserKnob {6 plot_input l "plot input" t "Enable plotting of the input pixels" +STARTLINE}
plot_input true
addUserKnob {41 input_gamut l gamut t "Set the gamut that the input colors are encoded in" -STARTLINE T GamutToXYZ.gamut}
addUserKnob {4 diagram l in t "Choose the type of chromaticity diagram: \nCIE 1931 xy Chromaticity Diagram\nCIE 1976 u' v' Uniform Chromaticity Scale Diagram" -STARTLINE M {"CIE 1931 xy" "CIE 1976 u' v'" "" ""}}
addUserKnob {6 enable_sample_color l "sample color" t "Enable plotting of the sampled color" +STARTLINE}
enable_sample_color true
addUserKnob {41 sample_color l color t "sample and plot selected color" T SampleColor.color}
addUserKnob {22 follow_viewer l "follow viewer" t "Follow the selected viewer node. This causes this node to automatically connect to whatever the followed viewer is connected to.\n\nThis is useful if you want to have a 2nd viewer showing a chromaticity plot for whever you're looking at in your main viewer." T "n = nuke.thisNode()\nnuke.root().begin()\nv = nuke.selectedNode()\nif not v or v.Class() != 'Viewer':\n nuke.message('Please select a viewer node to follow.')\nelse:\n v\['knobChanged'].setValue('v = nuke.activeViewer().node()\\nif v and v.name() == nuke.thisNode().name():\\n con = v.input(nuke.activeViewer().activeInput())\\n plt = nuke.toNode(\"\{0\}\")\\n plt.setInput(0, con)'.format(n.name()))" +STARTLINE}
addUserKnob {22 unfollow_viewer l "unfollow viewer" -STARTLINE T "n = nuke.thisNode()\nnuke.root().begin()\nv = nuke.selectedNode()\nif not v or v.Class() != 'Viewer':\n nuke.message('Please select a viewer node to unfollow.')\nelse:\n v\['knobChanged'].setValue('')"}
addUserKnob {26 plot_dimensions_label l " " T "<b>Chromaticity Diagram"}
addUserKnob {3 resolution l " resolution" t "resolution to output"}
resolution 2048
addUserKnob {7 right_margin l "right margin" R 1 1.5}
right_margin 1.1
addUserKnob {7 left_margin l "left margin" R 0 0.2}
left_margin 0.1
addUserKnob {6 draw_spectral_locus l "spectrum locus" t "draw the spectrum locus: the boundary of color the human eye can see." +STARTLINE}
draw_spectral_locus true
addUserKnob {6 draw_line_of_purples l "line of purples" t "draw the \"line of purples\"" -STARTLINE}
draw_line_of_purples true
addUserKnob {6 draw_planckian_locus l "planckian locus" t "Display the planckian locus or the blackbody locus." +STARTLINE}
draw_planckian_locus true
addUserKnob {6 gamut_grid l "gamut grid" t "Display a gamut boundary with a grid or dot pattern" +STARTLINE}
addUserKnob {41 gamut_gamutgrid l "" t "gamut for gamutgrid" -STARTLINE T RGBToXYZ_GamutGrid.gamut}
addUserKnob {4 gamut_grid_style l style t "Choose the style to display the gamut plot" -STARTLINE M {grid dots "" "" "" ""}}
addUserKnob {4 distribution l dist t "Which chromaticity space should the overlays be constructed in? \n\nYxy is familiar, but not very perceptually uniform.\n\nu'v' is designed to be more perceptually uniform." -STARTLINE M {"1931 Yxy" "1976 u'v'" "" ""}}
addUserKnob {7 density t "Density of the grid or points" R 10 100}
density 50
addUserKnob {6 gamut_a l "gamut a" t "Display a gamut outline" +STARTLINE}
gamut_a true
addUserKnob {41 gamut_a_1 l "" -STARTLINE T RGBToXYZ_GamutA.gamut}
addUserKnob {6 gamut_b l "gamut b" t "Display a gamut outline" +STARTLINE}
gamut_b true
addUserKnob {41 gamut_b_1 l "" -STARTLINE T RGBToXYZ_GamutB.gamut}
addUserKnob {6 gamut_c l "gamut c" t "Display a gamut outline" +STARTLINE}
gamut_c true
addUserKnob {41 gamut_c_1 l "" -STARTLINE T RGBToXYZ_GamutC.gamut}
addUserKnob {6 draw_pointers_gamut l "pointer's gamut" t "DrawPointer's gamut boundary" +STARTLINE}
addUserKnob {6 draw_pointers_samples l "pointers sample colors" t "show the individual pointer gamut samples" -STARTLINE}
addUserKnob {6 draw_macbeth_chart l "macbeth chart" t "draw a ColorChecker24 aka Macbeth Chart" +STARTLINE}
addUserKnob {6 coordinate_system l "coordinate system" t "Draw CIE xy coordinate grid x and y axes" +STARTLINE}
coordinate_system true
addUserKnob {6 map_overlays_to_input_gamut l "map overlays to input gamut" t "This maps the overlays like the spectral locus, pointer's gamut, and the gamut overlay to the working gamut instead of keeping them as XYZ.\n\nFor example if the input gamut is ACEScg, these overlays will be mapped to that. Note that this can cause most of the overlays to be negative or highly saturated which might harm the visual appearance." +STARTLINE}
map_overlays_to_input_gamut true
}
Group {
inputs 0
name GamutGrid1
xpos -920
ypos -201
postage_stamp true
addUserKnob {20 GamutGrid}
addUserKnob {3 style}
style {{!parent.gamut_grid_style}}
addUserKnob {3 distribution -STARTLINE}
distribution {{parent.distribution}}
addUserKnob {7 density R 10 150}
density {{parent.density}}
addUserKnob {26 ""}
addUserKnob {41 matrix T ColorMatrix.matrix}
addUserKnob {12 wxy}
wxy {{parent.RGBToXYZ_GamutGrid.wxy} {parent.RGBToXYZ_GamutGrid.wxy}}
}
ColorWheel {
inputs 0
format "512 512 0 0 512 512 1 square_512"
centerSaturation 1
fillFormat false
area {-170 -158 682 670}
name ColorWheel4
xpos -260
ypos -15
postage_stamp false
}
Crop {
box {0 0 {width} {height}}
crop false
name Crop2
xpos -260
ypos 27
}
Reformat {
type scale
scale {{max(parent.density/50,0.25)}}
resize distort
filter impulse
pbb true
name Reformat3
xpos -260
ypos 110
}
set N8728a800 [stack 0]
push $N8728a800
ContactSheet {
inputs 2
width {{width*columns}}
height {{height/pixel_aspect*rows}}
rows 1
columns 2
roworder TopBottom
name ContactSheet2
xpos -260
ypos 169
}
Dot {
name Dot1
label " "
note_font "Helvetica Bold"
note_font_size 24
note_font_color 0xa5a5a501
xpos -226
ypos 246
}
ColorWheel {
inputs 0
format "512 512 0 0 512 512 1 square_512"
fillFormat false
area {40 40 472 472}
name ColorWheel1
xpos -40
ypos -664
postage_stamp false
}
Reformat {
type scale
scale {{max(parent.density/50,0.25)}}
resize distort
filter impulse
pbb true
name Reformat1
xpos -40
ypos -628
}
Crop {
box {0 0 {width} {height}}
reformat true
name Crop1
xpos -40
ypos -602
}
Unpremult {
name Unpremult1
xpos -40
ypos -526
}
ColorMatrix {
matrix {
{{parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix} {parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix} {parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix}}
{{parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix} {parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix} {parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix}}
{{parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix} {parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix} {parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix}}
}
name ColorMatrix
label "RGB to XYZ"
xpos -40
ypos -415
}
Colorspace {
colorspace_in CIE-XYZ
colorspace_out CIE-Yxy
name Colorspace1
label "\[value colorspace_in] -> \[value colorspace_out]"
xpos -40
ypos -341
}
set Nefd57000 [stack 0]
Dot {
name Dot2
label " "
note_font "Helvetica Bold"
note_font_size 24
note_font_color 0xa5a5a501
xpos -556
ypos -331
}
Expression {
expr0 r
expr1 "4*g / ( -2*g + 12*b + 3)"
expr2 "9*b / ( -2*g + 12*b + 3)"
name Expression5
label "CIE Yxy to CIELuv"
xpos -590
ypos -304
disable {{!parent.distribution}}
}
Expression {
expr0 r
expr1 "(-(degrees(atan2(g-white.x, b-white.y))-180)+270)%360/360"
expr2 "hypot(g-white.x, b-white.y)"
expr3 a
name Expression3
xpos -590
ypos -261
cached true
addUserKnob {20 User}
addUserKnob {12 white}
white {{"parent.distribution ? 4*parent.wxy.x / ( -2 * parent.wxy.x + 12 * parent.wxy.y + 3) : parent.wxy"} {"parent.distribution ? 9*parent.wxy.y / ( -2*parent.wxy.x + 12*parent.wxy.y + 3) : parent.wxy"}}
}
set Nefd57c00 [stack 0]
Posterize {
channels rgb
Colors {{rint(parent.density/3*2)}}
name Posterize1
xpos -590
ypos -191
}
set N6a3b6000 [stack 0]
push $Nefd57c00
Dot {
name Dot15
xpos -446
ypos -257
}
Copy {
inputs 2
from0 rgba.blue
to0 rgba.blue
name Copy1
xpos -480
ypos -154
}
push $N6a3b6000
push $Nefd57c00
Dot {
name Dot16
xpos -666
ypos -257
}
Copy {
inputs 2
from0 rgba.green
to0 rgba.green
name Copy2
xpos -700
ypos -153
}
ContactSheet {
inputs 2
width {{width*columns}}
height {{height/pixel_aspect*rows}}
rows 1
columns 2
center true
roworder TopBottom
name ContactSheet3
xpos -590
ypos -106
}
Expression {
expr0 r
expr1 cos(radians(g*360))*b+white.x
expr2 sin(radians(g*360))*b+white.y
expr3 a
name Expression19
xpos -590
ypos -58
cached true
addUserKnob {20 User}
addUserKnob {12 white}
white {{parent.Expression3.white} {parent.Expression3.white}}
}
Expression {
expr0 r
expr1 "9*g / ( 6*g - 16*b + 12)"
expr2 "4*b/ ( 6*g - 16*b + 12)"
name Expression2
label "CIELuv to CIE Yxy"
xpos -590
ypos -16
disable {{!parent.distribution}}
}
Colorspace {
colorspace_in CIE-Yxy
colorspace_out CIE-XYZ
name Colorspace2
label "\[value colorspace_in] -> \[value colorspace_out]"
xpos -590
ypos 32
}
ColorMatrix {
matrix {
{{parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix} {parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix} {parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix}}
{{parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix} {parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix} {parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix}}
{{parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix} {parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix} {parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix}}
}
invert true
name ColorMatrix1
label "XYZ to RGB"
xpos -590
ypos 81
}
Clamp {
channels rgba
maximum_enable false
name ClampMin2
xpos -590
ypos 119
}
Clamp {
channels alpha
minimum 1
MinClampTo_enable true
MaxClampTo_enable true
name Clamp1
xpos -590
ypos 152
}
Premult {
name Premult1
xpos -590
ypos 194
}
Merge2 {
inputs 2
operation under
bbox B
name Merge2
xpos -590
ypos 242
}
Fill {
output alpha
name Fill1
xpos -590
ypos 297
}
Dot {
name Dot3
label " GRID"
note_font "Helvetica Bold"
note_font_size 24
note_font_color 0xa5a5a501
xpos -556
ypos 378
}
push $N8728a800
push $Nefd57000
Expression {
expr0 r
expr1 "4*g / ( -2*g + 12*b + 3)"
expr2 "9*b / ( -2*g + 12*b + 3)"
name Expression4
label "CIE Yxy to CIELuv"
xpos -40
ypos -280
disable {{!parent.distribution}}
}
Expression {
expr0 r
expr1 rint(g*Colors)/Colors
expr2 rint(b*Colors)/Colors
expr3 a
name Expression1
label rint
xpos -40
ypos -232
addUserKnob {20 User}
addUserKnob {7 Colors R 1 256}
Colors {{parent.density}}
}
Expression {
expr0 r
expr1 "9*g / ( 6*g - 16*b + 12)"
expr2 "4*b/ ( 6*g - 16*b + 12)"
name Expression6
label "CIELuv to CIE Yxy"
xpos -40
ypos -184
disable {{!parent.distribution}}
}
Colorspace {
colorspace_in CIE-Yxy
colorspace_out CIE-XYZ
name Colorspace3
label "\[value colorspace_in] -> \[value colorspace_out]"
xpos -40
ypos -112
}
ColorMatrix {
matrix {
{{parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix} {parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix} {parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix}}
{{parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix} {parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix} {parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix}}
{{parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix} {parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix} {parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix}}
}
invert true
name ColorMatrix3
label "XYZ to RGB"
xpos -40
ypos -57
}
Clamp {
channels alpha
minimum 1
MinClampTo_enable true
MaxClampTo_enable true
name Clamp4
xpos -40
}
Premult {
name Premult2
xpos -40
ypos 55
}
Merge2 {
inputs 2
operation under
bbox B
name Merge1
xpos -40
ypos 110
}
Clamp {
channels rgba
maximum_enable false
name ClampMin1
xpos -40
ypos 273
}
Dot {
name Dot4
label " DOTS"
note_font "Helvetica Bold"
note_font_size 24
note_font_color 0xa5a5a501
xpos -6
ypos 378
}
Switch {
inputs 2
which {{parent.style}}
name Switch1
xpos -257
ypos 483
}
ColorMatrix {
matrix {
{{parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix} {parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix} {parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix}}
{{parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix} {parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix} {parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix}}
{{parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix} {parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix} {parent.parent.RGBToXYZ_GamutGrid.ColorMatrix.matrix}}
}
name ColorMatrix2
label "RGB to XYZ"
xpos -257
ypos 560
}
Output {
name Output
xpos -257
ypos 740
}
ColorWheel {
inputs 0
format "256 256 0 0 256 256 1 square_256"
area {40 40 472 472}
name ColorWheel2
xpos -37
ypos -705
postage_stamp false
}
end_group
set Ne7d4a680 [stack 0]
Group {
name RGBToXYZ_GamutGrid
label "\[if \{\[value invert]\} \{return \"XYZ to \[value gamut]\"\} else \{return \"\[value gamut] to XYZ\"\}]\n\n"
xpos -1030
ypos -184
addUserKnob {20 GamutToXYZ_tab l GamutToXYZ}
addUserKnob {4 gamut t "Choose gamut" M {XYZ ACES ACEScg "Filmlight E-Gamut" Rec709 Rec2020 P3D60 P3D65 P3DCI "Arri AlexaWideGamut" REDDRAGONcolor REDDRAGONcolor2 REDcolor REDcolor2 REDcolor3 REDcolor4 REDWideGamutRGB "GoPro Protune Native" CanonCinemaGamut SonySGamut SonySGamut3Cine PanasonicVGamut "DJI D-Gamut" "Fujifilm F-Gamut" BMDFilmV1 BMD4kFilmV1 BMD4kFilmV3 BMD46kFilmV1 BMD46kFilmV3 BMDWideGamutV4 "AdobeRGB\t" AdobeWideGamutRGB ROMM RIMM ERIMM ProPhotoRGB RusselRGB SharpRGB AppleRGB BestRGB}}
gamut ACEScg
addUserKnob {6 invert +STARTLINE}
addUserKnob {26 ""}
addUserKnob {26 chromaticity_coordinates_label l " " T "<b>Chromaticity Coordinates</b>"}
addUserKnob {41 rxy T ColorMatrix.rxy}
addUserKnob {41 gxy T ColorMatrix.gxy}
addUserKnob {41 bxy T ColorMatrix.bxy}
addUserKnob {41 wxy T ColorMatrix.wxy}
addUserKnob {41 matrix T ColorMatrix.matrix}
}
Input {
inputs 0
name Input
xpos -40
ypos -10
}
ColorMatrix {
matrix {
{{curve(which) 1 0.9525524378 0.6624541879 0.7053968906 0.4123907983 0.6369580626 0.5049495697 0.4865709841 0.4451698363 0.6380076408 0.5070186853 0.4462202489 0.4300414324 0.4581649601 0.4878340662 0.4517004192 0.7352752686 0.5022571683 0.7160496712 0.7064827085 0.5990839601 0.6796444654 0.6481720209 0.6369580626 0.6390493512 0.6141571999 0.3724023998 0.60689044 0.4017650783 0.6065810919 0.5766690373 0.7165006995 0.797760427 0.797760427 0.797760427 0.7976718545 0.7015837431 0.8156226277 0.4496616423 0.6318944097} {curve(which) 0 0 0.1340042055 0.1640413404 0.3575843275 0.1446169019 0.2646814585 0.2656676769 0.2771343887 0.2147038579 0.3587769568 0.3157556653 0.3700728714 0.3832037449 0.3432727158 0.3178463876 0.06860940903 0.2929667532 0.1296834797 0.1288010478 0.2489254922 0.1522114277 0.1940581352 0.1446169019 0.1578372866 0.2825684249 0.4324877858 0.2193847299 0.4560420811 0.2203479856 0.1855582297 0.1010205746 0.1351858526 0.1351858526 0.1351858526 0.1351878047 0.1554162204 0.04716260359 0.3162561059 0.2053879201} {curve(which) 0 9.367863095e-05 0.1561876982 0.08101774752 0.180480808 0.1688809693 0.1830150485 0.1982172877 0.1722826511 0.09774444997 0.0868505761 0.190669477 0.152531758 0.1112773567 0.1215386018 0.1830992699 0.1465712637 0.1552320272 0.1047228053 0.1151721701 0.1024464965 0.1186000481 0.108225815 0.1688809693 0.1516760886 0.05183707923 0.1436725408 0.124180764 0.09264881909 0.123526901 0.1882286519 0.1467743814 0.03134934977 0.03134934977 0.03134934977 0.03133957833 0.09979832917 0.1372147948 0.1845382005 0.1270133406}}
{{curve(which) 0 0.3439664543 0.2722287476 0.2801307142 0.2126390189 0.2627002299 0.237623319 0.2289745659 0.209491685 0.2919537723 0.2207257152 0.1942579001 0.2022213936 0.1694435924 0.2289056629 0.2119505703 0.2866941094 0.1387997568 0.2612613738 0.2709796727 0.2150758505 0.2606855333 0.2830046713 0.2627002299 0.1743051857 0.2365771234 0.1383759677 0.1973138005 0.1721783578 0.2680045366 0.2973450124 0.258728236 0.2880711257 0.2880711257 0.2880711257 0.2880405784 0.3152042925 0.3790788651 0.2446159422 0.2276017666} {curve(which) 1 0.7281661034 0.6740817428 0.8202066422 0.7151686549 0.6779980659 0.6891706586 0.6917385459 0.7215952873 0.8238410354 0.839184761 0.7385566831 0.7585275769 0.8648257852 0.7808576822 0.7230190039 0.8429791331 0.910841465 0.8696421385 0.786606431 0.8850684762 0.7748944759 0.8131960034 0.6779980659 0.951146543 0.8896810412 0.911518693 0.943950057 0.8553914428 0.8326833844 0.6273635626 0.7246823311 0.7118432522 0.7118432522 0.7118432522 0.7118694782 0.6648360491 0.5769088268 0.6720442176 0.7383946776} {curve(which) 0 -0.07213255018 0.05368951708 -0.1003373638 0.07219231874 0.05930171534 0.07320601493 0.07928691059 0.06891305745 -0.1157948226 -0.05991046131 0.06718540192 0.03925102949 -0.03426937759 -0.009763340466 0.06503042579 -0.1296732277 -0.04964122549 -0.1309035122 -0.05758608505 -0.1001443192 -0.03558001295 -0.09620071948 0.05930171534 -0.1254517138 -0.1262581497 -0.04989464581 -0.1412638426 -0.02756982669 -0.1006879359 0.07529145479 0.01658944227 8.565396274e-05 8.565396274e-05 8.565396274e-05 8.991353388e-05 0.01995966583 0.04401229322 0.08333983272 0.0340035744}}
{{curve(which) 0 -3.863927134e-08 -0.005574660841 -0.1037815213 0.01933082007 0 0 0 0 0.0027982709 -0.0544523783 -0.04792318866 -0.0176958181 -0.1061859056 -0.02100777067 -0.01945115253 -0.07968087494 0.07801423222 -0.009676366113 -0.009677864611 -0.03206583485 -0.009310216643 -0.01825834997 0 -0.11669112 -0.02325225808 -0.1602820009 -0.1427432895 -0.10720893 -0.02941203304 0.02703136392 -2.906408625e-08 -3.236030111e-08 -3.236030111e-08 -3.236030111e-08 0 0 -0.01229703799 0.02518104948 0} {curve(which) 0 0 0.004060741514 -0.07290724665 0.1191947311 0.0280726999 0.0449459292 0.04511339962 0.04706057906 -0.06703422964 -0.0003228379355 -0.0002844714036 0.08768811822 0.02554347552 0.01782695204 0.01650637016 -0.3473432064 -0.3148325086 -0.2364816219 0.004600019194 -0.02765839547 -0.004612449091 -0.08316776901 0.0280726999 -0.5518454909 -0.4897170365 -0.171635136 -0.4278847873 0.07809129357 -0.08659287542 0.07068887353 0.05121183768 1.2621717e-08 1.2621717e-08 1.2621717e-08 -1.262213711e-08 0.04317118227 0.01672476344 0.1411857158 0.01001892332} {curve(which) 1 1.008825183 1.010339141 1.265746474 0.950532198 1.060985088 0.9638792276 1.043944359 0.9073553085 1.153293729 1.063571215 1.057001948 0.9388025999 1.089437366 1.01197505 1.011739731 1.51608181 1.325875998 1.335215807 1.094135642 1.148782015 1.102980375 1.190483928 1.060985088 1.745692492 1.590125084 1.409072995 1.65968585 1.118175387 1.205062628 0.9913375378 0.7738927603 0.8251045942 0.8251045942 0.8251045942 0.8248898983 0.8782252669 0.9955722094 0.9226909876 0.8150856495}}
}
invert {{parent.invert}}
name ColorMatrix
label "RGB to XYZ"
xpos -40
ypos 32
addUserKnob {20 Gamut}
addUserKnob {3 which}
which {{parent.gamut}}
addUserKnob {12 rxy}
rxy {{curve(which) 1 0.7347 0.713 0.8 0.64 0.708 0.68 0.68 0.68 0.684 0.7530442228 0.7530444911 0.6997470013 0.8786825105 0.7011810359 0.7011805919 0.780308 0.69848046 0.74 0.73 0.766 0.73 0.71 0.708 0.9173 0.7422 1.0625 0.9175 0.8608 0.7177 0.64 0.7347 0.7347 0.7347 0.7347 0.734699 0.69 0.6898 0.625 0.7351916376} {curve(which) 0 0.2653 0.293 0.3177 0.33 0.292 0.32 0.32 0.32 0.313 0.3278305767 0.3278310295 0.3290469303 0.3249640074 0.3290141556 0.3290136991 0.304253 0.19302645 0.27 0.28 0.275 0.28 0.31 0.292 0.2502 0.2859 0.3948 0.2983 0.3689 0.3171 0.33 0.2653 0.2653 0.2653 0.2653 0.265301 0.31 0.3206 0.34 0.2648083624}}
addUserKnob {12 gxy}
gxy {{curve(which) 0 0 0.165 0.18 0.3 0.17 0.265 0.265 0.265 0.221 0.2995702285 0.2995704905 0.304264039 0.3008887144 0.3006003047 0.3006003955 0.121595 0.32955538 0.17 0.14 0.225 0.165 0.21 0.17 0.2833 0.414 0.3689 0.2983 0.3282 0.228 0.21 0.1152 0.1596 0.1596 0.1596 0.159597 0.18 0.0736 0.28 0.2153361345} {curve(which) 1 1 0.83 0.9 0.6 0.797 0.69 0.69 0.69 0.848 0.700699322 0.7006994156 0.6236411451 0.6790547558 0.6837888343 0.6837888243 1.493994 1.02459662 1.14 0.855 0.8 0.84 0.88 0.797 1.7072 1.3035 0.7775 1.2835 0.6156 0.8616 0.71 0.8264 0.8404 0.8404 0.8404 0.840403 0.77 0.9003 0.595 0.7741596639}}
addUserKnob {12 bxy}
bxy {{curve(which) 0 0.0001 0.128 0.065 0.15 0.131 0.15 0.15 0.15 0.0861 0.07964206674 0.1450115843 0.1349139613 0.09539869461 0.1081544556 0.1453319462 0.095612 0.10844263 0.08 0.1 0.089 0.1 0.09 0.131 0.0856 0.0342 0.0956 0.0756 0.0783 0.1006 0.15 0.1566 0.0366 0.0366 0.0366 0.036598 0.1 0.1166 0.155 0.1301229508} {curve(which) 0 -0.077 0.044 -0.0805 0.06 0.046 0.06 0.06 0.06 -0.102 -0.05493795109 0.05109712509 0.03471744128 -0.02937932683 -0.008688175787 0.05161680362 -0.084589 -0.03467857 -0.1 -0.05 -0.087 -0.03 -0.08 0.046 -0.0708 -0.0833 -0.0332 -0.086 -0.0233 -0.082 0.06 0.0177 0.0001 0.0001 0.0001 0.000105 0.02 0.0374 0.07 0.03483606557}}
addUserKnob {12 wxy}
wxy {{curve(which) 0.33333333 0.32168 0.32168 0.3127 0.3127 0.3127 0.32168 0.3127 0.314 0.3127 0.3216831877 0.3216832104 0.3216832894 0.3216832894 0.3216832104 0.3216832894 0.3127 0.3127 0.3127 0.3127 0.3127 0.3127 0.3127 0.3127 0.3135 0.3135 0.3135 0.3127 0.3127 0.3127 0.3127 0.3457 0.3457 0.3457 0.3457 0.345704 0.33243 0.33333333 0.3127 0.3457} {curve(which) 0.33333333 0.33767 0.33767 0.329 0.329 0.329 0.33767 0.329 0.351 0.329 0.337673316 0.3376736101 0.3376734472 0.3376734472 0.3376736101 0.3376734472 0.329 0.329 0.329 0.329 0.329 0.329 0.329 0.329 0.3305 0.3305 0.3305 0.329 0.329 0.329 0.329 0.3585 0.3585 0.3585 0.3585 0.35854 0.34744 0.33333333 0.329 0.3585}}
}
Output {
name Output
xpos -40
ypos 86
}
end_group
ColorWheel {
inputs 0
format "512 512 0 0 512 512 1 square_512"
centerSaturation 1
fillFormat false
area {-196 -184 708 696}
name ColorWheel1
xpos -920
ypos 5
}
Crop {
box {0 0 {width} {height}}
name Crop1
xpos -920
ypos 87
}
BlackOutside {
name BlackOutside3
xpos -920
ypos 134
}
set Ne85bcc00 [stack 0]
Group {
name RGBToXYZ_GamutC
label "\[if \{\[value invert]\} \{return \"XYZ to \[value gamut]\"\} else \{return \"\[value gamut] to XYZ\"\}]\n\n"
xpos -1140
ypos 176
addUserKnob {20 GamutToXYZ_tab l GamutToXYZ}
addUserKnob {4 gamut t "Choose gamut" M {XYZ ACES ACEScg "Filmlight E-Gamut" "DaVinci WG" Rec709 Rec2020 P3D60 P3D65 P3DCI "Arri AlexaWideGamut" REDDRAGONcolor REDDRAGONcolor2 REDcolor REDcolor2 REDcolor3 REDcolor4 REDWideGamutRGB "GoPro Protune Native" CanonCinemaGamut SonySGamut SonySGamut3Cine PanasonicVGamut "DJI D-Gamut" "Fujifilm F-Gamut" BMDFilmV1 BMD4kFilmV1 BMD4kFilmV3 BMD46kFilmV1 BMD46kFilmV3 BMDWideGamutV4 "AdobeRGB\t" AdobeWideGamutRGB ROMM RIMM ERIMM ProPhotoRGB RusselRGB SharpRGB AppleRGB BestRGB}}
gamut Rec709
addUserKnob {6 invert +STARTLINE}
addUserKnob {26 ""}
addUserKnob {26 chromaticity_coordinates_label l " " T "<b>Chromaticity Coordinates</b>"}
addUserKnob {41 rxy T ColorMatrix.rxy}
addUserKnob {41 gxy T ColorMatrix.gxy}
addUserKnob {41 bxy T ColorMatrix.bxy}
addUserKnob {41 wxy T ColorMatrix.wxy}
addUserKnob {41 matrix T ColorMatrix.matrix}
}
Input {
inputs 0
name Input
xpos -40
ypos -10
}
ColorMatrix {
matrix {
{{curve(which) 1 0.9525524378 0.6624541879 0.7053968906 0.7006223798 0.4123907983 0.6369580626 0.5049495697 0.4865709841 0.4451698363 0.6380076408 0.5070186853 0.4462202489 0.4300414324 0.4581649601 0.4878340662 0.4517004192 0.7352752686 0.5022571683 0.7160496712 0.7064827085 0.5990839601 0.6796444654 0.6481720209 0.6369580626 0.6390493512 0.6141571999 0.3724023998 0.60689044 0.4017650783 0.6065810919 0.5766690373 0.7165006995 0.797760427 0.797760427 0.797760427 0.7976718545 0.7015837431 0.8156226277 0.4496616423 0.6318944097} {curve(which) 0 0 0.1340042055 0.1640413404 0.1487748176 0.3575843275 0.1446169019 0.2646814585 0.2656676769 0.2771343887 0.2147038579 0.3587769568 0.3157556653 0.3700728714 0.3832037449 0.3432727158 0.3178463876 0.06860940903 0.2929667532 0.1296834797 0.1288010478 0.2489254922 0.1522114277 0.1940581352 0.1446169019 0.1578372866 0.2825684249 0.4324877858 0.2193847299 0.4560420811 0.2203479856 0.1855582297 0.1010205746 0.1351858526 0.1351858526 0.1351858526 0.1351878047 0.1554162204 0.04716260359 0.3162561059 0.2053879201} {curve(which) 0 9.367863095e-05 0.1561876982 0.08101774752 0.101058729 0.180480808 0.1688809693 0.1830150485 0.1982172877 0.1722826511 0.09774444997 0.0868505761 0.190669477 0.152531758 0.1112773567 0.1215386018 0.1830992699 0.1465712637 0.1552320272 0.1047228053 0.1151721701 0.1024464965 0.1186000481 0.108225815 0.1688809693 0.1516760886 0.05183707923 0.1436725408 0.124180764 0.09264881909 0.123526901 0.1882286519 0.1467743814 0.03134934977 0.03134934977 0.03134934977 0.03133957833 0.09979832917 0.1372147948 0.1845382005 0.1270133406}}
{{curve(which) 0 0.3439664543 0.2722287476 0.2801307142 0.2741185129 0.2126390189 0.2627002299 0.237623319 0.2289745659 0.209491685 0.2919537723 0.2207257152 0.1942579001 0.2022213936 0.1694435924 0.2289056629 0.2119505703 0.2866941094 0.1387997568 0.2612613738 0.2709796727 0.2150758505 0.2606855333 0.2830046713 0.2627002299 0.1743051857 0.2365771234 0.1383759677 0.1973138005 0.1721783578 0.2680045366 0.2973450124 0.258728236 0.2880711257 0.2880711257 0.2880711257 0.2880405784 0.3152042925 0.3790788651 0.2446159422 0.2276017666} {curve(which) 1 0.7281661034 0.6740817428 0.8202066422 0.8736318946 0.7151686549 0.6779980659 0.6891706586 0.6917385459 0.7215952873 0.8238410354 0.839184761 0.7385566831 0.7585275769 0.8648257852 0.7808576822 0.7230190039 0.8429791331 0.910841465 0.8696421385 0.786606431 0.8850684762 0.7748944759 0.8131960034 0.6779980659 0.951146543 0.8896810412 0.911518693 0.943950057 0.8553914428 0.8326833844 0.6273635626 0.7246823311 0.7118432522 0.7118432522 0.7118432522 0.7118694782 0.6648360491 0.5769088268 0.6720442176 0.7383946776} {curve(which) 0 -0.07213255018 0.05368951708 -0.1003373638 -0.1477504075 0.07219231874 0.05930171534 0.07320601493 0.07928691059 0.06891305745 -0.1157948226 -0.05991046131 0.06718540192 0.03925102949 -0.03426937759 -0.009763340466 0.06503042579 -0.1296732277 -0.04964122549 -0.1309035122 -0.05758608505 -0.1001443192 -0.03558001295 -0.09620071948 0.05930171534 -0.1254517138 -0.1262581497 -0.04989464581 -0.1412638426 -0.02756982669 -0.1006879359 0.07529145479 0.01658944227 8.565396274e-05 8.565396274e-05 8.565396274e-05 8.991353388e-05 0.01995966583 0.04401229322 0.08333983272 0.0340035744}}
{{curve(which) 0 -3.863927134e-08 -0.005574660841 -0.1037815213 -0.09896291792 0.01933082007 0 0 0 0 0.0027982709 -0.0544523783 -0.04792318866 -0.0176958181 -0.1061859056 -0.02100777067 -0.01945115253 -0.07968087494 0.07801423222 -0.009676366113 -0.009677864611 -0.03206583485 -0.009310216643 -0.01825834997 0 -0.11669112 -0.02325225808 -0.1602820009 -0.1427432895 -0.10720893 -0.02941203304 0.02703136392 -2.906408625e-08 -3.236030111e-08 -3.236030111e-08 -3.236030111e-08 0 0 -0.01229703799 0.02518104948 0} {curve(which) 0 0 0.004060741514 -0.07290724665 -0.1378953159 0.1191947311 0.0280726999 0.0449459292 0.04511339962 0.04706057906 -0.06703422964 -0.0003228379355 -0.0002844714036 0.08768811822 0.02554347552 0.01782695204 0.01650637016 -0.3473432064 -0.3148325086 -0.2364816219 0.004600019194 -0.02765839547 -0.004612449091 -0.08316776901 0.0280726999 -0.5518454909 -0.4897170365 -0.171635136 -0.4278847873 0.07809129357 -0.08659287542 0.07068887353 0.05121183768 1.2621717e-08 1.2621717e-08 1.2621717e-08 -1.262213711e-08 0.04317118227 0.01672476344 0.1411857158 0.01001892332} {curve(which) 1 1.008825183 1.010339141 1.265746474 1.325916052 0.950532198 1.060985088 0.9638792276 1.043944359 0.9073553085 1.153293729 1.063571215 1.057001948 0.9388025999 1.089437366 1.01197505 1.011739731 1.51608181 1.325875998 1.335215807 1.094135642 1.148782015 1.102980375 1.190483928 1.060985088 1.745692492 1.590125084 1.409072995 1.65968585 1.118175387 1.205062628 0.9913375378 0.7738927603 0.8251045942 0.8251045942 0.8251045942 0.8248898983 0.8782252669 0.9955722094 0.9226909876 0.8150856495}}
}
invert {{parent.invert}}
name ColorMatrix
label "RGB to XYZ"
xpos -40
ypos 32
addUserKnob {20 Gamut}
addUserKnob {3 which}
which {{parent.gamut}}
addUserKnob {12 rxy}
rxy {{curve(which) 1 0.7347 0.713 0.8 0.8 0.64 0.708 0.68 0.68 0.68 0.684 0.7530442228 0.7530444911 0.6997470013 0.8786825105 0.7011810359 0.7011805919 0.780308 0.69848046 0.74 0.73 0.766 0.73 0.71 0.708 0.9173 0.7422 1.0625 0.9175 0.8608 0.7177 0.64 0.7347 0.7347 0.7347 0.7347 0.734699 0.69 0.6898 0.625 0.7351916376} {curve(which) 0 0.2653 0.293 0.3177 0.313 0.33 0.292 0.32 0.32 0.32 0.313 0.3278305767 0.3278310295 0.3290469303 0.3249640074 0.3290141556 0.3290136991 0.304253 0.19302645 0.27 0.28 0.275 0.28 0.31 0.292 0.2502 0.2859 0.3948 0.2983 0.3689 0.3171 0.33 0.2653 0.2653 0.2653 0.2653 0.265301 0.31 0.3206 0.34 0.2648083624}}
addUserKnob {12 gxy}
gxy {{curve(which) 0 0 0.165 0.18 0.1682 0.3 0.17 0.265 0.265 0.265 0.221 0.2995702285 0.2995704905 0.304264039 0.3008887144 0.3006003047 0.3006003955 0.121595 0.32955538 0.17 0.14 0.225 0.165 0.21 0.17 0.2833 0.414 0.3689 0.2983 0.3282 0.228 0.21 0.1152 0.1596 0.1596 0.1596 0.159597 0.18 0.0736 0.28 0.2153361345} {curve(which) 1 1 0.83 0.9 0.9877 0.6 0.797 0.69 0.69 0.69 0.848 0.700699322 0.7006994156 0.6236411451 0.6790547558 0.6837888343 0.6837888243 1.493994 1.02459662 1.14 0.855 0.8 0.84 0.88 0.797 1.7072 1.3035 0.7775 1.2835 0.6156 0.8616 0.71 0.8264 0.8404 0.8404 0.8404 0.840403 0.77 0.9003 0.595 0.7741596639}}
addUserKnob {12 bxy}
bxy {{curve(which) 0 0.0001 0.128 0.065 0.079 0.15 0.131 0.15 0.15 0.15 0.0861 0.07964206674 0.1450115843 0.1349139613 0.09539869461 0.1081544556 0.1453319462 0.095612 0.10844263 0.08 0.1 0.089 0.1 0.09 0.131 0.0856 0.0342 0.0956 0.0756 0.0783 0.1006 0.15 0.1566 0.0366 0.0366 0.0366 0.036598 0.1 0.1166 0.155 0.1301229508} {curve(which) 0 -0.077 0.044 -0.0805 -0.1155 0.06 0.046 0.06 0.06 0.06 -0.102 -0.05493795109 0.05109712509 0.03471744128 -0.02937932683 -0.008688175787 0.05161680362 -0.084589 -0.03467857 -0.1 -0.05 -0.087 -0.03 -0.08 0.046 -0.0708 -0.0833 -0.0332 -0.086 -0.0233 -0.082 0.06 0.0177 0.0001 0.0001 0.0001 0.000105 0.02 0.0374 0.07 0.03483606557}}
addUserKnob {12 wxy}
wxy {{curve(which) 0.33333333 0.32168 0.32168 0.3127 0.3127 0.3127 0.3127 0.32168 0.3127 0.314 0.3127 0.3216831877 0.3216832104 0.3216832894 0.3216832894 0.3216832104 0.3216832894 0.3127 0.3127 0.3127 0.3127 0.3127 0.3127 0.3127 0.3127 0.3135 0.3135 0.3135 0.3127 0.3127 0.3127 0.3127 0.3457 0.3457 0.3457 0.3457 0.345704 0.33243 0.33333333 0.3127 0.3457} {curve(which) 0.33333333 0.33767 0.33767 0.329 0.329 0.329 0.329 0.33767 0.329 0.351 0.329 0.337673316 0.3376736101 0.3376734472 0.3376734472 0.3376736101 0.3376734472 0.329 0.329 0.329 0.329 0.329 0.329 0.329 0.329 0.3305 0.3305 0.3305 0.329 0.329 0.329 0.329 0.3585 0.3585 0.3585 0.3585 0.35854 0.34744 0.33333333 0.329 0.3585}}
}
Output {
name Output
xpos -40
ypos 86
}
end_group
Position {
translate {{parent.Reformat1.box_width+Rectangle1.area.r+input.width} {parent.ReformatBox4.box_width-input.height}}
name Position6
xpos -1140
ypos 254
}
push $Ne85bcc00
Group {
name RGBToXYZ_GamutB
label "\[if \{\[value invert]\} \{return \"XYZ to \[value gamut]\"\} else \{return \"\[value gamut] to XYZ\"\}]\n\n"
xpos -1030
ypos 176
addUserKnob {20 GamutToXYZ_tab l GamutToXYZ}
addUserKnob {4 gamut t "Choose gamut" M {XYZ ACES ACEScg "Filmlight E-Gamut" "DaVinci WG" Rec709 Rec2020 P3D60 P3D65 P3DCI "Arri AlexaWideGamut" REDDRAGONcolor REDDRAGONcolor2 REDcolor REDcolor2 REDcolor3 REDcolor4 REDWideGamutRGB "GoPro Protune Native" CanonCinemaGamut SonySGamut SonySGamut3Cine PanasonicVGamut "DJI D-Gamut" "Fujifilm F-Gamut" BMDFilmV1 BMD4kFilmV1 BMD4kFilmV3 BMD46kFilmV1 BMD46kFilmV3 BMDWideGamutV4 "AdobeRGB\t" AdobeWideGamutRGB ROMM RIMM ERIMM ProPhotoRGB RusselRGB SharpRGB AppleRGB BestRGB}}
gamut P3D65
addUserKnob {6 invert +STARTLINE}
addUserKnob {26 ""}
addUserKnob {26 chromaticity_coordinates_label l " " T "<b>Chromaticity Coordinates</b>"}
addUserKnob {41 rxy T ColorMatrix.rxy}
addUserKnob {41 gxy T ColorMatrix.gxy}
addUserKnob {41 bxy T ColorMatrix.bxy}
addUserKnob {41 wxy T ColorMatrix.wxy}
addUserKnob {41 matrix T ColorMatrix.matrix}
}
Input {
inputs 0
name Input
xpos -40