ACESGamutConvert - 图1

    1. // ACES AP1 Gamut convert from other Color Gamuts conversion V.3.1 node by Saul Espinosa for Redshift
    2. // Updated 6/21/2021 - V3.2 - Added ACEScg inversion Matrices
    3. // This file is licensed under Apache 2.0 license
    4. #define NUM_MODES 7
    5. shader ACESconvert
    6. [[ string help = "Converts an input color gamut to ACEScg",
    7. string label = "ACES Gamut Convert" ]]
    8. (
    9. color input = 0.5
    10. [[ string label = "Input" ]],
    11. int mode = 0
    12. [[ string label = "Color Space",
    13. string widget = "mapper",
    14. string options = "sRGB:0|Rec. 709:1|Rec. 2020:2|Display P3:3|DCI-P3:4|V-Gamut:5|S-Gamut:6"]],
    15. int invert = 0
    16. [[ string widget = "checkBox",
    17. string label = "Inverse",
    18. int connectable = 0 ]],
    19. output color outColor = 0
    20. [[ string label = "Color" ]]
    21. )
    22. {
    23. matrix aces_tm[NUM_MODES] = {
    24. // sRGB
    25. { 0.61313, 0.07012, 0.02058, 0,
    26. 0.33953, 0.91639, 0.10957, 0,
    27. 0.04741, 0.01345, 0.86985, 0,
    28. 0, 0, 0, 1 },
    29. // Rec. 709
    30. { 0.61309, 0.07019, 0.02061, 0,
    31. 0.33952, 0.91635, 0.10956, 0,
    32. 0.04737, 0.01345, 0.86981, 0,
    33. 0, 0, 0, 1 },
    34. // Rec. 2020
    35. { 0.97489, 0.00217, 0.00479, 0,
    36. 0.01959, 0.99553, 0.02453, 0,
    37. 0.05505, 0.00228, 0.97067, 0,
    38. 0, 0, 0, 1 },
    39. // Display P3 D65
    40. { 0.73579, 0.04717, 0.00356, 0,
    41. 0.21216, 0.93804, 0.04114, 0,
    42. 0.05203, 0.014774, 0.95529, 0,
    43. 0, 0, 0, 1 },
    44. // DCI-P3 D60
    45. { 0.69472, 0.04297, 0.00361, 0,
    46. 0.25626, 0.94617, 0.04301, 0,
    47. 0.04901, 0.01084, 0.95336, 0,
    48. 0, 0, 0, 1 },
    49. // V-Gamut
    50. { 1.04866, -0.02939, -0.00331, 0,
    51. 0.00955, 1.14580, -0.00560, 0,
    52. -0.05821, -0.11641, 1.00892, 0,
    53. 0, 0, 0, 1 },
    54. // S-Gamut
    55. { 1.09007, -0.03055, -0.00344, 0,
    56. -0.03523, 1.18025, -0.00255, 0,
    57. -0.05843, -0.14969, 1.00089, 0,
    58. 0, 0, 0, 1 }
    59. };
    60. matrix aces_tm_inv[NUM_MODES] = {
    61. // invert ACES sRGB
    62. { 1.70487, -0.130101, -0.0239479, 0,
    63. -0.621708, 1.1407, -0.128979, 0,
    64. -0.0833087, -0.0105471, 1.15292, 0,
    65. 0, 0, 0, 1 },
    66. // invert ACES Rec. 709
    67. { 1.70507, -0.130251, -0.023995, 0,
    68. -0.621798, 1.14081, -0.128961, 0,
    69. -0.0832433, -0.010547, 1.15298, 0,
    70. 0, 0, 0, 1 },
    71. // invert ACES Rec. 2020
    72. { 1.02608, -0.00222513, -0.00500722, 0,
    73. -0.0187585, 1.00459, -0.0252946, 0,
    74. -0.0581487, -0.00223348, 1.03056, 0,
    75. 0, 0, 0, 1 },
    76. // invert ACES Display P3 D65
    77. { 1.37922, -0.069321, -0.0021545, 0,
    78. -0.30886, 1.08230, -0.045459, 0,
    79. -0.070343, -0.012963, 1.04762, 0,
    80. 0, 0, 0, 1 },
    81. // invert ACES DCI-P3 D60
    82. { 1.46412, -0.0664636, -0.00254562, 0,
    83. -0.393324, 1.07529, -0.0470216, 0,
    84. -0.070795, -0.00880969, 1.04959, 0,
    85. 0, 0, 0, 1 },
    86. // invert ACES V-Gamut
    87. { 0.953553, 0.0247907, 0.00326596, 0,
    88. -0.00768311, 0.873045, 0.00482062, 0,
    89. 0.0541291, 0.102163, 0.991903, 0,
    90. 0, 0, 0, 1 },
    91. // invert ACES S-Gamut
    92. { 0.918326, 0.0241784, 0.00321783, 0,
    93. 0.0275364, 0.848277, 0.00225582, 0,
    94. 0.0577284, 0.128277, 0.999636, 0,
    95. 0, 0, 0, 1 }
    96. };
    97. if (mode >= 0 && mode < NUM_MODES)
    98. {
    99. float r = input[0], g = input[1], b = input[2];
    100. outColor = transform(invert ? aces_tm_inv[mode] : aces_tm[mode], vector(r, g, b));
    101. }
    102. else
    103. {
    104. outColor = 0;
    105. }
    106. }