I am trying to use sf::Shader for a simple grayscale filter (on certain sprites) and getting really confused trying to wrap my head around it. I looked at
http://en.sfml-dev.org/forums/index.php?topic=1791.0 but it seems to be outdated (the draw() function no longer takes a shader param for instance, and I couldnt set it in a renderstate as its const).
I got it working via bind/unbind() but I want to do it per-sprite - do I just keep binding and unbinding it then? or is there a better way?
secondly, while I've done some HLSL for DX before, I am getting confused with GLSL. I got tutorials that fill color or draw a circle working, but I cant quite figure out how to simply modify the inColor to grayscale it. Or how to even draw it. I tried a simple:
void main()
{
gl_FragColor = gl_Color;
}
and that just gives me a blank white screen.
Fyi here's my full render loop in case I missed anything:
//snip (setup views and stuff)
sf::Shader colorizePostEffect;
if (sf::Shader::isAvailable() )
{
if (colorizePostEffect.loadFromFile( "mypath", sf::Shader::Fragment ) )
{
// Setup the effect parameters
colorizePostEffect.bind();
}
}
mWindow->draw(everything);
mWindow->display();
colorizePostEffect.unbind();