2007-04-29 17:35:43 +00:00
|
|
|
uniform sampler2D inputTex;
|
|
|
|
|
2007-12-14 16:57:38 +00:00
|
|
|
varying vec2 samplePos1;
|
|
|
|
varying vec2 samplePos2;
|
|
|
|
varying vec2 samplePos3;
|
|
|
|
varying vec2 samplePos4;
|
|
|
|
varying vec2 samplePos5;
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
|
2007-12-14 16:57:38 +00:00
|
|
|
// If defined, use five samples (blur radius = 5), otherwise 3 samples (radius = 3)
|
|
|
|
#define FIVE_SAMPLES
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-12-14 16:57:38 +00:00
|
|
|
vec3 blurTex(vec2 pos, float strength)
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
2007-12-14 16:57:38 +00:00
|
|
|
return texture2D(inputTex, pos).rgb * strength;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
// Do the gaussian blur
|
|
|
|
// This blur actually has a radius of 4, but we take advantage of gpu's
|
|
|
|
// linear texture filtering, so e.g. 1.5 actually gives us both texels
|
|
|
|
// 1 and 2
|
2007-12-14 16:57:38 +00:00
|
|
|
#ifdef FIVE_SAMPLES
|
|
|
|
vec3 tex = blurTex(samplePos1, 0.30);
|
|
|
|
tex += blurTex(samplePos2, 0.25);
|
|
|
|
tex += blurTex(samplePos3, 0.25);
|
|
|
|
tex += blurTex(samplePos4, 0.1);
|
|
|
|
tex += blurTex(samplePos5, 0.1);
|
|
|
|
#else
|
|
|
|
vec3 tex = blurTex(samplePos1, 0.40);
|
|
|
|
tex += blurTex(samplePos2, 0.30);
|
|
|
|
tex += blurTex(samplePos3, 0.30);
|
|
|
|
#endif
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
gl_FragColor = vec4(tex, 1.0);
|
|
|
|
}
|
|
|
|
|