forked from rodrigomas/DCTLs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGaussian.dctl
28 lines (17 loc) · 1.8 KB
/
Gaussian.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
// Gaussian Blur
// Resolution: 3x3
// Sigma^2 = 1
__CONSTANT__ float Gaus[9] = { 0.07511360795411207f, 0.12384140315297387f, 0.07511360795411207f,
0.12384140315297387f, 0.20417995557165622f, 0.12384140315297387f,
0.07511360795411207f, 0.12384140315297387f, 0.07511360795411207f };
__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;
}