It could. I would need to change the way components behave by accessing other component's information.
I ended up writing a smart shader. It keeps a table of individual uniform values and a reference to the sf::Shader. It also overloads copy and assignment operators with sf::Shader so you can use it naturally: e.g.
sf::Shader* GetShader(ShaderType type) { ... }
SmartShader pixelate = GetShader(ShaderType::PIXEL_BLUR);
pixelate.SetUniform("factor", timer/maxTimer);
In order to share between other entities it has a function called ApplyUniforms()
that steps through the table and setting uniform values before the engine calls Draw()
on the entity.
After drawing for cleanliness sake there's another function ResetUniforms()
that sets the uniforms to the type-equivalent of zero.
At any time SmartShaders can free the reference to an sf::Shader by using Release()
.
I'm satisfied with the results.