stk-code_catmod/data/shaders/gaussian17tapv.frag
vlj e5a5c78045 Use a big triangle instead of 2 to cover full screen.
This allows to rasterize a single primitive instead of two, and avoid
trashing the cache between the 2 triangles drawing.
2014-06-03 19:56:59 +02:00

32 lines
671 B
GLSL

// From http://http.developer.nvidia.com/GPUGems3/gpugems3_ch40.html
uniform sampler2D tex;
uniform vec2 pixel;
uniform float sigma = 5.;
out vec4 FragColor;
void main()
{
vec2 uv = gl_FragCoord.xy * pixel;
float X = uv.x;
float Y = uv.y;
float g0, g1, g2;
g0 = 1.0 / (sqrt(2.0 * 3.14) * sigma);
g1 = exp(-0.5 / (sigma * sigma));
g2 = g1 * g1;
vec4 sum = texture(tex, vec2(X, Y)) * g0;
g0 *= g1;
g1 *= g2;
for (int i = 1; i < 9; i++) {
sum += texture(tex, vec2(X, Y - i * pixel.y)) * g0;
sum += texture(tex, vec2(X, Y + i * pixel.y)) * g0;
g0 *= g1;
g1 *= g2;
}
FragColor = sum;
}