-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConvSLD.dctl
63 lines (58 loc) · 3.61 KB
/
ConvSLD.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/************
ConvSLD ver 2.0 by Passiflora Tsui
for using convolution in Davinci Resolve
This slider version is convenient for mouse operation
************/
DEFINE_UI_PARAMS(ker11, Row 1 Col 1, DCTLUI_SLIDER_FLOAT, 0.0, -20.0, 20.0, 0.1)
DEFINE_UI_PARAMS(ker12, Row 1 Col 2, DCTLUI_SLIDER_FLOAT, -1.0, -20.0, 20.0, 0.1)
DEFINE_UI_PARAMS(ker13, Row 1 Col 3, DCTLUI_SLIDER_FLOAT, 0.0, -20.0, 20.0, 0.1)
DEFINE_UI_PARAMS(ker21, Row 2 Col 1, DCTLUI_SLIDER_FLOAT, -1.0, -20.0, 20.0, 0.1)
DEFINE_UI_PARAMS(ker22, Row 2 Col 2, DCTLUI_SLIDER_FLOAT, 4.0, -20.0, 20.0, 0.1)
DEFINE_UI_PARAMS(ker23, Row 2 Col 3, DCTLUI_SLIDER_FLOAT, -1.0, -20.0, 20.0, 0.1)
DEFINE_UI_PARAMS(ker31, Row 3 Col 1, DCTLUI_SLIDER_FLOAT, 0.0, -20.0, 20.0, 0.1)
DEFINE_UI_PARAMS(ker32, Row 3 Col 2, DCTLUI_SLIDER_FLOAT, -1.0, -20.0, 20.0, 0.1)
DEFINE_UI_PARAMS(ker33, Row 3 Col 3, DCTLUI_SLIDER_FLOAT, 0.0, -20.0, 20.0, 0.1)
DEFINE_UI_PARAMS(coef, Coefficient, DCTLUI_SLIDER_FLOAT, 1.0, 0.0, 20.0, 0.01)
DEFINE_UI_PARAMS(coefR, Red Coefficient, DCTLUI_SLIDER_FLOAT, 1.0, 0.0, 10.0, 0.01)
DEFINE_UI_PARAMS(coefG, Green Coefficient, DCTLUI_SLIDER_FLOAT, 1.0, 0.0, 10.0, 0.01)
DEFINE_UI_PARAMS(coefB, Blue Coefficient, DCTLUI_SLIDER_FLOAT, 1.0, 0.0, 10.0, 0.01)
DEFINE_UI_PARAMS(offsetR, Red Offset, DCTLUI_SLIDER_FLOAT, 0.0, -1.0, 1.0, 0.001)
DEFINE_UI_PARAMS(offsetG, Green Offset, DCTLUI_SLIDER_FLOAT, 0.0, -1.0, 1.0, 0.001)
DEFINE_UI_PARAMS(offsetB, Blue Offset, DCTLUI_SLIDER_FLOAT, 0.0, -1.0, 1.0, 0.001)
__DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y, __TEXTURE__ p_TexR, __TEXTURE__ p_TexG, __TEXTURE__ p_TexB)
{
const float r = offsetR + (coef + coefR) * (
ker11 * (p_X * p_Y > 0? _tex2D(p_TexR, p_X - 1, p_Y - 1) : 0) +
ker12 * (p_Y > 0? _tex2D(p_TexR, p_X, p_Y - 1) : 0) +
ker13 * (p_Y * (p_Width - p_X - 1) > 0? _tex2D(p_TexR, p_X + 1, p_Y - 1) : 0) +
ker21 * (p_X > 0? _tex2D(p_TexR, p_X - 1, p_Y) : 0) +
ker22 * _tex2D(p_TexR, p_X, p_Y) +
ker23 * (p_Width - p_X - 1 > 0? _tex2D(p_TexR, p_X + 1, p_Y) : 0) +
ker31 * (p_X * (p_Height - p_Y - 1) > 0? _tex2D(p_TexR, p_X - 1, p_Y + 1) : 0) +
ker32 * (p_Height - p_Y - 1 > 0? _tex2D(p_TexR, p_X, p_Y + 1) : 0) +
ker33 * ((p_Width - p_X - 1) * (p_Height - p_Y - 1) > 0? _tex2D(p_TexR, p_X + 1, p_Y + 1) : 0)
);
const float g = offsetG + (coef + coefG) * (
ker11 * (p_X * p_Y > 0? _tex2D(p_TexG, p_X - 1, p_Y - 1) : 0) +
ker12 * (p_Y > 0? _tex2D(p_TexG, p_X, p_Y - 1) : 0) +
ker13 * (p_Y * (p_Width - p_X - 1) > 0? _tex2D(p_TexG, p_X + 1, p_Y - 1) : 0) +
ker21 * (p_X > 0? _tex2D(p_TexG, p_X - 1, p_Y) : 0) +
ker22 * _tex2D(p_TexG, p_X, p_Y) +
ker23 * (p_Width - p_X - 1 > 0? _tex2D(p_TexG, p_X + 1, p_Y) : 0) +
ker31 * (p_X * (p_Height - p_Y - 1) > 0? _tex2D(p_TexG, p_X - 1, p_Y + 1) : 0) +
ker32 * (p_Height - p_Y - 1 > 0? _tex2D(p_TexG, p_X, p_Y + 1) : 0) +
ker33 * ((p_Width - p_X - 1) * (p_Height - p_Y - 1) > 0? _tex2D(p_TexG, p_X + 1, p_Y + 1) : 0)
);
const float b = offsetB + (coef + coefB) * (
ker11 * (p_X * p_Y > 0? _tex2D(p_TexB, p_X - 1, p_Y - 1) : 0) +
ker12 * (p_Y > 0? _tex2D(p_TexB, p_X, p_Y - 1) : 0) +
ker13 * (p_Y * (p_Width - p_X - 1) > 0? _tex2D(p_TexB, p_X + 1, p_Y - 1) : 0) +
ker21 * (p_X > 0? _tex2D(p_TexB, p_X - 1, p_Y) : 0) +
ker22 * _tex2D(p_TexB, p_X, p_Y) +
ker23 * (p_Width - p_X - 1 > 0? _tex2D(p_TexB, p_X + 1, p_Y) : 0) +
ker31 * (p_X * (p_Height - p_Y - 1) > 0? _tex2D(p_TexB, p_X - 1, p_Y + 1) : 0) +
ker32 * (p_Height - p_Y - 1 > 0? _tex2D(p_TexB, p_X, p_Y + 1) : 0) +
ker33 * ((p_Width - p_X - 1) * (p_Height - p_Y - 1) > 0? _tex2D(p_TexB, p_X + 1, p_Y + 1) : 0)
);
return make_float3(r, g, b);
}