-
Notifications
You must be signed in to change notification settings - Fork 13
/
GamutCompress.nk
130 lines (130 loc) · 4.81 KB
/
GamutCompress.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
set cut_paste_input [stack 0]
push $cut_paste_input
Group {
name GamutCompress
addUserKnob {20 GamutCompress}
addUserKnob {18 threshold t "Percentage of the outer gamut boundary to affect. A value of 0.2 means 20% of the outer gamut will be utilized for gamut compression." R 0 0.2}
threshold 0.15
addUserKnob {6 threshold_panelDropped l "panel dropped state" -STARTLINE +HIDDEN}
addUserKnob {35 distance_presets l distance t "choose distance presets for common digital cinema camera source gamuts" M {"presets/ACEScg from Filmlight E-Gamut" "knobs this \{cyan 0.122 magenta 0.201 yellow 0.139\}" "presets/ACEScg from Alexa Wide Gamut" "knobs this \{cyan 0.078 magenta 0.22 yellow 0.056\}" "presets/ACEScg from RedWideGamutRGB" "knobs this \{cyan 0.143 magenta 0.239 yellow 0.316\}" "presets/ACEScg from Sony S-Gamut3.Cine" "knobs this \{cyan 0.074 magenta 0.264 yellow 0.049\}" "presets/ACEScg from Sony S-Gamut3" "knobs this \{cyan 0.089 magenta 0.182 yellow 0.004\}" "presets/ACEScg from Panasonic V-Gamut" "knobs this \{cyan 0.06 magenta 0.148 yellow 0.012\}"}}
addUserKnob {7 cyan t "Maximum distance beyond the green-blue gamut boundary to compress to the gamut boundary." R 0 0.4}
cyan 0.1
addUserKnob {7 magenta t "Maximum distance beyond the blue-red gamut boundary to compress to the gamut boundary." R 0 0.4}
magenta 0.2
addUserKnob {7 yellow t "Maximum distance beyond the red-green gamut boundary to compress to the gamut boundary." R 0 0.4}
yellow 0.1
addUserKnob {4 direction M {forward inverse}}
addUserKnob {20 info_tab l Info}
addUserKnob {26 info_label l " " T "<style> a:link \{ color: #ccc \}</style>\n<font color=#ccc>\n<b>GamutCompress v0.7</b><br>\nmaps out of gamut colors back into gamut.\n<br><br><a href=https://github.com/jedypod/gamut-compress>Documentation</a>"}
addUserKnob {26 about_label l " " T "<style> a:link \{ color: #ccc \}</style>\n<font color=#ccc><br>\n<b>About</b><br>\nWritten by <a href=https://github.com/jedypod color=red>Jed Smith</a> <br> with <a href=https://community.acescentral.com/t/rgb-saturation-gamut-mapping-approach-and-a-comp-vfx-perspective>help</a> from the <a href=https://community.acescentral.com/c/aces-development-acesnext/vwg-aces-gamut-mapping-working-group>ACES Gamut Mapping VWG</a>"}
}
Input {
inputs 0
name Input
xpos -40
ypos -298
}
Dot {
name Dot5
xpos -6
ypos -186
}
set N50366260 [stack 0]
Expression {
channel0 rgba
expr0 max(r,g,b)
channel1 none
channel2 none
channel3 none
name Norm_MaxRGB
xpos -260
ypos -189
}
Dot {
name Dot6
xpos -226
ypos -126
}
set N4b7ba180 [stack 0]
Dot {
name Dot8
xpos -226
ypos 54
}
push $N4b7ba180
push $N50366260
MergeExpression {
inputs 2
expr0 Ar==0?0:(Ar-Br)/fabs(Ar)
expr1 Ag==0?0:(Ag-Bg)/fabs(Ag)
expr2 Ab==0?0:(Ab-Bb)/fabs(Ab)
name RGB_to_InverseRGBRatios
xpos -40
ypos -129
}
Dot {
name Dot9
xpos -6
ypos -96
}
set N4b7ae1c0 [stack 0]
Expression {
expr0 r<t.r?r:pow(r-t.r+s.r*sqrt(s.r*s.r/4),2)/(s.r*s.r)-s.r*s.r/4+t.r
expr1 g<t.g?g:pow(g-t.g+s.g*sqrt(s.g*s.g/4),2)/(s.g*s.g)-s.g*s.g/4+t.g
expr2 b<t.b?b:pow(b-t.b+s.b*sqrt(s.b*s.b/4),2)/(s.b*s.b)-s.b*s.b/4+t.b
name uncompress
xpos -150
ypos -70
addUserKnob {20 Params_tab l Params}
addUserKnob {18 t}
t {{1-parent.threshold} {1-parent.threshold} {1-parent.threshold}}
addUserKnob {6 t_panelDropped l "panel dropped state" -STARTLINE +HIDDEN}
addUserKnob {18 d R 0 2}
d {{1+parent.cyan} {1+parent.magenta} {1+parent.yellow}}
addUserKnob {6 d_panelDropped l "panel dropped state" -STARTLINE +HIDDEN}
addUserKnob {18 s}
s {{parent.compress.s} {parent.compress.s} {parent.compress.s}}
addUserKnob {6 s_panelDropped l "panel dropped state" -STARTLINE +HIDDEN}
}
push $N4b7ae1c0
Expression {
expr0 r<t.r?r:s.r*sqrt(r-t.r+s.r*s.r/4)-s.r*sqrt(s.r*s.r/4)+t.r
expr1 g<t.g?g:s.g*sqrt(g-t.g+s.g*s.g/4)-s.g*sqrt(s.g*s.g/4)+t.g
expr2 b<t.b?b:s.b*sqrt(b-t.b+s.b*s.b/4)-s.b*sqrt(s.b*s.b/4)+t.b
maskChannelMask rgba.red
name compress
xpos 70
ypos -70
addUserKnob {20 Params_tab l Params}
addUserKnob {18 t}
t {{1-parent.threshold} {1-parent.threshold} {1-parent.threshold}}
addUserKnob {6 t_panelDropped l "panel dropped state" -STARTLINE +HIDDEN}
addUserKnob {18 d R 1 2}
d {{1+parent.cyan} {1+parent.magenta} {1+parent.yellow}}
addUserKnob {6 d_panelDropped l "panel dropped state" -STARTLINE +HIDDEN}
addUserKnob {18 s}
s {{(1-this.t)/sqrt(max(1.001,d)-1)} {(1-this.t)/sqrt(max(1.001,d)-1)} {(1-this.t)/sqrt(max(1.001,d)-1)}}
addUserKnob {6 s_panelDropped l "panel dropped state" -STARTLINE +HIDDEN}
}
Switch {
inputs 2
which {{parent.direction}}
name SwitchDirection
xpos -40
ypos -9
}
MergeExpression {
inputs 2
expr0 Ar-fabs(Ar)*Br
expr1 Ag-fabs(Ag)*Bg
expr2 Ab-fabs(Ab)*Bb
name InverseRGBRatios_to_RGB
xpos -40
ypos 51
}
Output {
name Output
xpos -40
ypos 158
}
end_group