File: blur-f.sdr

package info (click to toggle)
freespace2 24.2.0%2Brepack-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid
  • size: 43,716 kB
  • sloc: cpp: 595,001; ansic: 21,741; python: 1,174; sh: 457; makefile: 248; xml: 181
file content (41 lines) | stat: -rw-r--r-- 1,333 bytes parent folder | download | duplicates (2)
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
out vec4 fragOut0;

in vec4 fragTexCoord;

uniform sampler2D tex;

const float TapSize = 1.0;

layout (std140) uniform genericData {
	float texSize;
	int level;
};

// Gaussian Blur
// 2 passes required
void main()
{
	// Echelon9 - Due to Apple not implementing array constructors in OS X's
	// GLSL implementation we need to setup the arrays this way as a workaround
	float BlurWeights[6];
	BlurWeights[5] = 0.0402;
	BlurWeights[4] = 0.0623;
	BlurWeights[3] = 0.0877;
	BlurWeights[2] = 0.1120;
	BlurWeights[1] = 0.1297;
	BlurWeights[0] = 0.1362;
	vec4 sum = textureLod(tex, fragTexCoord.xy, float(level)) * BlurWeights[0];
#ifdef PASS_0
	for (int i = 1; i < 6; i++) {
		sum += textureLod(tex, vec2(clamp(fragTexCoord.x - float(i) * (texSize) * TapSize, 0.0, 1.0), fragTexCoord.y), float(level)) * BlurWeights[i];
		sum += textureLod(tex, vec2(clamp(fragTexCoord.x + float(i) * (texSize) * TapSize, 0.0, 1.0), fragTexCoord.y), float(level)) * BlurWeights[i];
	}
#endif
#ifdef PASS_1
	for (int i = 1; i < 6; i++) {
		sum += textureLod(tex, vec2(fragTexCoord.x, clamp(fragTexCoord.y - float(i) * (texSize) * TapSize, 0.0, 1.0)), float(level)) * BlurWeights[i];
		sum += textureLod(tex, vec2(fragTexCoord.x, clamp(fragTexCoord.y + float(i) * (texSize) * TapSize, 0.0, 1.0)), float(level)) * BlurWeights[i];
	}
#endif
	fragOut0 = sum;
}