32 lines
1.4 KiB
GLSL
32 lines
1.4 KiB
GLSL
#version 330 core
|
|
|
|
// linear sampling gaussian blur (kernel size : 9)
|
|
// from http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling
|
|
|
|
uniform sampler2DRect colorSampler;
|
|
|
|
layout(location = 0)out vec4 outColor;
|
|
|
|
uniform int width;
|
|
uniform int height;
|
|
|
|
void main(void)
|
|
{
|
|
//vec3 color = vec3(0);
|
|
vec3 color = texelFetch(colorSampler, ivec2(gl_FragCoord.x/width, gl_FragCoord.y/height)).xyz * 0.2270270270;
|
|
#ifdef HORIZONTAL_BLUR
|
|
float y = gl_FragCoord.y/height;
|
|
color += texture(colorSampler, vec2((gl_FragCoord.x + 1.3846153846)/width, y)).xyz * 0.3162162162;
|
|
color += texture(colorSampler, vec2((gl_FragCoord.x - 1.3846153846)/width, y)).xyz * 0.3162162162;
|
|
color += texture(colorSampler, vec2((gl_FragCoord.x + 3.2307692308)/width, y)).xyz * 0.0702702703;
|
|
color += texture(colorSampler, vec2((gl_FragCoord.x - 3.2307692308)/width, y)).xyz * 0.0702702703;
|
|
#else
|
|
float x = gl_FragCoord.x/width;
|
|
color += texture(colorSampler, vec2(x, (gl_FragCoord.y + 1.3846153846)/height)).xyz * 0.3162162162;
|
|
color += texture(colorSampler, vec2(x, (gl_FragCoord.y - 1.3846153846)/height)).xyz * 0.3162162162;
|
|
color += texture(colorSampler, vec2(x, (gl_FragCoord.y + 3.2307692308)/height)).xyz * 0.0702702703;
|
|
color += texture(colorSampler, vec2(x, (gl_FragCoord.y - 3.2307692308)/height)).xyz * 0.0702702703;
|
|
#endif
|
|
outColor = vec4(color, 1.0);
|
|
}
|