1// Higher value, more centered glow.
2// Lower values might need more taps.
3#define GLOW_FALLOFF 0.35
4#define TAPS 4.
5
6#define kernel(x) exp(-GLOW_FALLOFF * (x) * (x))
7
8#if defined(VERTEX)
9
10#if __VERSION__ >= 130
11#define COMPAT_VARYING out
12#define COMPAT_ATTRIBUTE in
13#define COMPAT_TEXTURE texture
14#else
15#define COMPAT_VARYING varying
16#define COMPAT_ATTRIBUTE attribute
17#define COMPAT_TEXTURE texture2D
18#endif
19
20#ifdef GL_ES
21#define COMPAT_PRECISION mediump
22#else
23#define COMPAT_PRECISION
24#endif
25
26COMPAT_ATTRIBUTE vec4 VertexCoord;
27COMPAT_ATTRIBUTE vec4 COLOR;
28COMPAT_ATTRIBUTE vec4 TexCoord;
29COMPAT_VARYING vec4 COL0;
30COMPAT_VARYING vec4 TEX0;
31
32uniform mat4 MVPMatrix;
33uniform COMPAT_PRECISION int FrameDirection;
34uniform COMPAT_PRECISION int FrameCount;
35uniform COMPAT_PRECISION vec2 OutputSize;
36uniform COMPAT_PRECISION vec2 TextureSize;
37uniform COMPAT_PRECISION vec2 InputSize;
38
39void main()
40{
41    gl_Position = MVPMatrix * VertexCoord;
42    COL0 = COLOR;
43    TEX0.xy = TexCoord.xy;
44}
45
46#elif defined(FRAGMENT)
47
48#if __VERSION__ >= 130
49#define COMPAT_VARYING in
50#define COMPAT_TEXTURE texture
51out vec4 FragColor;
52#else
53#define COMPAT_VARYING varying
54#define FragColor gl_FragColor
55#define COMPAT_TEXTURE texture2D
56#endif
57
58#ifdef GL_ES
59#ifdef GL_FRAGMENT_PRECISION_HIGH
60precision highp float;
61#else
62precision mediump float;
63#endif
64#define COMPAT_PRECISION mediump
65#else
66#define COMPAT_PRECISION
67#endif
68
69uniform COMPAT_PRECISION int FrameDirection;
70uniform COMPAT_PRECISION int FrameCount;
71uniform COMPAT_PRECISION vec2 OutputSize;
72uniform COMPAT_PRECISION vec2 TextureSize;
73uniform COMPAT_PRECISION vec2 InputSize;
74uniform sampler2D Texture;
75COMPAT_VARYING vec4 TEX0;
76
77// compatibility #defines
78#define Source Texture
79#define vTexCoord TEX0.xy
80
81#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
82#define outsize vec4(OutputSize, 1.0 / OutputSize)
83
84void main()
85{
86	vec3 col = vec3(0.0);
87	float dy = SourceSize.w;
88
89	float k_total = 0.;
90	for (float i = -TAPS; i <= TAPS; i++)
91		{
92		float k = kernel(i);
93		k_total += k;
94		col += k * COMPAT_TEXTURE(Source, vTexCoord + vec2(0.0, float(i) * dy)).rgb;
95		}
96   FragColor = vec4(col / k_total, 1.0);
97}
98#endif
99