-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConv.dctl
62 lines (57 loc) · 3.23 KB
/
Conv.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
/************
Conv ver 2.0 by Passiflora Tsui
for using convolution in Davinci Resolve
************/
DEFINE_UI_PARAMS(ker11, Row 1 Col 1, DCTLUI_VALUE_BOX, 0.0)
DEFINE_UI_PARAMS(ker12, Row 1 Col 2, DCTLUI_VALUE_BOX, -1.0)
DEFINE_UI_PARAMS(ker13, Row 1 Col 3, DCTLUI_VALUE_BOX, 0.0)
DEFINE_UI_PARAMS(ker21, Row 2 Col 1, DCTLUI_VALUE_BOX, -1.0)
DEFINE_UI_PARAMS(ker22, Row 2 Col 2, DCTLUI_VALUE_BOX, 4.0)
DEFINE_UI_PARAMS(ker23, Row 2 Col 3, DCTLUI_VALUE_BOX, -1.0)
DEFINE_UI_PARAMS(ker31, Row 3 Col 1, DCTLUI_VALUE_BOX, 0.0)
DEFINE_UI_PARAMS(ker32, Row 3 Col 2, DCTLUI_VALUE_BOX, -1.0)
DEFINE_UI_PARAMS(ker33, Row 3 Col 3, DCTLUI_VALUE_BOX, 0.0)
DEFINE_UI_PARAMS(coef, Coefficient, DCTLUI_VALUE_BOX, 1.0)
DEFINE_UI_PARAMS(coefR, Red Coefficient, DCTLUI_VALUE_BOX, 1.0)
DEFINE_UI_PARAMS(coefG, Green Coefficient, DCTLUI_VALUE_BOX, 1.0)
DEFINE_UI_PARAMS(coefB, Blue Coefficient, DCTLUI_VALUE_BOX, 1.0)
DEFINE_UI_PARAMS(offsetR, Red Offset, DCTLUI_VALUE_BOX, 0.0)
DEFINE_UI_PARAMS(offsetG, Green Offset, DCTLUI_VALUE_BOX, 0.0)
DEFINE_UI_PARAMS(offsetB, Blue Offset, DCTLUI_VALUE_BOX, 0.0)
__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);
}