forked from rodrigomas/DCTLs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEdge_Detect.dctl
28 lines (16 loc) · 1.65 KB
/
Edge_Detect.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
// Edge Detect
// Resolution: 3x3
__CONSTANT__ float Gaus[9] = { 0.0f, 1.0f, 0.0f,
1.0f, -4.0f, 1.0f,
0.0f, 1.0f, 0.0f };
__DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y, __TEXTURE__ p_TexR, __TEXTURE__ p_TexG, __TEXTURE__ p_TexB)
{
float3 result;
result.x = (Gaus[0] * _tex2D(p_TexR, p_X - 1, p_Y + 1)) + (Gaus[1] * _tex2D(p_TexR, p_X, p_Y + 1)) + (Gaus[2] * _tex2D(p_TexR, p_X + 1, p_Y + 1)) + (Gaus[3] * _tex2D(p_TexR, p_X - 1, p_Y)) + (Gaus[4] * _tex2D(p_TexR, p_X, p_Y))
+ (Gaus[5] * _tex2D(p_TexR, p_X + 1, p_Y)) + (Gaus[6] * _tex2D(p_TexR, p_X - 1, p_Y - 1)) + (Gaus[7] * _tex2D(p_TexR, p_X, p_Y - 1)) + (Gaus[8] * _tex2D(p_TexR, p_X - 1, p_Y - 1));
result.y = (Gaus[0] * _tex2D(p_TexG, p_X - 1, p_Y + 1)) + (Gaus[1] * _tex2D(p_TexG, p_X, p_Y + 1)) + (Gaus[2] * _tex2D(p_TexG, p_X + 1, p_Y + 1)) + (Gaus[3] * _tex2D(p_TexG, p_X - 1, p_Y)) + (Gaus[4] * _tex2D(p_TexG, p_X, p_Y))
+ (Gaus[5] * _tex2D(p_TexG, p_X + 1, p_Y)) + (Gaus[6] * _tex2D(p_TexG, p_X - 1, p_Y - 1)) + (Gaus[7] * _tex2D(p_TexG, p_X, p_Y - 1)) + (Gaus[8] * _tex2D(p_TexG, p_X - 1, p_Y - 1));
result.z = (Gaus[0] * _tex2D(p_TexB, p_X - 1, p_Y + 1)) + (Gaus[1] * _tex2D(p_TexB, p_X, p_Y + 1)) + (Gaus[2] * _tex2D(p_TexB, p_X + 1, p_Y + 1)) + (Gaus[3] * _tex2D(p_TexB, p_X - 1, p_Y)) + (Gaus[4] * _tex2D(p_TexB, p_X, p_Y))
+ (Gaus[5] * _tex2D(p_TexB, p_X + 1, p_Y)) + (Gaus[6] * _tex2D(p_TexB, p_X - 1, p_Y - 1)) + (Gaus[7] * _tex2D(p_TexB, p_X, p_Y - 1)) + (Gaus[8] * _tex2D(p_TexB, p_X - 1, p_Y - 1));
return result;
}