Hi,
I'm trying to apply a blur shader on one of my sprites. But all I get is the texture with a half transparent grey cross layed over it (See screenshot below). Can someone tell me what I have done wrong?
This is my code that draws the sprite:
shader.setParameter("blur_radius", 20);
shader.setParameter("texture", backgroundTexture);
window.clear(sf::Color::Transparent);
window.draw(backgroundSprite, &shader);
window.display();
And this is my shader:
uniform sampler2D texture;
uniform float blur_radius;
void main()
{
vec2 offx = vec2(blur_radius, 0.0);
vec2 offy = vec2(0.0, blur_radius);
vec4 pixel = texture2D(texture, gl_TexCoord[0].xy) * 4.0 +
texture2D(texture, gl_TexCoord[0].xy - offx) * 2.0 +
texture2D(texture, gl_TexCoord[0].xy + offx) * 2.0 +
texture2D(texture, gl_TexCoord[0].xy - offy) * 2.0 +
texture2D(texture, gl_TexCoord[0].xy + offy) * 2.0 +
texture2D(texture, gl_TexCoord[0].xy - offx - offy) * 1.0 +
texture2D(texture, gl_TexCoord[0].xy - offx + offy) * 1.0 +
texture2D(texture, gl_TexCoord[0].xy + offx - offy) * 1.0 +
texture2D(texture, gl_TexCoord[0].xy + offx + offy) * 1.0;
gl_FragColor = gl_Color * (pixel / 16.0);
}
The shader is loaded correctly and shaders are supported on my computer.
And here is the screenshot of the sprite (As you can see, there is no blur):
Thanks,
StuntHacks