Thanks for your help with that error.
At the moment, the blur shader doesn't appear to be having any effect. I know it is loading because the whole screen turned purple when I tested.
However, when I restore it to the normal shader code, the screen appears unchanged.
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);
}
I tried manually filling in the blur_radius, in case I had to fill that in. I tried both 4.0 and 1.0. I notice no difference to the screen except strange random horizontal and vertical lines all the way across the screen, the same colour as some of the stars.
I also tried to change the code a bit like this to see if that would do anything:
vec4 pixel = texture2D(texture, gl_TexCoord[0].xy) * 0.0 +
texture2D(texture, gl_TexCoord[0].xy - offx) * 2.5 +
texture2D(texture, gl_TexCoord[0].xy + offx) * 2.5 +
texture2D(texture, gl_TexCoord[0].xy - offy) * 2.5 +
texture2D(texture, gl_TexCoord[0].xy + offy) * 2.5 +
texture2D(texture, gl_TexCoord[0].xy - offx - offy) * 1.5 +
texture2D(texture, gl_TexCoord[0].xy - offx + offy) * 1.5 +
texture2D(texture, gl_TexCoord[0].xy + offx - offy) * 1.5 +
texture2D(texture, gl_TexCoord[0].xy + offx + offy) * 1.5;
Here is the code:
sf::Shader blur;
if (sf::Shader::isAvailable())
{
if (!blur.loadFromFile("blur.frag", sf::Shader::Fragment))
{
std::cout << "Could Not Load Blur Shader!" <<std::endl;
}
}
else
{
std::cout << "Error! Shaders Not Supported!" <<std::endl;
}
sf::RenderTexture blurtexture;
if (!blurtexture.create(sf::VideoMode::getDesktopMode().width, sf::VideoMode::getDesktopMode().height))
{
std::cout << "Error Creating BlurTexture!" << std::endl;
}
blurtexture.clear(sf::Color::Black);
blurtexture.draw(smallstars);
for (i = 0; i < LARGESTAR_COUNT; i ++) {
blurtexture.draw(largestars[i]);
}
blurtexture.display();
sf::Sprite blursprite(blurtexture.getTexture());
window.clear(sf::Color::Black);
window.draw(blursprite, &blur);
window.display();