forked from tidus747/Avolition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgaussian_blur.sha
47 lines (40 loc) · 1.16 KB
/
gaussian_blur.sha
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
//Cg
//Hardcoded fast gaussian blur from here http://jahovaos.com/groups/kb/wiki/21ad5/Bloom.html
void vshader(
float4 vtx_position : POSITION,
float2 vtx_texcoord0 : TEXCOORD0,
out float4 l_position : POSITION,
out float2 l_texcoord0 : TEXCOORD0,
uniform float4 texpad_tex2,
uniform float4x4 mat_modelproj)
{
l_position=mul(mat_modelproj, vtx_position);
l_texcoord0 = vtx_position.xz * texpad_tex2.xy + texpad_tex2.xy;
}
void fshader(float2 l_texcoord0 : TEXCOORD0,
out float4 o_color : COLOR,
uniform float4 texpad_tex2,
uniform sampler2D k_tex2 : TEXUNIT0)
{
float2 samples[12] = {
-0.326212, -0.405805,
-0.840144, -0.073580,
-0.695914, 0.457137,
-0.203345, 0.620716,
0.962340, -0.194983,
0.473434, -0.480026,
0.519456, 0.767022,
0.185461, -0.893124,
0.507431, 0.064425,
0.896420, 0.412458,
-0.321940, -0.932615,
-0.791559, -0.597705
};
float4 c = 0;
for(int i = 0 ; i < 12 ; i++)
{
c += tex2D(k_tex2, l_texcoord0 + samples[i] * 0.005);
}
c /=13;
o_color = c;
}