-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsateq.ctl
More file actions
111 lines (93 loc) · 3.01 KB
/
sateq.ctl
File metadata and controls
111 lines (93 loc) · 3.01 KB
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
/**
* Equalizer by saturation ART CTL script
*
* Copyright 2023 Alberto Griggio <alberto.griggio@gmail.com>
*
* ART is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ART is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ART. If not, see <http://www.gnu.org/licenses/>.
*/
// @ART-label: "$CTL_EQUALIZER_BY_SATURATION;Equalizer by saturation"
// @ART-colorspace: "rec2020"
import "_artlib";
float[3] to_hsl(float r, float g, float b)
{
return rgb2okhcl(r, g, b);
}
float[3] to_rgb(float hsl[3])
{
return okhcl2rgb(hsl);
}
float sat(float r, float g, float b)
{
return to_hsl(r, g, b)[1];
}
const int num_bands = 6;
const float centers[6] = { 0.002, 0.05, 0.12, 0.35, 0.75, 0.9 };
const float sigma2[6] = { 0.001, 0.002, 0.0025, 0.025, 0.05, 0.05 };
float gauss_sum()
{
float res = 0;
for (int i = 0; i < num_bands; i = i+1) {
res = res + gauss(centers[i], sigma2[i], 0);
}
return res;
}
const float w_sum = gauss_sum();
float get_factor(float s,
int gray, int muted, int average, int vivid, int pure)
{
const float f[num_bands] = { gray, muted, average, vivid, pure, pure };
float res = 0;
for (int i = 0; i < num_bands; i = i+1) {
res = res + f[i]/100 * gauss(centers[i], sigma2[i], s);
}
return res / w_sum;
}
const float noise = pow(2, -16);
// @ART-param: ["mode", "$CTL_TARGET;Target", ["$TP_COLORCORRECTION_S", "$TP_COLORCORRECTION_L", "$TP_COLORCORRECTION_H"]]
// @ART-param: ["gray", "$CTL_NEUTRAL;Neutral", -100, 100, 0]
// @ART-param: ["muted", "$CTL_MUTED;Muted", -100, 100, 0]
// @ART-param: ["average", "$CTL_AVERAGE;Average", -100, 100, 0]
// @ART-param: ["vivid", "$CTL_VIVID;Vivid", -100, 100, 0]
// @ART-param: ["pure", "$CTL_PURE;Pure", -100, 100, 0]
void ART_main(varying float r, varying float g, varying float b,
output varying float rout,
output varying float gout,
output varying float bout,
int mode,
int gray,
int muted,
int average,
int vivid,
int pure)
{
float hsl[3] = to_hsl(r, g, b);
float f = get_factor(hsl[1], gray, muted, average, vivid, pure);
if (mode == 0) {
float s = fmax(1 + f*2, 0);
hsl[1] = hsl[1] * s;
} else if (mode == 1) {
float s = pow(2, f);
hsl[2] = hsl[2] * s;
} else {
float s = f*f;
if (f < 0) {
s = -s;
}
hsl[0] = hsl[0] + s * M_PI;
}
float rgb[3] = to_rgb(hsl);
rout = rgb[0];
gout = rgb[1];
bout = rgb[2];
}