-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathshadowboost.ctl
More file actions
42 lines (32 loc) · 1.14 KB
/
shadowboost.ctl
File metadata and controls
42 lines (32 loc) · 1.14 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
// @ART-colorspace: "rec2020"
// @ART-label: "$CTL_SHADOW_LIFTING;Shadow lifting"
import "_artlib";
float boost(float x, float base, float logb)
{
float l = pow(clamp(x, 0, 1), 0.1);
float y = log(x * (base - 1) + 1) / logb;
return intp(l, x, (pow(100, y) - 1) / (100 - 1));
}
// @ART-param: ["strength", "$CTL_STRENGTH;Strength", -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 strength)
{
const float base = ite(strength > 0, 1000 + 100 * strength, 1000 + 9 * strength);
const float logb = log(base);
float hue = rgb2hsl(r, g, b)[0];
float rgb[3] = { fmax(r, 0), fmax(g, 0), fmax(b, 0) };
float f = 0.18 / boost(0.18, base, logb);
float off = 1e-4 - boost(1e-4, base, logb);
for (int i = 0; i < 3; i = i+1) {
rgb[i] = fmax(boost(rgb[i], base, logb) * f + off, 0);
}
float hsl[3] = rgb2hsl(rgb[0], rgb[1], rgb[2]);
hsl[0] = hue;
rgb = hsl2rgb(hsl);
rout = rgb[0];
gout = rgb[1];
bout = rgb[2];
}