-
Notifications
You must be signed in to change notification settings - Fork 8
/
Channel-Saturation.dctl
46 lines (36 loc) · 1.82 KB
/
Channel-Saturation.dctl
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
DEFINE_UI_PARAMS(timeGamma, Timeline Gamma, DCTLUI_COMBO_BOX, 0, {sceneGam, linGam}, {Scene,Linear})
DEFINE_UI_PARAMS(r_Saturation, Red Saturation, DCTLUI_SLIDER_FLOAT, 1.0, 0, 1, 0.05)
DEFINE_UI_PARAMS(r_UpThreshold, Red Upper Threshold, DCTLUI_SLIDER_FLOAT, 1.0, 0.005, 1, 0.05)
DEFINE_UI_PARAMS(r_LoThreshold, Red Lower Threshold, DCTLUI_SLIDER_FLOAT, 0.0, 0, .995, 0.05)
DEFINE_UI_PARAMS(g_Saturation, Green Saturation, DCTLUI_SLIDER_FLOAT, 1.0, 0, 1, 0.05)
DEFINE_UI_PARAMS(g_UpThreshold, Green Upper Threshold, DCTLUI_SLIDER_FLOAT, 1.0, 0.005, 1, 0.05)
DEFINE_UI_PARAMS(g_LoThreshold, Green Lower Threshold, DCTLUI_SLIDER_FLOAT, 0.0, 0, .995, 0.05)
DEFINE_UI_PARAMS(b_Saturation, Blue Saturation, DCTLUI_SLIDER_FLOAT, 1.0, 0, 1, 0.05)
DEFINE_UI_PARAMS(b_UpThreshold, Blue Upper Threshold, DCTLUI_SLIDER_FLOAT, 1.0, 0.005, 1, 0.05)
DEFINE_UI_PARAMS(b_LoThreshold, Blue Lower Threshold, DCTLUI_SLIDER_FLOAT, 0.0, 0, .995, 0.05)
__DEVICE__ float rec_to_lin(float x) {
if(x < 0.081f) return (x / 4.5f);
else return _powf((x + 0.099f)/1.099f,(1.0f/0.45f));
}
__DEVICE__ float lin_to_rec(float x) {
if(x < .0018f) return 4.5f * x;
else return 1.099f * _powf(x,0.45f) - 0.099f;
}
__DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y, float p_R, float p_G, float p_B)
{
if(timeGamma == linGam) {
p_R = lin_to_rec(p_R);
p_G = lin_to_rec(p_G);
p_B = lin_to_rec(p_B);
}
if(p_R <= r_UpThreshold && p_R >= r_LoThreshold) p_R *= r_Saturation;
if(p_G <= g_UpThreshold && p_G >= g_LoThreshold) p_G *= g_Saturation;
if(p_B <= b_UpThreshold && p_B >= b_LoThreshold) p_B *= b_Saturation;
//float rL = 0.212639005871510f * p_R + 0.715168678767756f * p_G + 0.072192315360734f * p_B; // Rec.709
if(timeGamma == linGam) {
p_R = rec_to_lin(p_R);
p_G = rec_to_lin(p_G);
p_B = rec_to_lin(p_B);
}
return make_float3(p_R,p_G,p_B);
}