Hello! I'm trying to get transparent texture like this (made with Photoshop)
by combining it from separate textures on transparent RenderTexture
If draw them in default blend mode and RenderTexture cleared as transparent, they loose glowing effects like in first image below. The result I want to ahcieve is like on right image, but it was cleared as black and it's not transparent
I tried all blending modes and tried unsuccessfully to write custom ones. What can I do? I think I could solve it with shaders but I didn't try yet. There's more elegant way for sure.
Here is a minimal code
#include <SFML/Graphics.hpp>
using namespace sf;
int main()
{
sf::RenderWindow window(sf::VideoMode(360, 200), "SFML works!", Style::Default);
window.setFramerateLimit(60);
sf::IntRect redNoteTextureBounds{ 0, 0, 184, 100 };
sf::IntRect blueNoteTextureBounds{ 184, 0, 184, 100 };
sf::IntRect longNotesTextureBounds{ 0, 100, 184, 100 };
Texture t; t.loadFromFile("Texture.png");
Sprite s1(t);
s1.setTextureRect(blueNoteTextureBounds);
RenderTexture rt;
Sprite s2(t);
rt.create(184, 175);
rt.clear(Color::Transparent);
s2.setTextureRect(blueNoteTextureBounds);
s2.setPosition(0, 0);
rt.draw(s2, RenderStates());
s2.setPosition(0,80);
rt.draw(s2, RenderStates());
s2.setTextureRect(longNotesTextureBounds);
s2.setPosition(0, 40);
rt.draw(s2, RenderStates());
rt.display();
s2.setTexture(rt.getTexture(), true);
s2.setPosition(130, 0);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(s1);
window.draw(s2);
window.display();
}
return 0;
}