SFML community forums

Help => Graphics => Topic started by: Msonic on November 16, 2013, 07:46:49 am

Title: Shader issue with Color transparency
Post by: Msonic on November 16, 2013, 07:46:49 am
Hi,

I'm having some trouble with shaders and colors. See my StackOverflow question (http://stackoverflow.com/questions/20015601/semi-transparent-sprite-not-transparent-after-passed-through-a-fragment-shader)

Basically, when I have a fragment shader active, the Color field the object is not taken in consideration. I don't really know why.

I haven't found anything similar on the forum.

Any help is greatly appreciated!
Title: Re: Shader issue with Color transparency
Post by: fallahn on November 16, 2013, 08:32:58 am
When you use sprite.setColor() sfml is actually setting the vertex colours of the sprite. If you read the shader tutorial (http://www.sfml-dev.org/tutorials/2.1/graphics-shader.php) you'll find that by default the vertex colours are passed straight through and are available in fragment shaders via gl_Color. So in your case the transparency value can be found in gl_Color.a
Title: Re: Shader issue with Color transparency
Post by: Msonic on November 18, 2013, 05:11:23 pm
Hmmm, I see. I'll try this when I get back home.

Thanks for the quick reply!