SFML community forums

Help => Graphics => Topic started by: rcurtis on November 10, 2014, 03:52:20 pm

Title: Alpha artifacts
Post by: rcurtis on November 10, 2014, 03:52:20 pm
Hey guys,

  I was experimenting with implementing a runtime in SFML for GrapeFrukt exported animations (https://github.com/grapefrukt/grapefrukt-export).  But I have run into a bit of an issue I feel ill equipped to tackle.  In my first run, I noticed that all the animations were extremely pixelated when transformed (scaled, rotated, etc..), so I turned on texture smoothing. (http://i.imgur.com/ajyCjgy.png)

This fixed a lot of my aliasing issues, but introduced a bunch of alpha artifacts around the text that has a drop shadow. (http://i.imgur.com/ZQQalPR.png) 
It looks like a pre-multiplied alpha issue, but I'm not sure how to fix it in SFML (I'm using the .NET bindings).  I did a search for "pre-multiplied" and came up with very little.  I'm fairly certain this could be address with the new BlendMode stuff in the SFML repo, but documentation on how to use it is a bit scarce at the moment.

Thanks,
Rob
Title: Re: Alpha artifacts
Post by: Laurent on November 10, 2014, 05:00:34 pm
So what is your problem exactly? Finding the formula for pre-multiplied alpha, or finding how to apply it with SFML?
Title: Re: Alpha artifacts
Post by: rcurtis on November 10, 2014, 05:18:24 pm
Laurent,

Thanks for the reply.  I am using

Code: [Select]
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)

in my draw call for debugging and it gives even greater issues


(http://i.imgur.com/CsfEE1a.png)


This was rendered with mipmaps set to GL_LINEAR (which I believe SFML does with texture smoothing).  I 'm thinking this is not a pre-multiplied alpha issue, but I'm really not sure what to check next.


Here is the text graphic that is being rendered on top of the other images if your interested:


(http://i.imgur.com/mEAX5Kg.png)
Title: Re: Alpha artifacts
Post by: Laurent on November 10, 2014, 08:19:51 pm
I'm not sure if there's a perfect solution to this. Either you don't smooth and get aliasing issues, or you smooth and you get alpha-blending problems at edges.
Title: Re: Alpha artifacts
Post by: Nexus on November 10, 2014, 09:55:07 pm
You could try to enable the window's anti-aliasing to affect the whole rendered screen, not just a transformed texture.
Title: Re: Alpha artifacts
Post by: rcurtis on November 11, 2014, 03:13:45 pm
You could try to enable the window's anti-aliasing to affect the whole rendered screen, not just a transformed texture.

Are you talking about openGL multisampling?  If so, I am currently using multisampling with a value of 4 when the context is created.