Hello, I'm rendering everything to RenderTexture: image and polygon. It looks like 1.png from attachment. The code is:
sf::Texture img;
img.loadFromFile("test.png");
RENDER_TEXTURE->draw(sf::Sprite(img));
sf::ConvexShape polygon;
polygon.setPointCount(3);
polygon.setPoint(0, sf::Vector2f(0, 0));
polygon.setPoint(1, sf::Vector2f(230, 10));
polygon.setPoint(2, sf::Vector2f(70, 200));
polygon.setOutlineColor(sf::Color::Red);
polygon.setFillColor(sf::Color::Transparent);
polygon.setOutlineThickness(5);
RENDER_TEXTURE->draw(polygon);
Now I want to apply some shader for the area inside that polygon. I wrote a simple one:
uniform sampler2D texture;
void main()
{
vec4 color = texture2D(texture, gl_TexCoord[0].xy);
if (color.a != 0.)
{
color.r += 0.4;
}
gl_FragColor = color;
}
And changed the code of polygon drawing to:
shader.setParameter("texture", sf::Shader::CurrentTexture);
RENDER_TEXTURE->draw(polygon, shader);
The result you could see at second attachment. So, the shader is applied only for polygon, not for the whole texture inside it. But what to do if I want to pass that area inside polygon into shader and make it more red?
[attachment deleted by admin]