SFML community forums

Help => General => Topic started by: GamDev on June 07, 2018, 07:48:31 pm

Title: Shader in sf::Drawable
Post by: GamDev on June 07, 2018, 07:48:31 pm
Hello, please tell me it's possible to do this:
I have an image size of 128x64, that is 2 sprite.
I draw them like this:
(click to show/hide)
Tell me, please, is it possible to use the shader only on the second sprite inside the DrawTileMap class?
Title: Re: Shader in sf::Drawable
Post by: Hapax on June 12, 2018, 12:25:43 am
As I see it, you would need someway of telling the shader when and when not to be applied. One idea, if you don't need the alpha channels of the texture, is to make one of them fully transparent (still keeping the colours of course!). Then, in the shader, if check the texture's alpha channel and if it's higher or lower than half, apply the effect or pass the pixel unaffected.